Use Python to help show answer Answer the following a Which

Use Python to help show answer

Answer the following:

(a) Which of the two mathematically equivalent expressions x^2 y^2 and (x y)(x + y) can be evaluated more accurately in floating-point arithmetic? Why?

(b) For what values of x and y, relative to each other, is there a substantial difference in the accuracy of the two expressions?

Solution

(a) Which of the two mathematically equivalent expressions x^2 y^2 and (x y)(x + y)
can be evaluated more accurately in floating-point arithmetic? Why?
The squaring of a floating point number may lead to roundoff error, as the decimal part
in the result will have more digits. And ofcourse, after that the subtraction will loose
some digits when handling extremely skewed floating point numbers. So, x^2 - y^2 may lead
to more rounding errors.
Where as, on the other hand, (x-y)(x+y) will relatively be preferred to the previous one.
Even though this operation is also having multiplication involved in it, the subtraction
before the multiplication will do less harm relatively.

(b) For what values of x and y, relative to each other, is there a substantial difference
in the accuracy of the two expressions?
Computing the exact difference or sum of two floating point numbers can be very expensive
when their exponents are substantially different. Therefore, when the exponents are
substantially high, the x, and y value will have substantial difference in their accuracy.

Use Python to help show answer Answer the following: (a) Which of the two mathematically equivalent expressions x^2 y^2 and (x y)(x + y) can be evaluated more a

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site