Download as pdf or txt
Download as pdf or txt
You are on page 1of 10

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 : (a) f(a)*f(b)<0


ab
(b)
26
(c) no

3 (10%) The secant method approaches the root of an equation f ( x)  0 by


iteratively computing the intersection of the x-axis and a secant line passing
( x k , f ( xk ) ) and ( xk 1 , f ( xk 1 ) ), which approximates the curve y  f (x) in the
interval xk 1 , xk . Derive the iteration formula of the secant method in terms
of xk 1 , x k , f ( xk ) , xk 1 , f ( xk 1 ) .
Ans :
xk 1  xk xk  xk 1

0  f ( xk ) f ( xk )  f ( xk 1 )
xk  xk 1
 xk 1  xk  f ( xk ) *
f ( xk )  f ( xk 1 )

4.(10%) The Newton’s method approaches the root of an equation f ( x)  0 by


iteratively computing the intersection of the x-axis and a secant line passing
( x k , f ( xk ) ) with the slope f’(x), which approximates the curve y  f (x) in the
interval xk 1 , xk . Derive the iteration formula of the secant method in terms
of xk 1 , x k , f ( xk ) , xk 1 , f ( xk 1 ) .
Ans:

5 (10%) Suppose we want to solve the nonlinear equation f ( x)  x 2  c  0 given the


value of c. For each of the following functions, determine whether the
corresponding scheme xk 1  g ( xk ) is convergent if c  3 . Explain your reasoning
in each case.
(a) g1 ( x)  c  x  x 2 .
(b) g 2 ( x)  1  x  x 2 c .
(c) What is the fixed-point iteration function given by Newton’s method for this
particular problem? Is it convergent?

Ans :

c  3  f ( x)  x 2  3  0  x   3

(a) g1 ( x)  3  x  x 2 , g1 ' ( x)  1  2 x

 g1 ' ( 3 )  1 & g1 ' (  3 )  1

 It diverges
x2 2x
(b) g 2 ( x)  1  x  , g 2 ' ( x)  1 
3 3

g 2 ' ( 3 )  1  it converges in interval contain the root 3

g 2 ' ( 3 )  1  it diverges in interval contain the root  3

(c) fixed-point iteration function given by Newton’s method :

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 2T
 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

7. (10%) Solve this system by Gaussian elimination with partial pivoting:

 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

8. (10%) Suppose that both sides of a system of linear


equationsAx=b are premultiplied by a nonsingular diagonal
matrix.
(a) Does this change the true solution? Why?
(b) Can this affect the choice of pivots in Gaussian elimination? Why?

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

d11 0 0   a11 a12 a13 


設 D   0 d 22 0  , A  a a 23 
  21 a 22
 0 0 d 33  a31 a32 a33 

 d11a11 d11a12 d11a13 


則 DA  d 22 a 21 d 22 a 22 d 22 a 23 
 d 33a31 d 33a32 d 33a33 

若原本 a21  a11 ,但只要 d11 夠大, d 22 夠小,就會 d11a21  d 22a11 ,而

影響 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

11 The natural cubic splines f (u)  a  bu  cu 2  du 3 can be defined based on the


following conditions: p 0  f (0) , p1  f ' (0) , p 2  f " (0) , p3  f (1) .
p 0 
p 
(a) (9%) Please derive the coefficient matrix M in f (u )  u 3  u2 
u 1 M 1  .
p 2 
 
p3 

(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

12 The formula of Hermite splines for representing a 2D curve passing


points Pi and Pi 1 is

 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 

where u  [0,1] is the parameter; Pi  ( xi , yi ) is a point in 2D space and


P'i  dPi du is the derivative at Pi .
(a) (5%) Please derive the formula for Bezier splines from Hermite splines using
the following conditions
Pi  Qi , Pi 1  Qi 3
P' i  3(Qi 1  Qi ) , P' i 1  3(Qi 3  Qi  2 )
(b) (5%) Is a curve represented by composite Bezier splines C1 continuous?
What condition guarantees Bezier splines to be C1 continuous?
(c) (5%) Compute the connected Bezier curves from the following table.
points 0 1 2 3 4 5 6
x 10 50 75 90 105 150 180
y 10 15 65 100 140 220 140

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 

Plugging it into the Hermite splines equation, we can obtain


 2 2 1 1  1 0 0 0  Qi 
 3 3  2  1  0 Q 
1

f (u )  u 3 u2 u 1
0
0 1
 
0  - 3
0 0
3 0 0
 i 1 
 Q'i 
     
1 0 0 0 0 0 -3 3 Q ' i 1 

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 

(b)Yes, collinear control points guarantee C1 continuity


 1  3  3 1 10 10 
 3  6 3 0 50 15 
3

(c) P0~3  u u u 1 
2
 3 3
 
0 0 75 65 

  
1 0 0 0 90 100
 5  60
 45 135 
=u
3
u2 u 1 
 120 15 


 
 10 10 

 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

13. (15%) True or False


(a) If a linear system is well-conditioned, then pivoting is unnecessary in
Gaussian elimination.
(b) If a matrix has a small determinant value, then the matrix is nearly singular.
(c) If A is a nonsingular matrix and c is a scalar, then the condition number of A
and cA are the same.
(d) A curve generated by cubic B-splines is C2 continuous.
(e) Natural cubic splines have local control property.
(f) For finding a simple root of a nonlinear equation, the secant method
converges faster than the Newton method.
(g) A small residual guarantees an accurate solution of a system of nonlinear
equations f(x) = 0.

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 A1 = 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.

You might also like