Docsity

Numerical Linear Algebra - Solutions for Theoretical Assignment 2 | MATH 434, Study notes of Linear Algebra

Toggle sidebar
bg1
MATH 434/534
Theoretical Assignment 2 Solution
Chapter 3
No. 3.1
(a) Prove the expression
|fl(x)−x|
|x|≤µ
where µ=1
2β1−tfor rounding and µ=β1−tfor chopping.
(b) Show that (a) can be written in the form fl(x) = x(1 + δ) for |δ| ≤ µ.
-Solution-
(a)
First consider the bound for rounding. Let xbe written as x= (.d1d2··· dtdt+1 ···)×βe,
where d16= 0 and di∈[0, β) are integers. When we round off x, we have one of the following
floating point numbers,
x0= (.d1d2·· ·dt)×βe
x00 =h(.d1d2·· ·dt) + β−ti×βe
Since x∈x0, x00, without the loss of generality, we assume that xis close to x0. Then we
have
x−x0≤1
2x0−x00=1
2βe−t
So, the relative error is
x−x0
|x|≤1
2
βe−t
(.d1d2d3·· ·)×βe
=1
2
β−t
(.d1d2d3·· ·)
Since .d1d2d3·· · ≥ .d1and diare integers such that 0 ≤di< β, we have 1
.d1d2d3··· ≤1
.d1. Now
we have
x−x0
|x|≤1
2
β−t
(.d1d2d3·· ·)
≤1
2
β−t
.d1
=1
2
β−t
d1×β−1
≤1
2
β−t
β−1=1
2β1−t
Therefore for rounding, we have
|fl(x)−x|
|x|≤1
2β1−t
pf3
pf4
pf5
pf8

Partial preview of the text

Download Numerical Linear Algebra - Solutions for Theoretical Assignment 2 | MATH 434 and more Study notes Linear Algebra in PDF only on Docsity!

MATH 434/

Theoretical Assignment 2 Solution

Chapter 3 No. 3. (a) Prove the expression

|f l(x) − x| |x|

≤ μ

where μ = 12 β^1 −t^ for rounding and μ = β^1 −t^ for chopping. (b) Show that (a) can be written in the form f l(x) = x(1 + δ) for |δ| ≤ μ.

-Solution- (a) First consider the bound for rounding. Let x be written as x = (.d 1 d 2 · · · dtdt+1 · · ·) × βe, where d 1 6 = 0 and di ∈ [0, β) are integers. When we round off x, we have one of the following floating point numbers,

x

′ = (.d 1 d 2 · · · dt) × βe x ′′ =

[ (.d 1 d 2 · · · dt) + β−t

] × βe

Since x ∈

( x ′ , x ′′ ) , without the loss of generality, we assume that x is close to x ′

. Then we have ∣∣ ∣x − x

′ ∣∣ ∣ ≤

∣∣ ∣x

′ − x

′′ ∣∣ ∣ =

βe−t

So, the relative error is ∣∣ ∣x − x ′ ∣∣ ∣ |x|

βe−t (.d 1 d 2 d 3 · · ·) × βe

=

β−t (.d 1 d 2 d 3 · · ·)

Since .d 1 d 2 d 3 · · · ≥ .d 1 and di are integers such that 0 ≤ di < β, we have (^) .d 1 d^12 d 3 ··· ≤ (^) .d^11. Now we have ∣∣ ∣x − x ′ ∣∣ ∣ |x|

β−t (.d 1 d 2 d 3 · · ·)

≤

β−t .d 1

=

β−t d 1 × β−^1

≤

β−t β−^1

β^1 −t

Therefore for rounding, we have

|f l(x) − x| |x|

β^1 −t

Next consider the bound for chopping. Again let x be written as x = (.d 1 d 2 · · · dtdt+1 · · ·)×βe, where d 1 6 = 0 and di ∈ [0, β) are integers. Using the chopping method, we have the following floating point numbers,

x ′ = (.d 1 d 2 · · · dt) × βe

Now consider the absolute error

∣∣ ∣x − x ′ ∣∣ ∣. ∣∣ ∣x − x

′ ∣∣ ∣ = |(.d 1 d 2 · · · dtdt+1 · · ·) × βe^ − (.d 1 d 2 · · · dt) × βe|

∣∣ ∣∣ ∣∣(.^00 ︸ ︷︷· · · 0 ︸ t zeros

dt+1dt+2 · · ·) × βe

∣∣ ∣∣ ∣∣

=

∣∣ ∣(.dt+1dt+2 · · ·) × βe−t

∣∣ ∣

The relative error is ∣∣ ∣x − x ′ ∣∣ ∣ |x|

|(.dt+1dt+2 · · ·) × βe−t| |(.d 1 d 2 · · · dtdt+1 · · ·) × βe−t|

=

|(.dt+1dt+2 · · ·) × β−t| |(.d 1 d 2 · · · dtdt+1 · · ·)|

Since .d 1 d 2 d 3 · · · ≥ .d 1 and di are integers such that 0 ≤ di < β, we have (^) .d 1 d^12 d 3 ··· ≤ (^) .d^11. So, we have ∣∣ ∣x − x

′ ∣∣ ∣ |x|

|(.dt+1dt+2 · · ·) × β−t| |(.d 1 d 2 · · · dtdt+1 · · ·)|

≤

|(.dt+1dt+2 · · ·) × β−t| |.d 1 |

=

|(.dt+1dt+2 · · ·) × β−t| |d 1 × β−^1 |

|(.dt+1dt+2 · · ·)| |d 1 |

× β^1 −t

However, |(.dt+1|dd 1 t|+2 ···)|≤ 1 because d 1 6 = 0 and di ∈ [0, β) are integers. Finally, we have ∣∣ ∣x − x ′ ∣∣ ∣ |x|

{ |(.dt+1dt+2 · · ·)| |d 1 |

× β^1 −t

} ≤ β^1 −t

Therefore for chopping, we have

|f l(x) − x| |x|

≤ β^1 −t.

(b) Let δ = f l(xx) −x. Then we have

f l(x) = x + xδ = x(1 + δ)

Also, from part (a) we have

|δ| =

∣∣ ∣∣ ∣

f l(x) − x x

∣∣ ∣∣ ∣ ≤^ μ

For β = 10 and t = 9, f l(1.00000001) = 1.000000001 = 1 + 10−^8. Therefore, we have

f l(AT^ A) =

( 1 + 10−^8 1 1 + 10−^8

)

No. 3. Show how to arrange computation in each of the following, so that the loss of significant digits can be avoided. Do one numerical example in each case to support your answer. (a) ex^ − x − 1 for negative values of x. (c) (^) x^1 − (^) x+1^1 for large values of x. (e) 1 − cos x for values of x near zero.

-Solution- (a) Let x = −y for negative values of x for y > 0. Then we have

ex^ − x − 1 = e−y^ + y − 1

=

ey^

  • y − 1

=

1 + y + y 2 2! +^

y^3 3! +^ · · ·^

  • y − 1

Letting f (x) = ex^ − x − 1, consider the case where x = − 0 .01. The actual value of f at x = − 0 .01 is f (− 0 .01) = e−^0.^01 + 0. 01 − 1 = 4. 98337 × 10 −^5. Using five-digit arithmetic, since e−^0.^01 = 0.9900, we have

f (− 0 .01) = e−^0.^01 + 0.01 + 1 = 0.9900 + 0. 01 − 1 = 0

For y > 0, define g(y) = f (−x) as

g(y) =

1 + y + y 2 2! +^

y^3 3! +^ · · ·^

  • y − 1

Now consider g(0.01). Then we have

g(0.01) =

2 2! +^

(0.01)^3 3!

+ (0.01) − 1 = 4. 98341584 × 10 −^5

(c) Let f (x) = (^1) x − (^) x+1^1. In order to avoid the loss of significant digits, use

f (x) =

x(x + 1)

Now consider the case where x = 10^7. The actual value of f at x = 10^7 is f (7) = 1017 − 1 (10^7 +1) = 9.^999999 ×^10

− (^15). Using eight-digit arithmetic 1 107 = 1.^0 ×^10

− (^7) and 1 107 +1 = 0 .000000099999 = 0. Therefore, in eight-digit f (10^7 ) = 0.0000001 + 0 = 0.0000001. Using f (x) = (^) x(x^1 +1) , we have

f (10^7 ) =

107 (10^7 + 1)

1014 + 10^7

= 9. 99999 × 10 −^15

(e) Let f (x) = 1 − cos x. Then consider the case where x = 10−^4. The actual value of f at x = 10−^4 is f (10−^4 ) = 1 − cos(10−^4 ) = 5. 0 × 10 −^9. Using 9-digit arithmetic, cos(10−^4 ) = 0 .999999995 = 1.0. Therefore, f (10−^4 = 1 − 1 = 0) in 9-digit arithmetic. Using the Taylor expansion of cos x, we have

f (x) = 1 − cos x

= 1 −

( 1 −

x^2 2!

x^4 4!

x^6 6!

x^8 8!

)

x^2 2!

x^4 4!

x^6 6!

x^8 8!

Therefore, f (10−^4 ) ≈ 10 − 8 2! −^

10 −^16 4! +^

10 −^24 6 −^

10 −^32 8! = 4.^999999996 ×^10

− (^9). No. 3.

Let β = 10, t = 4. Consider computing

a =

) / 0. 1666.

How many correct digits of the exact answer will you get?

-Solution- The exact value of a is

a =

) / 0. 1666

= 4. 00160064 × 10 −^4 = 0. 000400160064

For β = 10 and t = 4, 16 = 0.166666 = 0.1667. Therefore, we have

a = (0. 1667 − 0 .1666) / 0. 1666 = 0. 0001 / 0. 1666 = 6. 00240096 × 10 −^4 = 0. 000600240096

Therefore, there are no correct significant digits.

No. 3. Consider evaluating e =

a^2 + b^2. How can the computation be organized so that overflow in computing a^2 + b^2 for large values of a or b can be avoided?

-Solution- If either a or b is too large or too small, we can get overflow or underflow. In oder to avoid overflow, we normalize both a and b. Let m = max(|a| , |b|). Also let y 1 = (^) ma and y 2 = (^) mb.

Then set e = m

√ y^21 + y 22.

No. 3. What problem do you foresee in solving the quadratic equations (a) x^2 − 106 x + 1 = 0.

Compute y 1 , y 2 ,... , y 10 using this formula, taking

y 0 = [ln(x + 5)]^10 = ln 6 − ln 5 = ln(1.2).

What abnormalities do you observe in this computation? Explain what happened. Now rearrange the recursion so that the values of yi can be computed more accurately.

-Solution- For i = 1,

y 1 =

∫ (^1)

0

x x + 5

dx

∫ (^1)

0

x + 5

dx

∫ (^1)

0

x + 5

dx = 1 − 5 y 0

For i = k, assume that we can express the integral

yk =

∫ (^1)

0

xk x + 5

dx

as

yk =

k

− 5 yk− 1.

With this assumption, we will show that the integral yk+1 =

∫ (^1) 0

xk+ x+5 dx^ expressed as the recursion formula yk+1 = (^) k+1^1 − 5 yk.

yk+1 =

∫ (^1)

0

xk+ x + 5

dx

∫ (^1)

0

xk^ −

5 xk x + 5

dx

∫ (^1)

0

xkdx − 5

∫ (^1)

0

xk x + 5

dx

k + 1

− 5 yk

By the mathematical induction, for i = 1, 2 , 3... we showed that the integral yi =

∫ (^1) 0

xi x+5 dx can be expressed as the formula yi = (^1) i − 5 yi− 1. Now computing the integral by using the recursion formula, you will have

i 0 1 2 3 4 5 6 7 8 9 yi 0. 1823 0. 0884 0. 0580 0. 0431 0. 0343 0. 0285 0. 0243 0. 0212 0. 0188 0. 0169

i 10 11 12 13 14 15 16 17 18 19 yi 0. 0154 0. 0141 0. 0130 0. 0120 0. 0112 0. 0105 0. 0099 0. 0094 0. 0087 0. 0092

i 20 21 22 23 24 25 yi 0. 0042 0. 0264 − 0. 0866 0. 4764 − 2. 3401 11. 7405

Or with four decimal degits floating point rounded arithmetic, we have

i 0 1 2 3 4 5 6 7 yi 0. 1823 0. 0885 0. 0575 0. 0458 0. 0208 0. 0958 − 0. 3125 1. 7054

i 8 9 10 yi − 8. 4018 42. 1200 − 210. 5002

Since x ∈ [0, 1], the integrand x

i

∫ x+5^ is positive for^ i^ = 1,^2 ,... , n.^ Therefore, the integral 1 0

xi x+5 dx^ ≥^ 0.^ However, we have negative values at^ i^ = 22 and^ i^ = 24.^ Now rewrite the recursion formula as

yi− 1 = −

yi 5

5 i

for i = 2, 3 ,... , n. Also since x ∈ [0, 1], we have 16 ≤ (^) x+5^1 ≤ 15. Therefore, for i = 1, 2 ,... , n we have

xi 6

xi x + 5

xi 5

≤ xi

This inequality tells us that

∫ (^1) 0

xi x+5 dx^ ≤^

∫ (^1) 0 x

idx = 1 i+1. For^ i^ = 25 we have

y 25 =

∫ (^1)

0

xi x + 5

dx ≤

Now assuming y 25 = 0 and using this rearranged recursion formula, we will obtain

i 1 2 3 4 5 6 7 8 9 10 yi 0. 0884 0. 0580 0. 0431 0. 0343 0. 0285 0. 0243 0. 0212 0. 0188 0. 0169 0. 0154

i 11 12 13 14 15 16 17 18 19 20 yi 0. 0141 0. 0130 0. 0120 0. 0112 0. 0105 0. 0099 0. 0093 0. 0088 0. 0084 0. 0080

i 21 22 23 24 yi 0. 0076 0. 0073 0. 0067 0. 0080