There do exists so-called hyperoperation sequence. It works like you construct multiplication a*b=a+a+a+a...+a
with many additions of a
repeated b
times. Then there goes exponentiation a^b = a*a*a*a*...*a
with many multiplicaitions of a
repeated b
times. Then, there goes tetration, expressed as a tower of exponentiations, same like a^^b == a^a^a^...^a
, repeated b
times.
I am interested how to write this function, for floating point and complex numbers?
I've alredy wrote multiplication and exponentiation functions, in glsl:
// complex multiplication:
vec2 cmul(in vec2 a, in vec2 b) {
return vec2(a.x*b.x-a.y*b.y, a.x*b.y+a.y*b.x);
}
// complex exponent e^a
vec2 cexp(in vec2 a) {
float ea = exp(a.x);
float vl = a.y;
return ea * vec2( cos(vl), sin(vl) );
}
// complex natural logarithm ln(a)
vec2 cln(in vec2 a) {
float ql = length(a);
return vec2( log(ql), atan(a.y, a.x));
}
// complex power function a^b
vec2 cpow(in vec2 a, in vec2 b) {
return cexp(cmul(cln(a), b));
}
But then I'm stuck! How can we write ctet(in vec2 a, in vec2 b)
tetration function, not only for floating point numbers, but for whole complex plane itself?
well lets start with Real domain and integer
b
only:this can be evaluated like this in C++:
as You already got the
pow
for complex domain you can do the same there too... To keep this simple I will not touch that for now ...Here some results:
btw. all of these hyper operations are related to Ackermann function you can find iterative implementation of mine in C++ in here:
However due to extremly fast growth even
double
will out of range soon (hence missing values)...Now how to move the
b
to Real domain? Have not a clue about algebraic approach for this but geometric one is possible.Simply "plot"
a^^b
as a function of variableb
and constanta
for integer values ofb
around your wanted realb
and then interpolate Real domainb
using Integer domainb
as control points. Its similar to obtaining non integer order derivation of a function.So
(X,Y)
will be your(a^^b,b)
. Now use any interpolation to construct Real domain function.Linear interpolation will look like this:
However higher order interpolation is needed and also the interpolation parameter should be scaled to non linear metrics. For more info see:
After some elaboration cubics (
t^3
) andlog^2
scale proved to be sufficient (C++ example using my 128 bit floating pointf128
class just rename it todouble
):This is what I compared it with:
I select the same graph bases
a
froma^^b
and as you can see its a very good match only range below 1.0 is slightly off.Lets go for the Complex domain fractal
Now when you want to go to complex domain you can not do the same as in Real because the results are too chaotic for interpolation. So we can only stick to integer
b
or use the Kneser algorithm to compute.Luckily for us there are more ways on show the fractal... For example we can evaluate integer
b
from thea^^b
where only thea
is complex and use the result for coloring the output. Here GLSL example (based on mine Mandelbrot shader and your complex math):Fragment:
And tetration preview:
This is what I compared with:
and it matches my result is just mirrored in both
x,y
So what I did was computing
a^^100
wherea
is complex domain position of fragment on screen<-1,+1>
with somepanning
andzooming
and render the color constructed from the result ...I leave there also a test function (not fractal) I used to test the coloring methods and complex math taken from here the first is from Wiki the second is shader result (color wheel):
You can do escape testing like for mandelbrot or whatever else algo to show the fractal instead.
Here coloring options screenshots of tetration (I like the grayscale) of
zoom=500.0 pos=-0.188418+0.234466i
And finally pentation: