[Math] Calculating powers

exponentiationnumerical methods

I was thinking how I could program powers into my application. And I want to do this without using the default math libraries. I want to use only +,-,* and /. So I wondered what is the definition of a power. I came across this definition of $a^{b}$:

$$
a^b = e^{b \ln a} = \sum_{n=0}^\infty \frac{(b \ln a)^n}{n!}
$$

The thing here, is that to calculate a power, you'd have to use a power. This seems kind of odd to me because that would make it impossible to program a power. So is there a way to calculate a power without using a power?

It's not as simple as $x*x*x$ since I want to calculate powers like $2^{-3,29032}$.

EDIT:
I just finished to code, calculating it the long way and I came across the infamous x^0. What should I do now, just put in 1?

Best Answer

Given any $\alpha\in{\mathbb C}$ one has the binomial series, giving the value of $$(1+x)^\alpha:=\exp\bigl(\alpha\log(1+x)\bigr)$$ without taking recourse to any tables: $$(1+x)^\alpha=\sum_{k=0}^\infty {\alpha\choose k}\>x^k\qquad(-1<x<1)\ .$$ Here $${\alpha\choose k}:={\alpha(\alpha-1)\cdots(\alpha-k+1)\over k!}$$ is a generalized binomial coefficient.

If you want $y^\alpha$ for a given $y>0$ let $x:=1-y$ when $y<1$, and let $x:=-{y-1\over y}$ when $y>1$, then take the reciprocal of the result.

Related Question