Quadratic Equation Error

9.2k Views Asked by At

For the floating point system $(B, t, L, U) = (10,8,-50,50)$ and for the quadratic equation:

$ax^2 + bx + c$, I need to show error that arises in various cases and how to fix those.

$$a=10^{-30}$$ $$b= -10^{30}$$ $$c=10^{30}$$

I think there is cancellation error when plugging into quadratic formula. Can anyone help me verify that if multiply quadratic formula by conjugate, then I'll get $\frac{2c}{-b \pm \sqrt{b^2-4ac}}$ which will take away the error for the case that is subject to error?

Thanks!

2

There are 2 best solutions below

5
On BEST ANSWER

The basic idea is that if |$4ac| \ll b^2$, the square root is very close to $|b|$. Depending on the sign of $b$, one combination or the other will involve subtracting two nearly equal quantities.

To be specific, let us assume $b \gt 0$. Then one root is $\frac {-b+\sqrt{b^2-4ac}}{2a}$ and is the one subject to cancellation. If we multiply by the congugate:$$\frac {-b+\sqrt{b^2-4ac}}{2a}\frac {b+\sqrt{b^2-4ac}}{b+\sqrt{b^2-4ac}}=\frac{b^2-4ac-b^2}{2ab+2a\sqrt{b^2-4ac}}=\frac{-2c}{b+\sqrt{b^2-4ac}}$$ and the cancellation has disappeared. The case $b \lt 0$ is similar except you worry about the one with the minus sign.

0
On

OK, just for fun, let's try a different method: $$ ax^2 + bx + c = 0 $$ $$ a + b\frac 1 x + c\frac{1}{x^2} = 0 $$ $$ a + bu + cu^2 = 0 $$ So $u=1/x$, and now we have a quadratic equation in $u$. Solve that by the usual formula (but we've interchanged the customary roles of $a$ and $c$, so do that in the formula as well): $$ u = \frac{-b\pm\sqrt{b^2 - 4ca}}{2c}. $$ $$ x = \frac{2c}{-b\pm\sqrt{b^2-4ca}}. $$