The problem: Given the equation $x^2−40x+1=0$, find its roots to five significant digits. Use $√399≐19.975$, correctly rounded to five digits.
Can anyone help me solve this problem?
My thoughts: Solution part1 Solution part2 I am stuck after this.
The problem: Given the equation $x^2−40x+1=0$, find its roots to five significant digits. Use $√399≐19.975$, correctly rounded to five digits.
Can anyone help me solve this problem?
My thoughts: Solution part1 Solution part2 I am stuck after this.
Copyright © 2021 JogjaFile Inc.
This is a problem with ill-conditioning, whereby the process of computation causes a loss of precision between inputs and outputs. Ill-conditioning takes various forms, but in the simplest version you subtract numbers that are nearly equal to each other and the result is less precise than the input. Digits that were significant in the inputs become leading zeroes in the difference, and lose their significance. See this question for more details.
Here, the roots are algebraically $20\pm\sqrt{399}$ and if we are given $\sqrt{399}\approx19.975$ we then compute
$20.000+19.975=39.975$
$\color{red}{20.0}00-\color{red}{19.9}75=\color{red}{00.0}25$
We have lost three significant digits for the smaller root and fail to get a precise rendering of the smaller root.
To beat the ill-conditioning, we render the root differently, using a form that's equivalent algebraically, but does not translate into an equivalent floating-point representation because it uses a different set of arithmetic operations. In plain English, with a difference involving square roots we may render
$a-b=(a^2-b^2)/(a+b)$
$20-\sqrt{399}=\dfrac{400-399}{20+\sqrt{399}}$
$=1/(20+\sqrt{399})$
and then use the well-conditioned sum for $20+\sqrt{399}$ to get the smaller root with the required full precision:
$1/(20+\sqrt{399})=1/39.975=\color{blue}{0.025016}.$
A check with a calculator shows that this is the correct floating five-digit representation of the smaller root.
Martial arts
I am not a martial artist, but I do know that a major objective of this discipline is to turn your opponent's strength to your advantage. Here, having identified an alternative expression for the smaller root, we note that since we know the two roots $20\pm\sqrt{399}$ add up to $40$ we may refine the larger root from $39.975$ to
$40-0.025016=39.974984$
(provided we can store the additional digits). Thus we have turned the original ill-conditioning around to gain precision in the larger root. This is, by another name, a convergent fixed-point iteration towards the true pair of roots.