How to approximate $x^y$ using a quadratic function I need to build an algorithm that finds the approximately $x^y$ where $x = [0, 1]$ and $y = [0, 0.4)$.
This is for a computer algorithm (the standard library is too slow). I thought about making a lookup table but that would require a 2 dimensional table (since I have 2 variable). I would be ok with a lookup 1 dimensional lookup table.
Ideally the function would be most accurate at around x=1, y=0.16
 A: If there is an inbuilt exponential function, then you can use the following equation to approximate it in the given intervals:
$$x^y \approx \exp \left(y\frac{x-1}{6}\left(1+\frac{8}{1+x}+\frac{1}{x}\right)\right)$$
The inner term is an approximation to ln(x) using Simpson's Rule, which is quite accurate. You can use a lookup table or a taylor series or some approximation if the inbuilt exp is not fast enough.
The accuracy is quite good, see this graph: https://www.desmos.com/calculator/75cebv9qks .
The green and blue lines coincide so nicely that they are not even visible seperately.
Near 0.16, its not that accurate and you may use 2 or 3 terms of the Simpson's Rule.
A: The commenters are right that exp(ln(x) * y) is the most efficient way to do this. On the other hand I have an over-complicated way to do it below, which may be slightly faster because it uses a look-up table.
I'm not sure I exactly understand what you mean by quadratic function, at first I thought you meant the complexity had to be quadratic, but it sounds like you are asking legitimately for a polynomial. I think it should suffice to say that polynomials do not approximate exponential functions such as the above, because the ratio of an exponential function changes drastically, where a polynomial approaches a fixed number (The lead coefficient multiplied by the factorial of the degree, I believe...).
You could make a binary look up table as follows, and make it small enough steps to suit your accuracy with numbers in between.
$$ y = a_n \frac{1}{2^n} + a_{n-1} \frac{1}{2^{n-1}} + ... + a_1 \frac12 $$
$$ x^y = a_n x^{2^{-n}} * a_{n-1} x^{-2^{n-1}} * ... * x^{a_1} $$
Note the above formula is right associative. By pre-computing the values of $ x^{2^{n}} $, one can multiply them together depending on the value of y and it's binary form, and pre-compute for different values of x to the desired n-depth for accuracy.
Even I don't think that is the better answer, it may be slightly faster in a time sensitive situation.
