I reverse engineered the windows calculator to find out why.
Turns out it's not a floating point error. The Windows calculator doesn't use floating point arithmetic. All calculations are done using integers. Internally the windows calculator represents all numbers as the quotient of two large integers. The location of the decimal point is saved separately.
The reason is because the Windows calculator calculates the square root of x using the formula:
`sqrt(x) = e^(1/2ln(x))`
For `x = 4` this gives:
`sqrt(4) = e^(1/2ln(4))`
Windows calculator calculates this as follows:
`ln(4)` | = | 805201261062806329606334447576254429992 | |
580829933126425138424282211438883083918 | |||
= | 1.3862943611198906188344642429163531361279871390484758676443363274643102982817382328871562524970367 | ||
`1/2ln(4)` | = | 805201261062806329606334447576254429992 | |
1161659866252850276848564422877766167836 | |||
= | 0.69314718055994530941723212145817656806399356952423793382216816373215514914086911644357812624851835 | ||
`e^(1/2ln(4))` | = | 55604229018504692596833125437922908794411 | |
27802114509252346298416562718961454397319 | |||
= | 1.9999999999999999999999999999999999999918351534044485712831478819877072178025271926847001408869710567 | ||
`e^(1/2ln(4))-2` | = | 227 | |
27802114509252346298416562718961454397319 | |||
= | 0.0000000000000000000000000000000000000081648465955514287168521180122927821974728073152998591130289432 | ||
Hence... | |||
`sqrt(4) - 2` | = | 8.1648465955514287168521180122927821974728073152998591130289432e-39 |
It's actually a tollerance error. The actual result is:
`sqrt(4) = 1.9999999999999999999999999999999999999918351534044485712831478819877072178025271926847001408869710567 ± 1e-38`
Hence...
`sqrt(4) - 2 = 8.1648465955514287168521180122927821974728073152998591130289432e-39 ± 1e-38`
Derivation of `sqrt(x)=e^(1/2ln(x))`
`x = e^ln(x)`
`x^(1/2) = e^ln(x^(1/2))`
`x^(1/2) = e^((1/2)ln(x))`
Back to Math Topics Index |