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!

-

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.

-
Sweet! Thank you for verifying! – Samuel Gregory Aug 26 '12 at 21:58
When you multiply by conjugate shouldnt it be -b? – Samuel Gregory Aug 26 '12 at 22:19
Also, I feel like there will still be error in how big the exponents will be since they can only go up to -50 and 50 by the problem statement – Samuel Gregory Aug 26 '12 at 22:31
@SamuelGregory: re the conjugate, you want to change the sign of one term or the other. I chose the $b$, not the square root. re the problem with exponents, you are right in that $b^2$ overflows before $b$ does. This approach does not solve that, and I don't know of one that does. You can certainly use a numeric technique that avoids squaring $b$. – Ross Millikan Aug 26 '12 at 23:22

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}}.$$

-