All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars    
perplexus dot info

Home > Just Math > Calculus
Function(Function()) Finding (Posted on 2005-02-02) Difficulty: 5 of 5
If f(x)=1-x, f(f(x))=x. Can you provide another such f(x), other than the obvious f(x)=x or f(x)=-x?

Can you find a real function g(x) such that g(g(x))=-x? Note that if we allowed complex numbers, g(x)=ix would do the job.

Can you find another real function h(x) so for x≠0, h(h(x))=1/x?

In all cases, if you cannot find a solution that works for all x, a function valid for some ranges is better than nothing!

See The Solution Submitted by Old Original Oskar!    
Rating: 3.1667 (6 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution solution (spoiler) | Comment 2 of 13 |

Part 1: f(x)=3-x, or generally, f(x)=a-x where a is a constant.

Part 2:
When g(x) is applied twice in succession, on one of those occasions it will have to reverse the sign and on another, not reverse the sign, so g(x) will sometimes have to result in an opposite sign from its argument, and at other times result in the same sign. This is true regardless of whether starting from positive or negative numbers.

Thus, a specific subset of the positive numbers must be set aside to result in negative numbers, and another subset to map to the first subset.  A similar scheme must be made out for the negative numbers.  Also the negative number subsets must work hand-in-hand with the positive subsets, so that the subset of positive numbers that maps to negative numbers must map to the subset of negative numbers that maps to other negative numbers.

Let's temporarily not worry about the endpoints of the intervals of numbers that make up the subsets, where the function will become discontinuous.  Let's arbitrarily take the interval from zero to 1 as that which will map to the interval 1 to 2, which will map to negative numbers, specifically zero to -1. The next available interval is 2 to 3; let it map to the interval from 3 to 4. That in turn will have to map into -2 to -3. Then continue on in this fashion.  It's best to make a graph of the function as we go along.

Now, if we map the interval 1 to 2 into zero to -1, it follows that zero to -1 must map into -1 to -2, to satisfy the requirements of the puzzle.  Likewise, if we map the interval 3 to 4 into -2 to -3, then -2 to -3 must map into -3 to -4, etc.

Now since zero to -1 maps into -1 to -2, the latter must map into zero to 1.  This is fine, as that in turn maps into 1 to 2--just what we want as it came from -1 to -2.  Similarly, the cycle -2 to -3, -3 to -4, 2 to 3, 3 to 4 checks out.

On a graph, this function looks like a pinwheel, with spokes broken into on and off segments of equal length.

We haven't yet considered the endpoints of the interval, glossing over the fact that the endpoints have been mentioned in two intervals each. Zero cannot map into a non-zero number because no non-zero number can ever map back into zero.  So zero has to map into zero; and this satisfies the requirements as it will stay zero into the next generation also.

So consider x=1. If it's considered part of 1 to 2 and maps into zero, it will be lost and never get to -1 nor ever get back to 1 in the 4-cycle. So make it part of the zero to 1 interval; that is, make it (0,1], a semi-closed interval. Then 1 maps into 2, then 2 into -1, then -1 into -2 and -2 into 1 to close the cycle.

So the integers should be considered as the end of each interval that is highest in absolute value:

... [-6,-5), [-4,-3), [-2,-1) map into -x - 1
... [-5,-4), [-3,-2), [-1,-0) map into x - 1
0 maps into 0
(0,1], (2,3], (4,5], ... map into x + 1
(1,2], (3,4], (5,6], ... map into 1 - x

the square bracket indicating that end is inclusive.

Part 3:

If we take the logarithm of the number, apply g and take the antilog of the result, we will get the desired result, as negating the logarithm is taking the reciprocal of the number.

However, negative numbers do not have real logarithms. So take the absolute value of the number before taking the logarithm; then, after g is applied and e raised to the power (the antilog taken), make the result the same sign as the original number, as the antilog will always be positive anyway, so the sign is available to encode the sign of the original number.

h(x) = sgn(x) * e^(g(ln(abs(x))))

Here's a program that tests these ideas:

DECLARE FUNCTION ceil! (x!)
DECLARE FUNCTION h! (x!)
DECLARE FUNCTION g! (x!)
RANDOMIZE TIMER
CLS
samples = 20
DIM rnum(samples)
FOR i = 1 TO samples
 r = RND(1) * 60 - 30
 rnum(i) = r
NEXT
DO
  flag = 0
  FOR i = 1 TO samples - 1
   IF rnum(i + 1) < rnum(i) THEN SWAP rnum(i), rnum(i + 1): flag = 1
  NEXT
LOOP UNTIL flag = 0
FOR i = 1 TO samples - 1
 g1 = g(rnum(i))
 g2 = g(g1)
 PRINT rnum(i), g1, g2
NEXT
FOR i = -3 TO 3
  PRINT i, g(i), g(g(i))
NEXT

PRINT

FOR i = 1 TO samples - 1
 h1 = h(rnum(i))
 h2 = h(h1)
 PRINT rnum(i); TAB(20); h1; TAB(40); h2; TAB(60); 1 / h2
NEXT

FUNCTION ceil (x)
  ceil = -INT(-x)
END FUNCTION

FUNCTION g (x)
  segment = ceil(ABS(x))
  IF segment MOD 2 = 1 THEN
   IF x > 0 THEN
    g = x + 1
   ELSE
    g = x - 1
   END IF
  ELSE
   IF x > 0 THEN
    g = 1 - x
   ELSEIF x < 0 THEN
    g = -x - 1
   ELSE
    g = 0
   END IF
  END IF
END FUNCTION

FUNCTION h (x)
  h = SGN(x) * EXP(g(LOG(ABS(x))))
END FUNCTION

Here's a sample output:
-28.02582     -29.02582      28.02582
-26.96076     -27.96076      26.96076
-15.64493      14.64493      15.64493
-15.43939      14.43939      15.43939
-12.68054     -13.68054      12.68054
-12.64378     -13.64378      12.64378
-10.49975     -11.49975      10.49975
-10.47616     -11.47616      10.47616
-10.00988     -11.00988      10.00988
-7.821289      6.821289      7.821289
-6.496117     -7.496117      6.496117
-5.013628      4.013628      5.013628
-3.297944      2.297944      3.297944
-2.685821     -3.685821      2.685821
 3.028032     -2.028032     -3.028032
 4.313746      5.313746     -4.313746
 5.371442     -4.371442     -5.371442
 9.06912      -8.06912      -9.06912
 23.25927     -22.25927     -23.25927
-3            -4             3
-2             1             2
-1            -2             1
 0             0             0
 1             2            -1
 2            -1            -2
 3             4            -3
-28.02582          -9.699205E-02       -3.568138E-02       -28.02582
-26.96076          -.1008236           -3.709094E-02       -26.96076
-15.64493          -42.52734           -6.391846E-02       -15.64493
-15.43939          -41.9686            -6.476942E-02       -15.43939
-12.68054          -34.46929           -7.886097E-02       -12.68054
-12.64378          -34.36936           -7.909027E-02       -12.64378
-10.49975          -28.54127           -9.524041E-02       -10.49975
-10.47616          -28.47716           -9.545482E-02       -10.47616
-10.00988          -27.20968           -9.990127E-02       -10.00988
-7.821289          -21.26047           -.1278562           -7.82129
-6.496117          -.4184472           -.1539381           -6.496117
-5.013628          -.5421786           -.1994563           -5.013628
-3.297944          -.8242353           -.3032192           -3.297944
-2.685821          -7.300818           -.3723256           -2.685821
 3.028032           .8977059            .3302476            3.028032
 4.313746           .6301441            .2318171            4.313746
 5.371442           .5060619            .1861698            5.371442
 9.06912            24.65242            .1102643            9.06912
 23.25927           .1168687            .0429936            23.25928


 
 The first section shows x, g(x) and g(g(x)), first for a set of random values sorted lowest to highest, and then for integers -3 to 3.  Both result in g(g(x)) being the negation of x.
 
 The last section shows x, h(x), h(h(x)) and 1/h(h(x)), showing the last column as being the same as the first.


  Posted by Charlie on 2005-02-02 19:38:43
Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (1)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (15)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2024 by Animus Pactum Consulting. All rights reserved. Privacy Information