[Math] Addition, subtraction, multiplication and division of irrational numbers, correct to $n$ decimal places

arithmeticirrational-numbers

Suppose we want to do one of the four basic arithmetic operations on two irrational numbers, and we want some confidence that our answer is correct to $n$ significant figures/decimal places. Doing this to $n$ siginificant figures seems much harder, since the two numbers may be of much different scales, and you might experience phenomena such as "catastrophic cancellation" for instance.

So suppose we try do $\pi + e$, correct to $5$ decimal places. If I take $\pi$ and $e$ both correct to $5$ decimal places, and try to add them with interval arithmetic, we see that $[3.14159, 3.14160] + [2.71828, 2.71829] = [5.85987, 5.85989]$; i.e. we only get an answer correct to $4$ decimal places. However, if we do the same calculation, using $\pi$ and $e$ with $6$ decimal places, we see that $[3.141592, 3.141593] + [2.718281, 2.718282] = [5.859873, 5.859875]$; i.e. we get an answer correct to $5$ decimal places.

As another example, take multiplication. If we take $\pi$ and $e$ correct to $6$ decimal places, and multiply them, we see that $[3.141592, 3.141593] * [2.718281, 2.718282] = [8.53972…, 8.53973…]$. So in this case, we only get something correct to $4$ decimal places. However, performing the calculation with $\pi, e$ correct to $7$ decimal places, we get the answer correct to $5$ decimal places: $[3.1415926, 3.1415927] * [2.7182818, 2.7182819] = [8.539733…, 8.539734…]$.

However, if one of our multiplicands is much larger than the other, we need more decimal places to get a similar level of precision. For instance, to get $50\pi * e$ correct to $5$ decimal places, we need $50\pi$ correct to $7$ decimal places and $e$ correct to $9$ decimal places.

From this, it is tempting to conjecture that if $a$ and $b$ are irrational numbers, and we want $a + b$ correct to $n$ decimal places, it suffices to use $a,b$ rounded to $n+1$ decimal places. Additionally, if we want $a*b$ correct to $n$ decimal places, it is also tempting to conjecture that it is sufficient to work with $a$ correct to $n+ 2 + \lfloor\log_{10}(b)\rfloor$ decimal places, and $b$ correct to $n + 2 + \lfloor\log_{10}(a)\rfloor$ decimal places.

Since subtraction and division can be rewritten as addition and multiplication respectively, it suffices to understand addition and multiplication. Does anyone have any insight into this? Can anyone see any way of proving the two conjectures above? That is, if they are indeed correct?

EDIT: As stewbasic has pointed out in the comments below, the above approach to addition does not work if the precision needed is less than the precision of one of the summands (in general terms). I have suggested a workaround in the comments below, but it seems to me that any proof of this suggested workaround would be quite involved.

Best Answer

HINT.-Let $x,y$ be irrational in $[0,1]$ with $$x=0.a_1a_2a_3.......a_na_{n+1}a_{n+2}.........\\y=0.b_1b_2b_3.......b_nb_{n+1}b_{n+2}.........$$ and consider the approximations $$x_n\approx 0.a_1a_2a_3.......a_n\\y_n\approx 0.b_1b_2b_3.......b_n$$ We can see that $x_n+y_n$ is correct to n decimal places if and only if $a_{n+1}+b_{n+1}\lt 10$ in which case the correct digit corresponding to the $n^{th}$ place is given by $a_n+b_n$ modulo $10$ but when $a_{n+1}+b_{n+1}\gt 10$ this correct digit would be $a_{n}+b_{n}+1$ modulo $10$.

Related Question