# Daedalus' First Challenge

## 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:

$f \colon \mathbb{Z} \rightarrow \mathbb{R}$ defined by $f(x)=x^2$

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

{..., 0, 1, 4, $\pi$, 16, 25, 36, ...}

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

$f(x)=x^2 \, + \, ?$

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 $f(3)=\pi$ or use piecewise functions.

You can only use addition, subtraction, multiplication, division, exponents, and the variable $x$ and nothing else.

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

Edited by Daedalus

##### 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:

$f(x) = x^2 | x \neq 3$

$f(x) = \pi \, | x = 3$

(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

##### 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 $f(3)=\pi$, 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

##### 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 $f(3)=\pi$, 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

##### 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

##### 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

$\lim_{a\rightarrow\infty} (\pi-3)(g(x))^a$

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

Edited by Schrödinger's hat

##### 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

$\lim_{a\rightarrow\infty} (\pi-3)(g(x))^a$

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

##### Share on other sites

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.

Of course.

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

##### 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 $x$.

Edited by Daedalus

##### 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

##### Share on other sites

It can be quite a challenging problem. But, it will make you smile once you figure it out . 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 $\pi$ 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

##### Share on other sites

One more hint... The modification must produce zeroes for all inputs except $f(3)$ which must produce $\pi - 9$.

##### Share on other sites

What is 0^0 in this case?

=Uncool-

##### Share on other sites

What is 0^0 in this case?

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

$\lim_{x \, \to \, 0}0^x=0$

We could consider:

$\lim_{x \, \to \, 0}x^0=1$

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, $x$. 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

##### Share on other sites

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

=Uncool-

##### 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 : )

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

=Uncool-

{1, 4, 18-$\pi$, 16, 25, etc...}

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

$\frac{1\pm(-1)^x}{2}$

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

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

Edited by Daedalus

##### 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.

$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)$

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

Edited by Schrödinger's hat

##### 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.

$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)$

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

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

##### Share on other sites

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

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.

##### 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 : )

##### Share on other sites

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

{..., 0, 1, 4, $\pi$, 16, 25, 36, ...}

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

$f(x)=x^2 \, + \, ?$

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?

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.

$f(x)=x^2+(-9+\pi)*(1-\left|sgn(x-3)\right|)$

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.

##### Share on other sites

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

Sorry Sensei,

The solution to this challenge had nothing to do with programming.

## Create an account

Register a new account