3

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 \% $

2 Answers2

1

1) Unless you render the discriminant as $b^2-4(ac)$ with parentheses directing the order of multiplication in the second term, multiply from left to right. Thus

$4×1.22=4.88$

and then

$4.88×2.28=11.1$.

Here the estimated product is not affected by the order of mutiplication but in other cases it could be.

2) The expression

$(0.1-0.0292)/0.0292$

is correct for the relative error. Use the known correct value in the denominator. However, I calculate $242$% instead of $200$%.

Oscar Lanzi
  • 48,208
0

Concerning the last part, at least to me, as a physicist, comparing so different numbers to produce a relative error is quite dangerous.

I would prefer to use $$\frac {0.1-0.0292}{\frac {0.1+0.0292}2}\to 110\text{ %}$$

Otherwise, why not to use $$\frac {0.1-0.0292}{0.1} \to 78\text{ %}$$

  • 1
    Usually when comparing two quantities by percentage error and one is known to be correct, the known correct quantity is used in the denominator. – Oscar Lanzi Sep 09 '19 at 09:51
  • @OscarLanzi. For sure, I agree with you but, as I wrote, I am a physicist. You have the same problem with discounts on sales ! Cheers :-) – Claude Leibovici Sep 09 '19 at 10:04