Why is in Matlab exp(pi * sqrt(163)/3) - 640320 = -2.3283e-10

90 Views Asked by At

Why is in Matlab

$$ e^{\pi\cdot\frac{\sqrt{163}}{3}} - 640320 = -2.3283 * 10^{-10} $$

exp(pi * sqrt(163)/3) - 640320
ans =-2.3283e-10 

I know that it does have something to do with IEEE754, but I can't figure exactly out why.

exp(pi*sqrt(163)/3) = 640320, 

so the result should be 0.

Can anyone explain?

1

There are 1 best solutions below

1
On BEST ANSWER

First, that expression is not an integer, but very close to an integer $640320$. In fact, as @Peter mentioned, this is related to some deep theory of modular $j$-functions and Heegner numbers, e.g. see Wikipedia and this MSE question. Anyway, the main reason is that we have

$$ e^{\pi \sqrt{163}} \approx 640320^3 + 744 $$

with an error $< 10^{-12}$, so

$$ e^{\frac{\pi\sqrt{163}}{3}} \approx (640320^3 + 744)^{1/3} = 640320 \cdot \left(1 + \frac{744}{640320^3}\right)^{1/3} \approx 644320 $$

where the last approximation is due to

$$ \left(1 + \frac{744}{640320^3}\right)^{1/3} \approx (1 + 3 \cdot 10^{-15})^{1/3} \approx 1 + 10^{-15}. $$