Math 450 Midterm 1

advertisement
Math 450 Midterm 1
1. What are the values of x and y at the end of the following pseudocode?
x=1
y=0
for i = 1 : 4
x = ix
y =y+x
end
Solution.
x = 24, y = 1 + 2 + 6 + 24 = 33.
1
2. Using Taylor series, estimate sin
Solution.
1
10
to within 10−6 of the exact value.
Using the alternating series theorem with
sin(10−1 ) = 10−1 −
10−3 10−5
+
− ...
3!
5!
and the partial sum 10−1 − 103! = 0.09983333 . . ., we nd that
−3
| sin(10−1 ) − 0.09983333 . . . | ≤
2
10−5
< 10−6 .
5!
3. Suppose x, y and x + y are numbers within the range of our 32-bit model machine
that uses chopping. Give an example to show that ((x) + (y)) 6= (x + y) in general.
Solution.
Let x = 1 + 2−24 , y = 2−24 . Then (x) = 1, (y) = y , and (x + y) = x + y , so
((x) + (y)) = (1 + y) = (x) = 1 6= x + y = (x + y).
3
4. How can loss of signicance be avoided in computing x − sin x for x ≈ 0?
Solution.
By using Taylor series to write
x − sin x =
x3 x5
−
+ ...
3!
5!
4
5. Consider Newton's method for estimating the root r =
1
a
1
of f (x) = 1 − ax
.
a) Verify that the sequence of iterates is
(1)
xn+1 = 2xn − ax2n .
Solution.
Note that
1
1 − ax
f (x)
=
= ax2 − x.
1
f 0 (x)
2
ax
Thus, the iterates are
xn+1 = xn −
f (xn )
= xn − (ax2n − xn ) = 2xn − ax2n .
f 0 (xn )
b) Let en = xn − a1 be the error at the nth iteration, and show by hand that the sequence
of iterates (1) converges quadratically under appropriate conditions.
Solution.
The iterates converge quadratically when x0 is close enough to a because
2
1
1
1
2
.
xn+1 − = 2xn − axn − = −a xn −
a
a
a
For a rigorous argument, suppose |x0 − a1 | =
x1 −
1 C 2
=
,
a |a|
x2 −
C
|a|
1 C 4
=
,
a |a|
so that limn→∞ xn = a1 .
5
where 0 ≤ C < 1. Then
...,
xn −
n
1 C 2
=
a
|a|
Download