Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

6. We promised to return to the distinction between catastrophic and be- nign cancellation. Take Ye and ye to be two floats, which for ease

image text in transcribed

6. We promised to return to the distinction between catastrophic and be- nign cancellation. Take Ye and ye to be two floats, which for ease of ex- position we will take as having round values: Ie = 1234567891234567.0 and xe = 1234567891234566.0. Now, if we try to evaluate xa y we will experience catastrophic cancellation: each of the squaring opera- tions leads to a rounding error and then the subtraction exacerbates that dramatically. Write a Python code that does the following: (a) Carries out the calculation 1234567891234567212345678912345662 using integers, i.e., exactly. (b) Carries out the subtraction 1234567891234567.021234567891234566.02 using floats, i.e., exhibiting catastrophic cancellation. (c) Now, we will employ a trick: x2 - y2 can be re-expressed as (x - y) (x + y). Try using this trick for the floats and see what happens. Does your answer match the integer answer or the catastrophic-cancellation answer? Why? (N.B.: In the case of the quadratic equation we completely eliminated the need for any subtractions, whereas here we are still left with a subtraction, even in the best-case scenario)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Nested Relations And Complex Objects In Databases Lncs 361

Authors: Serge Abiteboul ,Patrick C. Fischer ,Hans-Jorg Schek

1st Edition

ISBN: 3540511717, 978-3540511717

More Books

Students also viewed these Databases questions

Question

What is the difference between Trigger and Stored Procedure?

Answered: 1 week ago

Question

Describe Balor method and give the chemical reaction.

Answered: 1 week ago

Question

How to prepare washing soda from common salt?

Answered: 1 week ago