Daedalus 329 Posted September 28, 2011 (edited) 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 September 28, 2011 by Daedalus 1 Share this post Link to post Share on other sites

Schrödinger's hat 230 Posted September 28, 2011 (edited) 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 September 28, 2011 by Schrödinger's hat 0 Share this post Link to post Share on other sites

Daedalus 329 Posted September 28, 2011 (edited) 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 September 28, 2011 by Daedalus 0 Share this post Link to post Share on other sites

Schrödinger's hat 230 Posted September 28, 2011 (edited) 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 September 28, 2011 by Schrödinger's hat 0 Share this post Link to post Share on other sites

Daedalus 329 Posted September 28, 2011 (edited) 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 September 28, 2011 by Daedalus 0 Share this post Link to post Share on other sites

Schrödinger's hat 230 Posted September 28, 2011 (edited) 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 September 28, 2011 by Schrödinger's hat 0 Share this post Link to post Share on other sites

Daedalus 329 Posted September 28, 2011 (edited) 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 September 28, 2011 by Daedalus 0 Share this post Link to post Share on other sites

Schrödinger's hat 230 Posted September 28, 2011 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? 0 Share this post Link to post Share on other sites

Daedalus 329 Posted September 28, 2011 (edited) 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 September 28, 2011 by Daedalus 0 Share this post Link to post Share on other sites

Schrödinger's hat 230 Posted September 28, 2011 (edited) 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 September 28, 2011 by Schrödinger's hat 0 Share this post Link to post Share on other sites

Daedalus 329 Posted September 28, 2011 (edited) 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 [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 September 28, 2011 by Daedalus 0 Share this post Link to post Share on other sites

Daedalus 329 Posted September 29, 2011 One more hint... The modification must produce zeroes for all inputs except [math]f(3)[/math] which must produce [math]\pi - 9[/math]. 0 Share this post Link to post Share on other sites

uncool 227 Posted September 29, 2011 What is 0^0 in this case? =Uncool- 0 Share this post Link to post Share on other sites

Daedalus 329 Posted September 29, 2011 (edited) 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 September 29, 2011 by Daedalus 0 Share this post Link to post Share on other sites

uncool 227 Posted September 29, 2011 [math]f(x) = x^2 - (9 - \pi)*((-1)^{2^{((x - 3)^2)}} - 1)/2[/math] =Uncool- 1 Share this post Link to post Share on other sites

Daedalus 329 Posted September 29, 2011 (edited) 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 September 29, 2011 by Daedalus 1 Share this post Link to post Share on other sites

Schrödinger's hat 230 Posted September 30, 2011 (edited) 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. Edited September 30, 2011 by Schrödinger's hat 1 Share this post Link to post Share on other sites

Daedalus 329 Posted September 30, 2011 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. Thank you Schrödinger's hat. Your solution is interesting as well : ) 0 Share this post Link to post Share on other sites

Schrödinger's hat 230 Posted September 30, 2011 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. 0 Share this post Link to post Share on other sites

Daedalus 329 Posted September 30, 2011 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 : ) 0 Share this post Link to post Share on other sites

Sensei 975 Posted September 15, 2015 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. 0 Share this post Link to post Share on other sites

Daedalus 329 Posted September 15, 2015 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. 0 Share this post Link to post Share on other sites