My book has the following problem (which is part of our ungraded homework in numerical analysis):
Assume that you are solving the quadratic equation $ax^2 + bx + c = 0$, with $a = 1.22$, $b = 3.34$, $c = 2.28$, using a normalized floating-point system with $\beta = 10$, $p = 3$.
(a) What is the computed value of the discriminant $b^2 - 4ac$?
(b) What is the correct value of the discriminant in real (exact) arithmetic?
(c) What's the relative error in the computed value of the discriminant?
Below are my solutions and questions:
Part (a)
This is the one where I sort of doubted myself because I wasn't sure if I should round at each step or only at the end. A human would presumably round at the very end to avoid piling up a bunch of rounding errors, but I imagine a computer does not have that luxury because the problem tells us that we are limited to $3$ digits of precision, so there's no way a computer could temporarily "hold on" to a more precise answer and only round at the end... right? That's my line of thinking, at least. For this reason, I chose to round at each step. Please let me know if that is not correct:
$b^2 - 4ac = 3.34^2 - 4(1.22)(2.28) = 11.2 - 4(2.78) = 11.2 - 11.1 = 0.1$
Part (b)
I think this one's straightforward, but it's worth checking anyway. I got $0.0292$.
Part (c)
Here, I get that the relative error is $\frac{0.1 - 0.0292}{0.0292} = 200 \% $