

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


Due on Tuesday, Oct. 1 on plain old paper. Binary floating-point numbers have the form
xˆ = ±a 0 .a 1 a 2 · · · ad × 2 e.
If ˆx 6 = 0, then ˆx is normalized if a 0 = 1. Normalization makes e unique, since it must be the largest integer such that 2e^ ≤ | xˆ|. If ˆx = 0, then we may simply define the normalized representation to be 0 × 20. In IEEE single-precision arithmetic, d = 23 (i.e., 24-bit precision), and in double-precision arithmetic, d = 52 (i.e., 53-bit precision). Floating-point arithmetic is correctly rounded if the operation ˆx yˆ is per- formed as though infinite precision were available, followed by rounding. Here refers to the rounded floating-point operations of addition, subtraction, multiplica- tion, and division. All four elementary operations in IEEE arithmetic are correctly rounded, as is the square root operation. In lecture, we discussed the following theorem:
Let ˆx and ˆy be floating-point numbers of the same precision and range. Suppose that ˆx · yˆ is defined and representable, where · refers to one of addition, subtraction, multiplication, or division. Let ˆx yˆ denote the corresponding correctly-rounded result (to the same precision as xˆ and ˆy). Then there is a real number δ such that
xˆ yˆ = ( xˆ · yˆ)( 1 + δ ), (1)
where |δ | ≤ ε (the machine epsilon) in all rounding modes and where |δ | ≤ 12 ε when rounding to nearest.
By defined and representable, we mean that ˆx · yˆ is a real number (e.g., we aren’t dividing by 0) and can be approximated as a floating-point number without over- flow or underflow.
(a) Show that the values 1.0, 2.0, and 3.0 can be represented exactly. (b) You can extend your argument in (a) to show that 4.0, 5.0, 6.0,... , M have exact representations. What is M? (c) Repeat your calculation in (b) for IEEE double precision.
r± =
−b ± D 2 a
, where D =
b^2 − 4 ac. (2)
What is the relative error in r+ in terms of the machine epsilon in 6-digit, correctly-rounded decimal arithmetic, when a = 0 .414235, b = 12, and c = 0 .0129134? Use Python, Maple, or a pocket calculator. Round the result of each cal- culation to the nearest 6-digit floating-point number before continuing to the next one. (You’re trying to simulate the behavior of a computer whose registers hold 6-digit decimal values.) For instance, you can compute
4 ⊗ a |= x 1 x 1 ⊗ c |= x 2 b ⊗ b |= x 3 x 3 x 2 |= x 4 ,
and so on. Here |= refers to the truncation to 6 digits by rounding to nearest.
r± =
2 c −b ±
b^2 − 4 ac
is equivalent to the usual quadratic formula for the zeroes of the polynomial ax^2 + bx + c. (b) Repeat the previous problem using Eq. (3). Which of the two equations produces the most accurate value of r+? r−? Explain why. (Hint: where does catastrophic cancelation occur?)