Jump to content

Daedalus' First Challenge


Daedalus

Recommended Posts

A long time ago, I discovered how to modify a function in such a way as to only affect a single output for a given input. The function's domain is restricted to the set of integers. The following is an example of what I am describing:

 

[math]f \colon \mathbb{Z} \rightarrow \mathbb{R}[/math] defined by [math]f(x)=x^2[/math]

 

Without affecting any other output of [math]f(x)=x^2[/math], can you figure out how to modify the function such that [math]f(3)=\pi[/math] ? The modified equation must still produce all other outputs of [math]f(x)[/math] and only change the output of [math]f(3)[/math] such that it would produce the following sequence (ignoring negatives in the example):

 

{..., 0, 1, 4, [math]\pi[/math], 16, 25, 36, ...}

 

If you have read this post carefully, you might be able to figure out the missing piece:

 

[math]f(x)=x^2 \, + \, ?[/math]

 

I will post the answer at the end of the week unless someone solves this problem or requests more time : )

 

Edited to state the rules:

 

You cannot define [math]f(3)=\pi[/math] or use piecewise functions.

You can only use addition, subtraction, multiplication, division, exponents, and the variable [math]x[/math] and nothing else.

No higher order operations such as series operators, trigonometry, etc.. is allowed (This includes modular arithmetic).

Edited by Daedalus
Link to comment
Share on other sites

This seems a little bit ill-defined. What are the restrictions and rules? I mean, it'd be a bit trivial with the heaviside step function. Or just:

[math] f(x) = x^2 | x \neq 3[/math]

[math] f(x) = \pi \, | x = 3 [/math]

 

(note: I don't pretend that these are the intended answer, they just don't appear to be excluded by what you said)

Edited by Schrödinger's hat
Link to comment
Share on other sites

I'm sorry I didn't cleary define the rules. I actually thought about stating that one could not just define [math]f(3)=\pi[/math], but I figured that was obvious enough. Also, I will not accept any form of interpolation or piecewise functions.

 

The answer is actually quite simple. However, it takes a little thought. It took me about 2 hours to figure it out when I first thought about this problem. But, I had been working on similiar problems at the time : )

Edited by Daedalus
Link to comment
Share on other sites

I'm sorry I didn't cleary define the rules. I actually thought about stating that one could not just define [math]f(3)=\pi[/math], but I figured that was obvious enough. Also, I will not accept any form of interpolation or piecewise functions.

 

The answer is actually quite simple. However, it takes a little thought. It took me about 2 hours to figure it out when I first thought about this problem. But, I had been working on similiar problems at the time : )

I'm assuming you're including things like the step function in piecewise functions.

Still seems either too obvious or too obtuse. What about floor/ceiling/round?

Perhaps there is some form of succinct way of stating what types of things we are allowed to add?

Edited by Schrödinger's hat
Link to comment
Share on other sites

The modification that I am looking for only makes use of elementary operators (+, -, *, /, ^) and nothing more. I did not use a piecewise function, series operators, trigonometry, or any other higher operators.

 

I do realize that it seems impossible, but I assure you that it can be done using simple math.

Edited by Daedalus
Link to comment
Share on other sites

The modification that I am looking for only makes use of elementary operators (+, -, *, /, ^) and nothing more. I did not use a piecewise function, series operators, trigonometry, or any other higher operators.

 

I do realize that it seems impossible, but I assure you it can be done using simple math.

 

Ah, now it's more interesting, and a bit of a head scratcher.

The only way I can think of still involves something along the lines of

[math] \lim_{a\rightarrow\infty} (\pi-3)(g(x))^a[/math]

 

Alternatively, I could cheat and pretend that by * you meant complex conjugate... ^_^

Edited by Schrödinger's hat
Link to comment
Share on other sites

Ah, now it's more interesting, and a bit of a head scratcher.

The only way I can think of still involves something along the lines of

[math] \lim_{a\rightarrow\infty} (\pi-3)(g(x))^a[/math]

 

I'm sorry Schrödinger's hat, but I only used elementary operators. No Calculus, or any higher mathematics except Algebra.

 

I'll give you a hint in that the input, 3, is an arbitrary value. I could've chosen any integer value for the input.

Edited by Daedalus
Link to comment
Share on other sites

One more question: Are we allowed to assume a^0.5 will be the positive square root, as per convention?

 

You are allowed to assume anything, except piecewise functions, as long as it only uses elementary operators. Otherwise, I solved this problem using only addition, subtraction, multiplication, division, and powers. Oh, and of course, the variable [math]x[/math].

Edited by Daedalus
Link to comment
Share on other sites

You are allowed to assume anything, except piecewise functions, as long as it only uses elementary operators.

Well technically ^0.5 is many valued and as such makes the resulting expression not a function unless we take 'the positive solution of ^0.5'

 

Okay, now I got it. It was just a matter of figuring out exactly how I was allowed to cheat ^_^. Although my answer is possibly a bit more convoluted than it should be.

Edited by Schrödinger's hat
Link to comment
Share on other sites

It can be quite a challenging problem. But, it will make you smile once you figure it out :D. Plus, the simplicity of the solution is actually quite impressive for what it actually does. The main hint in the problem is that the domain is restricted to the set of integers.

 

Plus, the output [math]\pi[/math] is as arbitrary as the input 3. I figured you already made that determination. I made this statement for others who are trying to solve this problem. I'm going to go watch a movie. I'll check back periodically : )

 

One more thing.... I did not use the modulo operator or modular arithmetic ; )

Edited by Daedalus
Link to comment
Share on other sites

What is 0^0 in this case?

 

Sorry uncool, [math]0^0[/math] is not defined and must be handled as an indeterminate form. This leads us to evaluate the limit of [math]0^x[/math] as [math]x[/math] approaches zero which would not produce the desired solution:

 

[math]\lim_{x \, \to \, 0}0^x=0[/math]

 

We could consider:

 

[math]\lim_{x \, \to \, 0}x^0=1[/math]

 

But, this would not produce the correct solution either.

 

The solution itself does not rely on Calculus and, as stated, requires only elementary operators such as addition, subtraction, multiplication, division, and exponents that operate on the variable, [math]x[/math]. However, at risk of giving away the answer, you are on the right track by considering exponents : )

 

To up the ante, I will give the person who solves this five stars and reputation if they do so before I post the solution.

Edited by Daedalus
Link to comment
Share on other sites

We have a winner. Good job uncool!!! Except you didn't check the math so your answer didn't come out exact. But you did realize the solution : )

 

 

 

 

[math]f(x) = x^2 - (9 - \pi)*((-1)^{2^{((x - 3)^2)}} - 1)/2[/math]

=Uncool-

 

Your solution gave:

 

{1, 4, 18-[math]\pi[/math], 16, 25, etc...}

 

 

The solutions to alot of the problems I solve requires alternating sums. I realized that [math](-1)^x[/math] produces -1 or 1 whether the integer was odd or even. It didn't take me long to figure out that [math](1-(-1)^x)/2[/math] produces a 1 or 0. You can switch the one or zero pending on if you use a + or - :

 

[math]\frac{1\pm(-1)^x}{2}[/math]

 

After some thought I realized that by using [math]2^{x^2}[/math] as the exponent, the function would produce zeroes for all other integers except when [math]x=0[/math] which produces a one. The correct solution is:

 

[math]f \colon \mathbb{Z} \rightarrow \mathbb{R}[/math] defined by [math]f(x)=x^2+(\pi - 9)\frac{1-(-1)^{2^{(x-3)^2}}}{2}[/math]

 

 

Edited by Daedalus
Link to comment
Share on other sites

Better than my solution, which I think is much more cumbersome, and a bit flaky as you have to assume positive square root.

 

[math]x^2 + \frac{1}{2}\left(1- \frac{(x - 3)^2 - 0.5}{(( (x - 3)^2 - 0.5)^2)^{\frac{1}{2}}}\right)(\pi - 9)[/math]

 

Also your rule of 'no trig' threw me waaay off of the trail of using (-1)^(f(x)) without prohibiting its use. Well done. :D

Edited by Schrödinger's hat
Link to comment
Share on other sites

Better than my solution, which I think is much more cumbersome, and a bit flaky as you have to assume positive square root.

 

[math]x^2 + \frac{1}{2}\left(1- \frac{(x - 3)^2 - 0.5}{(( (x - 3)^2 - 0.5)^2)^{\frac{1}{2}}}\right)(\pi - 9)[/math]

 

Also your rule of 'no trig' threw me waaay off of the trail of using (-1)^(f(x)) without prohibiting its use. Well done. :D

 

Thank you Schrödinger's hat. Your solution is interesting as well : )

Link to comment
Share on other sites

It does have the interesting feature that -- with a slight modification -- you can make the additional part both continuous, and non-zero for an arbitrarily small region.

 

Very cool indeed! I'll have to explore your method in more detail. I give you props : )

Link to comment
Share on other sites

  • 3 years later...

Without affecting any other output of [math]f(x)=x^2[/math], can you figure out how to modify the function such that [math]f(3)=\pi[/math] ? The modified equation must still produce all other outputs of [math]f(x)[/math] and only change the output of [math]f(3)[/math] such that it would produce the following sequence (ignoring negatives in the example):

 

{..., 0, 1, 4, [math]\pi[/math], 16, 25, 36, ...}

 

If you have read this post carefully, you might be able to figure out the missing piece:

 

[math]f(x)=x^2 \, + \, ?[/math]

In programming we're dealing with it every single day dozen of times.

 

 

 

In C/C++ it would be f.e.

y = ( x==3 ) ? M_PI : x*x;

 

Comparison can be replaced by subtraction

x'=x-3

Now we need to check whether x' is 0 or not.

sgn() can do it:

x''=sgn(x')

 

Is it allowed to use sgn() in this challenge?

https://en.wikipedia.org/wiki/Sign_function

 

sgn() returns -1 if input is negative, +1 if input is positive, or 0 if it's 0.

 

So, after sgn() we need to use abs() to turn -1 to +1:

abs(sgn(x-3))

Now output will be only 0 and 1.

 

(We can notice that abs(sgn(x)) is also equal to sgn(x)^2, -1*(-1)=+1 and +1*1=+1)

 

We need to reverse it by using (1-abs(sgn(x-3)))

this way if we multiply it by anything, if x!=3, will be multiplied by 0, and canceled.

 

[math]f(x)=x^2+(-9+\pi)*(1-\left|sgn(x-3)\right|)[/math]

 

abs(x)=sgn(x)*x

so

sgn(x)=abs(x)/x (except x=0)

 

and

 

abs(x)=sqrt(x*x)=(x^2)^0.5

 

so

 

sgn(x)=((x^2)^0.5)/x (except x=0)

 

If you can make sgn() (any way) using just add, sub, multiply, divide, power, sqrt, etc. you can finish my logic.

 

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.