# How calculators compute stuff (like irrational exponentiation)

I'm just curious as to how a calculator does the following operation:

##5^{1/\pi}##

I mean, it has to look for the number that raised to the power of pi, gives me 5. I think that's insane. How does it do that?

How does a calculator store the value of pi? -- I guess that's a more boring question because it might as well be it just "stores" it.

jedishrfu
Mentor
it could convert the expression to log form and convert the answer back.

log(5)/pi = log(ans)

Mark44
Mentor
How does a calculator store the value of pi? -- I guess that's a more boring question because it might as well be it just "stores" it.
A calculator stores an approximation to pi.

pwsnafu
Depends on your calculator, of course. We can use linear interpolation based methods if we want. Just repeat the operation to get within a needed precision. Let's demonstrate. We want to calculate ##5^{1/\pi}##. This is equivalent to finding the zero of
##f(x) = \log(x) - \pi^{-1} \log(5)##
We can assume that ##\pi^{-1}## is known, and also assume the logarithm function is cheap.
We need to test various points where the function changes sign. Suppose that ##f(s) < 0## and ##f(t) > 0## and s and t are near each other. Then
##x \approx \frac{sf(t)-tf(s)}{t-s}##.
Repeat until you get your desired precision.

There are faster techniques for trig functions, exponentials and logarithms (such as CORDIC and BKM). But these are for when you are working on a computer without hardware acceleration (very unlikely these days)

HallsofIvy