Professional Documents
Culture Documents
Reference Solution For The Midterm Exam of Numerical Methods, 2008 Spring
Reference Solution For The Midterm Exam of Numerical Methods, 2008 Spring
1 (5%) Explain the differences between truncation error and rounding error
Ans:
Truncation error is the difference between the true result and the result produced
by a given algorithm using exact arithmetic. It usually occurs due to truncating an
infinite series or terminating an iterative sequence before convergence.
Rounding error is the difference between the result produced by a given algorithm
using exact arithmetic and the result produced by the same algorithm using limited
precision arithmetic, e.g., inexact representation of real numbers and arithmetic
operations upon them.
2 (a) (3%) What condition ensures that bisection method will find a root of a
continuous nonlinear equation f ( x) 0 in the interval [a, b]?
(b) (4%) What is the length of interval containing the root after six iterations?
(c) (3%) Do you need to know the particular function f to answer the question in
(b)?
Ans :
c 3 f ( x) x 2 3 0 x 3
(a) g1 ( x) 3 x x 2 , g1 ' ( x) 1 2 x
It diverges
x2 2x
(b) g 2 ( x) 1 x , g 2 ' ( x) 1
3 3
x 3
2
f ( xk )
g ( xk ) xk xk k
f ' ( xk ) 2 xk
g ' ( 3 ) g ' ( 3 ) 0 1
It converges
6 (10%) Carry out one iteration of Newton’s method applied to the system of
nonlinear equations with starting point x0 = [x0 y0] T = [1 2]T
x 2 xy 10
f ( x, y )
y 3xy 57
2
Ans :
x 2 xy 10 7
f ( x, y ) , x x y T
1 2T
f ( x ) 43
y 3xy 57
2 0 0 0 0
2 x y x 4 1
J ( x, y ) , J ( x0 )
3y
2
1 6 xy 12 13
4 1 7 7
J ( x0 ) S 0 f ( x0 ) S 0
12 13 43 43
1 13 1 7 1.2
S0
40 12 4 43 2.2
1 1.2 2.2
x1 x0 S 0
2 2.2 4.2
1 2 4 6
8 3 2 2
1 10 2 4
Ans:
Gaussian Elimination with Partial Pivoting 在每一個步驟中會先找出運算行對角線
以下絕對值最大的元素,並作列交換,這樣就會保證對角線上的元素都是在那一
行中對角線以下絕對值的最大值。
1 2 4 6
8 3 2 2 row1、row2 交換
1 10 2 4
8 3 2 2
1 2 4 6 1 row1 - row2, 1 row1 + row2
8 8
1 10 2 4
8 3 2 2
0 13 15 23 row2、row3 交換
8 4 4
77 9 17
4
0
8 4
8 3 2 2
0 77 9 17 77 row2 + row3
138 154 23 4 13
0 8 4 4
8 3 2 2
0 77 9 17
8 4 4
318 498
77
0 0
77
x = -0.113, y = 0.076, z = 1.566
Ans:
(a) No
因為 Ax=b 同乘一個 nonsingular diagonal matrix D,使得 DAx = Db,
但 D 為 nonsingular,所以只要再同乘 D 1 ,使得
D 1 ( DAx) Ax D 1 ( Db) b 。並不影響結果。
(b)Yes
影響 pivot 的選擇。
9. (5%) What is the LU factorization of the following matrix?
1 a
c b
Ans:
1 a 1 0 1 a
A , M1 , M1 A U
c b c 1 0 b ca
1 0
L ( M 1 ) 1
c 1
1 a 1 0 1 a
A LU
c b c
1 0 b ca
10. What is the sufficient condition for the Jacobi method to converge? Suppose we
want to solve the following equations using the Jacobi method, what coefficient
matrix should be used? (5%)
7 x1 3x2 4 x3 6
3x1 2 x2 6 x3 2
2 x 5 x 3x 5
1 2 3
Ans:
(a)
Coefficient n×n matrix A is diagonally dominant, a is one of element of A.
n
aii a
j 1, j i
ij , i 1,2,..., n
(b)
7 3 4
2 5 3
3 2 6
(b) (6%) Let A(0, 1), B(1, 3) and C(2, 15) be three points that we want to
interpolate on the XY plane. Please compute the natural cubic
splines f (u) and g (u ) passing A, B and C using the formula derived in (a)
and f (0) 1 , f ' (0) 1 , f " (0) 2 , g (0) f (1) 3 , g (1) 15 . (Hint:
Natural cubic splines are C2 continuous)
g(1)
C
f(1)
f(u) g(u)
f(0) B
A
Ans :
(a)
f (u ) a bu cu 2 du 3
f ' (u ) b 2cu 3du 2
f " (u ) 2c 6du
a p0
p0 f (0) a b p1
p1 f ' (0) b p2
c
p 2 f " (0) 2c 2
p3 f (1) a b c d p2
d p3 p1 p 0
2
d
c
f (u ) u 3 u2
u 1
b
a
1 1 1 / 2 1 p 0
0 0 1/ 2 0 p1
u3 u2
u 1
0 1 0 0 p 2
1 0 0 0 p 3
(b)這題有g(1)=15 & g(2)=15兩種解:
case(1) : g(1)=15
f (0) 1 a p0 1
f ' (0) 1 b p1 1
f " (0) 2 c 1 p 2 2
f (1) 3 d 2 p3 3
1 1 1/ 2 1 1 2
0 0 1 1
f (u ) u 3 u2
u 1
0
0
1
1/ 2
0
u3
0 2
u2
u 1
1
1 0 0 0 3 1
f (u) 2u 3 u 2 u 1
So we get,
g ( 0) f ( 0) 3 p 0
f (u ) 2u 3 u 2 u 1
g ' (0) f ' (1) 5 p1
f ' (u ) 6u 2 2u 1
g" (0) f " (1) 10 p2
f " (u ) 12u 2
g (1) 15 p3
1 1 1 / 2 1 3 2
0 0 5 5
g (u ) u 3 u 2 u 1
0
0
1
1/ 2
0
u3
0 10
u2
u 1
5
1 0 0 0 15 3
2u 3 5u 2 5u 3
case 2: g(2) = 15
g (0) 3 d
g (u ) au bu cu d
3 2
g ' (0) f ' (1) c 5
g ' (u ) 3au 2 2bu c g" (0) f " (1) 2b 10 b 5
g" (u ) 6au 2b 9
g ( 2) 8a 4b 2c d 15 a
4
a 9
b 4
g (u ) u 3 u2
u 1 u3
c
u2
u 1 5
5
d 3
9
g (u ) u 3 5u 2 5u 3
4
2 2 1 1 Pi
3 3 2 1 P
f (u ) u 3 u2 u 1
0
0 1
i 1
0 P' i
1 0 0 0 P' i 1
Ans :
(a) From the given conditions,
Pi Qi , Pi 1 Qi 3
P' i 3(Qi 1 Qi ) , P' i 1 3(Qi 3 Qi 2 )
we can re-express them as
Pi 1 0 0 0 Qi
P Q
i 1 = 0 0 0 1 i 1
P'i - 3 3 0 0 Qi 2
P ' i 1 0 0 -3 3 Qi 3
1 3 3 1 Qi
3 6 3 Q
0
= u3 u2 u 1
3 3 0 0
i 1
Q'i
1 0 0 0 Q ' i 1
1 3 3 1 90 100
3 6 3 0 105 140
P3~ 6 u 3 u2 u 1
3 3 0 0
150 220
1 0 0 0 180 140
45 200
90 120
= u3 u2
u 1
45 120
90 100
u 0,1
Ans:
(a) FALSE
因為 pivot 可能為 0,所以還是要做 partial pivoting
(b) FALSE
Counter example: consider an n by n diagonal matrix
0.5 0 0
0 0.5 0
A
0 0 0.5
whose determinant value is small, but the matrix is nonsingular.
(c) TRUE
1 1
Since (cA) 1 A
c
1 1
cond(cA) = cA A A A1 = cond(A)
c
(d) TURE
(e) FALSE
(f) FALSE
(g)FALSE
When the condition number is large, the residual gives little information
about the accuracy of solution.