format_quote Originally Posted by
Periwinkle18
y isnt it 0??
sqrt : is square root
Actually, the calculator cannot calculate the exact value of sqrt(4) = 2, it instead calculates an approximative value of sqrt(4) = 1.99999.....99999 for example. ( pricesely he finds 2 - 8,1648465955514287168521180122928e-39),
Although the calculator displays 2 (because the number found is too close to 2), but it really stores in his memory "2 - 8,1648465955514287168521180122928e-39",
That's why when you substruct 2 from this result, you get "- 8,1648465955514287168521180122928e-39"
WARNING : DO NOT READ THE FOLLOWING, IF YOU HATE MATHS & PROGRAMMING.
Useless attempt to explain more:
The calculator makes approximative calculation of the non-arithmetic functions (sqrt(), sin(), cos(), log(), etc.)...
It does not have exact values, because electronic processors (those you find in calculators, computers, etc.) do not understand analytic mathematics (mathematical functions, derivation, integration), they only understand basic arithmetic operations (+, -, x, / ).
So in order to calculate no-arithmetic functions, the calculator will approximate/represent these functions with a "series" of simple arithmetic operations. It will calculate a sum of arithmetic expressions (terms) that will have a result too close to the real (ideal) result, with an acceptable precision.
To be honest, I don't really know what algorithm is used with the Calculator program. There's too many algorithms (methods) for every type of function. Algorithms vary according to it's precision and according to it's performance (calculation time).
For the sqrt() function, I still remember one example of algorithm : Héron d'Alexandrie
SQRT(N):
N is the number that we want to determine its square root.
r1: to be chosen.
// epsilon is the precision (the acceptable convergence difference)
While ( | rn+1 - rn | > epsilon ) Do // For n = 1, 2, 3, ....
rn+1 = (rn + N/ rn)/2
Loop
// Result :
SQRT(N) = rn+1 // (last term found) |
Now, forgive me for the very interesting mathematical explanation!
Please go on with this funny thread.