3
$\begingroup$

Possible Duplicate:
How can I calculate non-integer exponents?

What is the most efficient way to estimate $a^b$ ($a > 0$) numerically?
My goal is not to use built-in math functions (like $e^x$ or $\log x$), i.e. only using +-*/.

I successfully accomplished this task by estimating $e^x$ and $\log x$ (below), because $a^b=e^{b\log a}$.

What I have done so far is estimated $e^x$ using the Taylor's series expansion:

$e^x=\sum_{k=0}^{\infty}\frac{x^k}{k!}$

$x^k$ can be found simply by multiplying $1$ by $x$ by $k$ times (because $k$ is an integer).

I then proceeded to estimate $\log$:

$\log (z) = 2\operatorname{artanh}\,\frac{z-1}{z+1} = 2\sum_{n=0}^\infty\frac{1}{2n+1}\left(\frac{z-1}{z+1}\right)^{2n+1}$

Putting these estimations together: $a^b=e^{b\log a}$, giving us an estimate that we can make to whatever accuracy is needed.

This method works to estimate exponents, but are there better and more efficient ways of doing this?

  • 0
    What part of it seems difficult for you? If you could say what you're going for, I can repurpose some of the things there as an answer here.2012-04-20

0 Answers 0