# Calculating Non-Integer Exponent

I just wanted to directly calculate the value of the number $2^{3.1}$ as I was wondering how a computer would do it. I've done some higher mathematics, but I'm very unsure of what I would do to solve this algorithmically, without a simple trial and error.

I noted that

$$2^{3.1} = 2^{3} \times 2^{0.1}$$

So I've simplified the problem to an "integer part" (which is easy enough) : $2^3 = 2\times 2\times 2$, but I'm still very confused about the "decimal part". I also know that :

$$2^{0.1} = e^{2\log{0.1}}$$

But that still presents a similar problem, because you'd need to calculate another non-integer exponent for the natural exponential. As far as I can see, the only way to do this is to let:

$$2^{0.1}=a$$

And then trial and error with some brute force approach (adjusting my guess for a as I go). Even Newton's method didn't seem to give me anything meaningful. Does anybody have any idea how we could calculate this with some working algorithm?

-
And by a simple trial and error, I mean: how would I solve this without just using a calculator to refine to more and more decimal places. –  user2662833 Aug 8 at 2:56
In short, you'll have to use a calculator for the general case--computing numeric results for $\log x$ involves either infinite series or numeric integration. (By general case, I mean that there will be exceptions, like $4^{3.5} = 8$ is easy to do without a calculator, but you can't do that in general). –  anorton Aug 8 at 2:58
$2^{0.1} = e^{0.1\log 2}$ - you got the $2$ and $0.1$ backwards. –  Thomas Andrews Aug 8 at 3:16
Yes, you're right. I did get that backwards. That was a mistake I'm afraid :( However, I'm thinking of it from a more algorithmic standpoint. How does a calculator actually calculate a logarithm? –  user2662833 Aug 8 at 12:55

$$2^{3.2} = 2^3 2^{0.1} = 2^3 e^{0.1 \log{2}}$$

Now use a Taylor expansion, so that the above is approximately

$$2^3 \left [1+0.1 \log{2} + \frac{1}{2!} (0.1 \log{2})^2 + \frac{1}{3!} (0.1 \log{2})^3+\cdots + \frac{1}{n!} (0.1 \log{2})^n\right ]$$

wheer $n$ depends on the tolerance you require. In this case, if this error tolerance is $\epsilon$, then we want

$$\frac{1}{(n+1)!} (0.1 \log{2})^{n+1} \lt \epsilon$$

For example, if $\epsilon=5 \cdot 10^{-7}$, then $n=4$.

-
Tis a very good idea. That was actually how I solved this :) I just wrote a Small java program to do it using nothing but basic arithmetic. I'd be happy to post it if any body is interested –  user2662833 Aug 10 at 15:26