22
3
The challenge
Quite simple, given an input x
, calculate it's infinite power tower!
x^x^x^x^x^x...
For you math-lovers out there, this is x
's infinite tetration.
Keep in mind the following:
x^x^x^x^x^x... = x^(x^(x^(x^(x...)))) != (((((x)^x)^x)^x)^x...)
Surprised we haven't had a "simple" math challenge involving this!*
Assumptions
x
will always converge.- Negative and complex numbers should be able to be handled
- This is code-golf, so lowest bytes wins!
- Your answers should be correct to at least 5 decimal places
Examples
Input >> Output
1.4 >> 1.8866633062463325
1.414 >> 1.9980364085457847
[Square root of 2] >> 2
-1 >> -1
i >> 0.4382829367270323 + 0.3605924718713857i
1 >> 1
0.5 >> 0.641185744504986
0.333... >> 0.5478086216540975
1 + i >> 0.6410264788204891 + 0.5236284612571633i
-i >> 0.4382829367270323 -0.3605924718713857i
[4th root of 2] >> 1.239627729522762
*(Other than a more complicated challenge here)
1I don’t think this tower converges at x = −2 or x = −0.5. – Anders Kaseorg – 2017-07-25T07:37:05.427
@AndersKaseorg I agree, though all programs seem to have the same converging answer. Why don't they converge? – Graviton – 2017-07-25T07:38:16.797
2x = −2 gets attracted to a 8-cycle and x = −0.5 gets attracted to a 6-cycle. (My program still gives an answer in these cases, but it’s one of the points in the cycle and not a fixed point; this doesn’t indicate convergence.) – Anders Kaseorg – 2017-07-25T07:44:03.600
@AndersKaseorg Aha very interesting. You wouldn't happen to know why '8' for -2 and '6' for -0.5? Just out of curiosity of course. – Graviton – 2017-07-25T07:47:20.267
2
You can run the iterations just as easily as I can, but here’s a picture: https://commons.wikimedia.org/wiki/File:Tetration_period.png
– Anders Kaseorg – 2017-07-25T07:50:51.727You say we have to calculate the infinite power tower, but do we have to display/output it? – kamoroso94 – 2017-07-25T14:01:22.030
@kamoroso94 Yes and no. A lot of answers just have a function that generates a number, but can be outputted quite easily (usually shown in the 'Try It Online'). It really depends if it's faster to print it or to return it as a function. – Graviton – 2017-07-25T22:14:12.307