Test 1B Solutions
Test 1B Solutions
Q1. The finite-divided difference approximation of the first derivative of the function f(x) can be
f ( xi ) f ( xi 1 )
f ( xi ) , (Eqn.1)
h
f ( xi1 ) f ( xi1 )
or f ( xi ) . (Eqn. 2)
2h
where step size h= xi+1-xi= xi-xi-1. which approximate has a better accuracy? Prove your answer through error
analysis. (16 marks)
Solutions:
Eqn. 2 has a better accuracy.
Using Taylor series expansion, one has
f ( xi ) 2 f xi 3
f xi 1 f xi f xi h h h .... (a)
2 6
f ( x i ) f ( xi1 ) f ( xi )
Thus, one has f ( x ) h
i h 2
f ( x i ) f ( xi1 )
O(h) .
h
For f (xi+1), one has
f xi 2 f xi 3
f xi 1 f xi f xi h h h ... (b)
2 6
Then, from (b)-(a), one can get
f xi 1 f xi 1 f (3) ( xi ) 2
f xi h
2h 12
f xi 1 f xi 1
O(h2 ).
2h
Thus, the truncation error of Eqn. 2 is O(h2) which is one order smaller than that of Eqn.1, i.e. O(h).
Q2: Starting from the initial values x =2.1, apply the Newton-Raphson method for two iterations to estimate the
root of
f ( x) x sin(4 x) (15 marks)
Solution:
The first derivative of f ( x) is :
f '( x) sin(4 x) 4 x cos(4 x).
Then, the Newton-Raphson equation can be written as
f ( xk ) xk sin(4 xk )
xk 1 xk xk
f '( xk ) sin(4 xk ) 4 xk cos(4 xk )
Since x0 2.1, the values for two interations are:
x0 sin(4 x0 )
x1 x0 2.6117
sin(4 x0 ) 4 x0 cos(4 x0 )
1
x1 sin(4 x1 )
x2 x1 2.2582
sin(4 x1 ) 4 x1 cos(4 x1 )
Q3: For unknown function f(x), it is known that f(0)=1.0, f(1)=1.5, f(2)=1.9, and f(3)=2.8. Find the estimation of
f ’(1.3) with the second-order Lagrange interpolating polynomial. (14 marks)
Solution:
Using the data of f(0), f(1) and f(2) to build the second-order Lagrange interpolating polynomial, one has
( x 1)( x 2) ( x 0)( x 2) ( x 0)( x 1)
f 2 ( x) 1.0 1.5 1.9
(0 1)(0 2) (1 0)(1 2) (2 0)(2 1)
1.0+0.55x 0.05x2
Then,
f 2( x)= 0.55 0.1x ,
Q4: Starting from the initial value y=1 and dy/dt=0 when t =0, solve the differential equation:
d2y
7sin 2 ( y )
dt 2
for y at t =0.2 by using the Classical fourth-order Runge-Kutta method with the step size of 0.1.
(y is in radian; Round your answer to 4 decimal places) (25 marks)
Solution:
The equation can be rewritten as the following pair of ODEs:
dy
z,
dt
dz
7sin 2 ( y) ,
dt
h=0.1, f1 (t , y, z) z , f 2 (t , y, z ) 7sin 2 ( y) ;
k1,1 f1 (0, 1, 0) 0
k1,2 f 2 (0, 1, 0) −4.9565
k2,1 f1 (0.05, 1, 0.2478) −0.2478
k2,2 f 2 (0.05, 1, 0.2478) −4.9565
k3,1 f1 (0.05, 0.9876, 0.2478) -0.2478
k3,2 f 2 (0.05, 0.9876, 0.2478) −4.8772
k4,1 f1 (0.1, 0.9752, 0.4877) −0.48772
y(0.1)=1+(k1,1+2k2,1+2k3,1+k4,1)×0.1/6=1.0-0.1×0.2465=0.9753.
z(0.1)=0+(k1,2+2k2,2+2k3,2+k4,2)×0.1/6=-0.1×4.9035=-0.4903.
2
k1,1 f1 (0.1, 0.9753, 0.4903) −0.4903
k1,2 f 2 (0.1, 0.9753, 0.4903) −4.7979
k2,1 f1 (0.15, 0.9508, 0.7302) -0.7302
k2,2 f 2 (0.15,0.9508, 0.7302) -4.6370
k3,1 f1 (0.15, 0.9388, 0.7222) -0.7222
k3,2 f 2 (0.15, 0.9388, 0.7222) -4.5573
k4,1 f1 (0.2, 0.9031, 0.9461) -0.9461
y(0.2)= 0.9753+(k1,1+2k2,1+2k3,1+k4,1)×0.1/6=0.9753-0.1×0.7236=0.9030.
z(0.2)= -0.4903+(k1,2+2k2,2+2k3,2+k4,2)×0.1/6=-0.4903-0.1×4.5838=-0.9487.
Q5: The cross section of an infinitely long metal square conduit is charged with the given potentials at the
boundaries as shown in Fig. Q5. The conduit is filled with a dielectric material such that the field strengths are
different in the x and y directions. The potential at any particular point in the cross section satisfies the partial
d 2V d 2V
differential equation 7 0.
dx 2 dy 2
Fig. Q5
Find the approximate values of the potentials at the grid points by accelerated Liebmann’s method with the
initial guess of V11, V21, V12, and V22 as 25, 25, 65, and 65, respectively. (Iterate 2 times; give your answer to
4 decimal places) (30 marks)
Solution:
As shown in the above figure, for partial differential equation
2V 2V
7 0
x 2 y 2
If the grid is with the width of h, the potential V can be expressed by using a Taylor series at (x, y)
along x axis, retaining only up to and including the third-order terms, as:
1 1
V ( x h, y ) V ( x, y ) hVx ( x, y ) h 2Vxx ( x, y ) h3Vxxx ( x, y ) ... (1)
2 6
1 1
V ( x h, y ) V ( x, y ) hVx ( x, y ) h 2Vxx ( x, y ) h3Vxxx ( x, y ) ... (2)
2 6
3
by adding (1) and (2), we can get
1
Vxx ( x, y) [V ( x h, y) V ( x h, y ) 2V ( x, y )] (3)
h2
Similarly, along y axis, we can have
1 1
V ( x, y h) V ( x, y ) hVy ( x, y ) h 2Vyy ( x, y ) h3Vyyy ( x, y ) ... (4)
2 6
1 1
V ( x, y h) V ( x, y ) hVy ( x, y ) h 2Vyy ( x, y ) h3Vyyy ( x, y ) ... (5)
2 6
By adding (4) and (5), we can obtain,
1
Vyy ( x, y) 2 [V ( x, y h) V ( x, y h) 2V ( x, y )] (6)
h
through (3)+7(6), we have
V ( x h, y) V ( x h, y) 7V ( x, y h) 7V ( x, y h) 16V ( x, y)
which can be written as
1
V (i, j ) (Vi 1, j Vi 1, j 7Vi , j 1 7Vi , j 1 )
16
Consider the boundary condition, we can have
1
V11 (25 V21 7 25 7V12 ) 0.0625V21 0.4375V12 12.5
16
1
V21 (V11 25 7 25 7V22 ) 0.0625V11 0.4375V22 12.5
16
1
V12 (25 V22 7V11 7 100) 0.0625V22 0.4375V11 45.3125
16
1
V22 (V12 25 7V21 7 100) 0.0625V12 0.4375V21 45.3125
16
Then, the iteration formula of accelerated Liebmann’s method is
V11k 1 0.0625V21k 0.4375V12 k 12.5
V21k 1 0.0625V11k 1 0.4375V22 k 12.5
V12 k 1 0.0625V22 k 0.4375V11k 1 45.3125
V22 k 1 0.0625V12 k 1 0.4375V21k 1 45.3125
So, we have the following iteration table containing values of each mesh points:
k V11 V21 V12 V22
0 25 25 65 65
1 42.5000 43.5938 67.9688 68.6328
2 44.9609 45.3369 69.2725 69.4769