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?
If you only want to do integer powers, you may use iterated multiplication ($x^3 = x * x * x$), and for negative powers $x^{-n}$, you may calculate $x^n$, then take the reciprocal $$\frac{1}{x^n}= x^{-n}$$This should be much easier than programming natural logarithms or infinite sums.
As an added bonus, you could use a little more memory and save some computation time by finding the powers $x, x^2, x^4, \ldots, x^{\log_2(n)}$, then use these as your building blocks to achieve exponentiation in $O(\log_2(n))$ time as opposed to $O(n)$.