Solution1

Homework #1, due Feb. 5, 2009.
1: Compute the absolute error and relative error in approximation of x by x*.
a): x=π, x*=22/7.
b): x=π, x*=3.1416
please review your lecture notes for the definition of absolute error and relative
error. Absolute error=|x-x*|; relative error=|(x-x*)/x|, provided x is not zero.
2: Suppose x* must approximate x with relative error at most 10 !3 . Find the largest
interval in which x* must lie for each value of x
a) x=150.
b) x=90.
Use the definition of relative error, | (x ! x*) / x |" # , let ! = 10 "3 . Solve the inequality,
you will get the interval for x.
3: The Maclaurin series for the arctangent function converges for !1 < x " 1 and given by
n
x 2i #1
arctan(x) = lim Pn (x) = lim $ (#1)i +1
x!"
x!"
2i # 1
i =1
a): use the fact that tan(! / 4) = 1 to determine the number of n terms of the series
that need to be summed to ensure that | 4Pn (1) ! " |< 10 !3 .
b): suppose Matlab require the value of π to be within 10 !10 , how many terms of
the series would we need to sum to obtain this degree of accuracy?
c): this is NOT an efficient way to evaluate the value of π. The method can be
!
1
1
significantly improved by observing that = arctan + arctan and evaluating
4
2
3
the series for the arctangent at ½ and 1/3. Determine the number of terms that
must be summed to ensure an approximation to π to within 10 !3 .
The key idea is infinite series Pn (x) is an alternating series. So the difference
12n !1
|< " = 10 !3 , solve for
| 4Pn (1) ! " | is bounded by the nth term only, 4 | (!1)
2n ! 1
n=2001, so you need 2000 terms to get the required accuracy. Similarly for. ! = 10 "10 .
This series converges slowly. To improve, we consider
n
1 % 1
1 (
!
1
1
+ 2i #1 * , follow the same procedure
= arctan + arctan = lim $ (#1)i +1
2i
#1
'
(2i # 1) & 2
3 )
4
2
3 x!" i =1
as part a, you will find 5 terms would be enough for the required degree of accuracy
! = 10 "3 .
n
1 x
dx n=0,1,2,...20.
4: Consider integral I n = !
0 x+5
a): establish the recursive relation between I n and I n !1 with I 0 =ln6-ln5
hint: I n +5I n !1 can be calculated explicitly.
n +1
b): establish the recursive relation between en and en !1 . suppose an error e0 is
introduced initially in the computation of I 0 .
c): how e0 is amplified at the nth step? Is this algorithm numerical stable?
The hint tells you why you can evaluate the integral explicitly. for n=0, I 0 = ln(6) ! ln(5) .
1 n
1
n !1
For n>0, I n +5I n !1 = " x + 5x dx = " x n !1dx = 1 ; This leads to the iterative formula,
0
5+x
0
n
1
1
*
with
- 5I n !1 , with I 0 = ln(6) ! ln(5) . For a computer, we have I n* = - 5I n!1
n
n
I 0* = I 0 + e0 . We are interested in how e0 is amplified. Use the definition of error, we
In =
know, en = I n ! I n* = !5I n !1 +5I n*!1 = !5en !1 , so en = (!5)n e0 , for large n, the error at nth
iteration can be significant.
5: Determine the convergence rate of the cosine function f (h) = cosh as h ! 0
see your lecture notes for the solution.