First for the integer powers you can do much better than n multiplications to evaluate x**n.
For the fractional exponent I would reach for my copy of the "Handbook of Mathematical Functions" edited by Abramowitz and Stegun. This provides polynomial approximations for ln(1+x) where 0<=x<=1, accurate to 1e-5, 3e-8 or better than 1e-9. Another set of functions are provided for exp.
Pick a set of suitable polynomials for the required accuracy, add the code to reduce the values to the appropriate range(s) and you are done. |