Consider the quantitya^{2} - b^{2} where a and b are real numbers. (a) Under what conditions should one expect an unusually large relative error in th

Globokim8

Globokim8

Answered question

2020-10-20

Consider the quantitya2  b2 where a and b are real numbers.
(a) Under what conditions should one expect an unusually large relative error in the computed value of a2  b2 when this expression is evaluated in finite precision arithmetic?
(b)cWs 4-digit (decimal) rounding arithmetic to evaluate both a2  b2 and (a + b)(a  b) with a =995.1 and b=995.0. Calculate th relative error in each result.
(c) The expression (a + b)(a  b) is algebraically equivalent to a2  b2, but it is a more accurate way to calculate this quantity if both a and b have exact floating point representations. Why?

Answer & Explanation

Arnold Odonnell

Arnold Odonnell

Skilled2020-10-21Added 109 answers

Solution:
a.The condition is that the computed value is rounded off when this expression is evaluated in finite precision arithmetic.
b.Given: a=995.1 and b=995.0
a2  b2=(995.1)2  (995.0)2
=990224.01  990025
=199.01
4 digit rounding arithmetic we have a2  b2=199.0.
The relative error becomes |199.01  199.0|199.01=0.01199.010.525 × 104
Conclusion:
Given: a=995.1 and b=995.0
(a + b)(a  b)=(995.1 + 995.0)(995.1  995.0)
=(199.01)(0.1)
4 digit rounding arithmetic we have (a + b)(a  b)=199.0.
The relative error becomes |199.01  199.0|199.01=0.01199.010.525 × 104
c.The expression (a + b)(a  b) is more accurate than a2  b2 when a and b have exact floating point representations because the expression
(a + b)(a  b) involves simple addition and subtraction of decimals, then easy multiplication takes place,
however the expression a2  b2 involves squaring of decimals resulting in more decimals , then subtraction takes place. The latter may involves round off whereas the former may not.

Do you have a similar question?

Recalculate according to your conditions!

Ask your question.
Get an expert answer.

Let our experts help you. Answer in as fast as 15 minutes.

Didn't find what you were looking for?