# Thread: Numerical Methods - Error propagation and avoiding cancellation

1. ## Numerical Methods - Error propagation and avoiding cancellation

Simplify (x+sqrt(y))(x-sqrt(y)) & use result to derive a method for avoiding cancellation when solving quadratic equations.

So (x+sqrt(y))(x-sqrt(y)) simplified is x²-y but where do I go from there?

2. ## Re: Numerical Methods - Error propagation and avoiding cancellation

Originally Posted by CourtneyMoon
Simplify (x+sqrt(y))(x-sqrt(y)) & use result to derive a method for avoiding cancellation when solving quadratic equations.

So (x+sqrt(y))(x-sqrt(y)) simplified is x²-y but where do I go from there?
When you use the quadratic formula the roots are:

$x_1=\frac{-b+\sqrt{b^2-4ac}}{2a}$

$x_2=\frac{-b-\sqrt{b^2-4ac}}{2a}$

if $4ac \ll b^2$ one of these calculations will result in the subtraction of two nearly equal numbers leading to a loss of precision. This can be avoided by using the simplification you quote, since:

$4a^2 x_1 x_2=b^2-(b^2-4ac)=4ac$

so ....

CB