4

I have a phone with an inbuilt calculator. I love to play with calculators. So I did the following and the following was shown by the calculator.

When I went in the scientific tab and wrote $\pi$ it returned $3.1415926535$.

When I wrote $\pi \times 2^{32}$, it wrote $1.34930377\times10^{10}$, which basically is $1349303770$.

Now when I wrote $\frac{1349303770}{\pi\times{2^{32}}}$, it gave me $0.99999966483$.

My question is, can we predict what will my calculator give me when I write $\sqrt3 \times {2^{31}}$? Or when I write anything, can I predict what the calculator will display?

Also, what is the best method to say if a calculator is accurate or not?

According to me, first we must assume that the calculator is taking the values it is showing. Like, it should not be taking values of $\pi$ more accurate or less accurate. Secondly, I think the error must be coming due to the range of values it must be taking. But is there any logical method to determine the range of values a calculator takes?

Rohinb97
  • 1,702
  • $\pi\cdot 2^{32}$ is closer to $13493037704.5$. If you run that division, you get a bit more nines. – Arthur Aug 30 '13 at 07:31

1 Answers1

9

The precision of a calculator is largely influenced by the number of significant figures used for computation. It is normally greater than the number of digits displayed.

For example, if you compute $\pi$ and it displays $3.141592654$, the actual number stored in its RAM might be $3.14159265\color{blue}{359}$, where the digits in $\color{blue}{\text{blue}}$ denotes the extra figures which are not displayed.

That's the reason why you do not get $1$ from $1349303770/(2^{32} \pi)$: $1349303770$ was the displayed number which you read off from previous result, while the calculator used slightly more significant figures to compute $2^{32}\pi$.

There is an indirect way to count the total no. of significant figures used for computation:

  1. Compute $\sqrt{2}$
  2. Subtract $1$ from previous result (do not compute $\sqrt{2} - 1$ directly: you must make use of the previous result)
  3. Compute $1/\text{Previous result}$. This can be tricky because the method to do this depends on the type of calculator. Again, do not type the previous answer manually.
  4. Subtract $2$ from previous answer
  5. Repeat Steps 3-4, until you notice a discrepancy between the fractional part of the result from Step 3 and that from Step 1
  6. The approximate number of extra significant figures would be the total number of subtractions you have made before you notice a discrepancy
  7. The total number of significant figures is then $$N = \text{no. of digits displayed} + \text{no. of extra significant figures}$$

Once this is known, you can sort of predict the result of computation by using a more precise calculator, and round off the result to $N$ figures. You might need an advanced calculator for this, such as PARI/GP.

Using my scientific calculator, these are the results:

  1. $1.414213562$ (Step 1)
  2. $0.414213562$ (Step 2)
  3. $2.414213562$ (Step 3)
  4. $0.414213562$ (Step 4)
  5. $2.414213562$ (Step 3)
  6. $0.414213562$ (Step 4)
  7. $2.41421356\color{red}{3}$ (Step 3)
  8. $0.41421356\color{red}{3}$ (Step 4)
  9. $2.4142135\color{red}{59}$ (Step 3)

Hence the approximate number of extra significant figures would be $3$ or $4$.

Why this method works: each subtraction causes catastrophic cancellation.

fluorine
  • 451
  • Thanks. Interesting answer. +1 – bubba Aug 30 '13 at 09:13
  • Nice answer!(+1) – Rohinb97 Aug 30 '13 at 17:45
  • But you did not tell about my calculator. Imagine I have the most accurate calculator. I perform my calculation above and get my answer. I also(somehow) know it's error so I can know my exact answer. Now from here how can I exactly know what the calculator would display? How can I $calculate$ the exact error my calculator gives? – Rohinb97 Aug 30 '13 at 17:52
  • Well I thought I have addressed that in the paragraph before the results of my calculator. Perhaps I didn't quite understand your question. Do you mean you want to predict what the calculator would display if you input $\sqrt{3} 2^31$? For instance my calculator would display $3719550787$, and is this what you want to predict? Or do you want to predict the result of $3719550787 / (\sqrt{3} 2^31)$ which might be $0.9999999$? – fluorine Aug 31 '13 at 15:51
  • Actually, both. You see, my question is how can I exactly calculate what results will I get (or how much it would be different from the actual result, and suppose I know it). I just would like to know mainly the former, that's it. – Rohinb97 Sep 04 '13 at 12:23