In the Problem 5 of Homework #1, for the given coefficients a= 1,b=−1e5 and c= 1, the root formula gives two real roots
r1= (−b−√∆)/(2a) = 1.0000003385357559e−05,
r2= (−b+√∆)/(2a) = 9.9999999989999997e+ 04
If we plug these two roots back into the quadratic function, we obtain
f(r1) =−3.3844e−07,
f(r2) = 0
We see that root r1 is not correct up to the round-off error.
(a) Explain what the problem is with the formula for evaluatingr1numerically?
(b) Come up with a way to fix it. Modify your code and recalculate the roots for a= 1,b=−1e5 and c= 1.
Check your result by plugging the root back to the quadratic polynomial.
Get Answers For Free
Most questions answered within 1 hours.