1
$\begingroup$

I was using my calculator (TI-83 Plus) to do some calculations involving complex and imaginary numbers, and I found in two cases that something weird will happen in the following scenario:

I did $log(-1)$ which gave some decimal along with i (my calculator was in a+bi mode). I stored that in a variable $D$, and did $10^D$, which should return just $-1$, as $log(-1)=x$ is the same as $10^x=-1$. However, it gave me back a complex number with a really small negative part. $-1+2\cdot 10^{-13}i$ (the calculator just said $-1+2e-13i$, so I'm not sure if it means $2\cdot 10^{-13}i$ or $2\cdot 10^{-13}i$, I think it is the latter) Why does it do that?

It happened in a different scenario for me a long time ago, but I don't quite remember what it was.

Edit: I remember the second scenario, and this one I don't know why it does this: i did $(-2-2i)^2$ and it said the answer is $8\cdot10^{-13}+8i$. It doesn't happen when I change the sign of the first 2, but not the second. With $log(-1)$, it's probably because it's irrational, but with this scenario, I'm not really dealing with any irrational numbers.

$\endgroup$
  • $\begingroup$ Your calculator stores numbers in floating points, which has a precision limit. $\endgroup$ – Henricus V. Jan 2 '17 at 20:44
  • $\begingroup$ Rational vs Irrational is not the issue for numeric imprecision in calculators. Most rational numbers cannot be represented exactly and will be approximated. This can lead to the type of accuracy issues seen here. It is a large topic in numerical analysis, where many techniques are developed to minimize the effect of the problem. $\endgroup$ – Ross Millikan Jan 3 '17 at 4:44
2
$\begingroup$

If you compute $1/3$ and store it in $Q$, and then compute $3*Q$, you'll find that you don't get 1 -- there's a tiny numerical imprecision, related to the fact that calculators use binary, in which $1/3$ is not representable in a finite number of bits(just as it is not in decimal, where it cannot be represented with a finite number of decimal digits: you have to write $.33333\ldots$).

The same is true for $\log -1$: it can't be represented exactly in binary. So when you exponentiate it, you get something very near $-1$; the error in this case happens to be in the imaginary component rather than the real part, but it's the same phenomenon.

By the way, 1+2e-13i means $-1 + 2 \times 10^{-13} \Bbb {i}$.

$\endgroup$
  • $\begingroup$ Thanks, but wouldn't it be true regardless of whether calculators use binary (as $log(-1)$ is irrational in binary as well as decimal)? $\endgroup$ – mdlp0716 Jan 2 '17 at 20:14
  • $\begingroup$ Yes; the key thing is that it's irrational in the number system used by the calculator. It's possible (but unlikely) to have a base-3 calculator in which $1/3$ is exactly represented. In the same way (but even more unlikely!), your calc. could have a special representation for $\log -1$, so that exponentiating it would give the exact correct answer. But since it's (probably) binary, it does not. $\endgroup$ – John Hughes Jan 2 '17 at 21:44
  • $\begingroup$ is there any number system where $log(-1)$ is rational? $\endgroup$ – mdlp0716 Jan 2 '17 at 21:54
  • $\begingroup$ Almost certainly not. But niether is $\sqrt{n}$ for non-square integers $n$, but we can represent surds by 4-tuples $(a,b,n,c)$ of integers representing $\frac{a + b \sqrt{n}}{c}$, and then multiply and divide them and easily see that $\sqrt{2}^2$ is in fact rational (indeed, an integer) and print its value exactly. So it's imaginable (but unlikely) that one might say "in this 64-bit representation, we use 63 bits to do 2s-complement arithmetic, but reserve the number 1000 ... 000 to represent $\log(-1)$, and special-case our exponentation so that $10$ to that power is $-1$. $\endgroup$ – John Hughes Jan 2 '17 at 22:51
0
$\begingroup$

Calculators are purely computational in their approach to problems, so when you ask it to compute a logarithm for example, they will use numerical approaches. When the answers are not finite, they essentially store a very good estimate with a small error.

However, calculators don't 'know' the theory of logs etc and so when you ask it to find $10^D$ it simply returns the stored binary representation of the numeric value of $10^D$.

Calculators can't store an infinite number of digits

$\endgroup$
  • $\begingroup$ Thanks! I feel stupid now because I have no idea how it never once crossed my mind that when log(-1) returned a bunch of decimals, it was probably something irrational! $\endgroup$ – mdlp0716 Jan 2 '17 at 20:08
  • $\begingroup$ Can you look at the second part I added to the question? $\endgroup$ – mdlp0716 Jan 3 '17 at 3:48
  • $\begingroup$ Sure - it's a similar issue as mentioned in a couple of other comments. Calculators tend to store values as floating points and in this system most rationals can't be input exactly. So there will be a very small error that your calculator stores for the value of $ -2 - 2i$. I can't profess to be an expert in exactly how it works, but I'd imagine that if the error doesn't occur when changing one of the signs then the calculator can approximate the number so well (perhaps even exactly) that the error is of an order that the calculator can't work with so 'sets' to $0$ $\endgroup$ – TheMathsGeek Jan 3 '17 at 12:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.