Tetration is the level above exponentiation (e.g: 2^^4 = 2^(2^(2^2)) = 65536.
So far, I've figured out an algorithm for tetration that works.
However, although the variable a
can be floating or integer, unfortunately, the variable b
must be an integer number.
How can I modify the pseudo-code algorithm so that both a
and b
can be floating point numbers and the correct answer will be produced?
// Hyperoperation type 4:
public float tetrate(float a, float b)
{
float total = a;
for (i = 1; i < b; i++) total = pow(a, total);
return total;
}
In an attempt to solve this, I've created my own custom power() function (trying to avoid roots, and log functions), and then successfully generalized it to multiplication. Unfortunately, when I then try to generalize to tetration, numbers go pear shaped.
I would like an algorithm to be precise up to x amount of decimal places, and not an approximation as Wikipedia talks about. To clarify, preferably, it would need to satisfy at least the first three requirements, and the fourth requirement can be up to the answerer.