The other day I was looking at a string of calculations which were supposed to come out to zero. Instead, the conclusion of these calculations was written as:
Realizing that not only must this be wrong, but severely wrong, I plug it into a calculator just to make sure. The results are:
1. Via google.com: 0.
2. Via wolframalpha.com: -5.551115123125783×10-17 is the answer given while typing it in, though after hitting “enter”, we get 0, but we also get a whole bunch of series expansions and continued fractions, which is odd.
3. Via MATLAB: -5.551115123125783e-17
4. Via Python: -5.5511151231257827e-17, which is just one extra digit on wolfram and MATLAB’s output.
First, the right answer is in fact 0. Remember that arctan(x) takes the ratio of the opposite and adjacent sides of a right triangle (remember, side-angle-side completely determines a triangle), and returns the angle of the triangle, in radians. Then it follows that since a triangle has pi radians total, and the right angle uses up pi/2 of those radians, we have the following identity for all nonzero x:
It follows, then, that
though this is one of the most… interesting ways I have ever seen the number 0 written.
Tomorrow: more on why the calculators were wrong, and a rough discussion of exactly how computers calculate with floating point numbers.