You are on page 1of 7

MTH 510 Midterm Test - (Solutions)

Full Solution Questions:

7 1. a) ( 3 marks) Find the Maclaurin series for f (x) = e 2x .


Marks

Solution: The Maclaurin series expansion of f (x) = e 2x

1 00 1 000
f (x) = f (x0 ) + f 0 (x0 )(x x0 ) + f (x0 )(x x0 ) 2 + f (x0 )(x x0 ) 3 · · ·
2! 3!
where x0 = 0

f (x) = e 2x ! f (0) = 1
f 0 (x) = ( 2)e 2x ! f 0 (0) = 2
f 00 (x) = ( 2)2 e 2x ! f 00 (0) = ( 2)2
0
f (x) = ( 2) e3 2x ! f 000 (0) = ( 2)3
iv
f (x) = ( 2) e 4 2x ! f iv (0) = ( 2)4
Maclaurin series approx of f (x)

2x 22 2 23 3 24 4
e ⇡1 2x + x x + x + ···
2! 3! 4!

b) (4 marks) Use the expansion to estimate e 0.2 with at least 4 correct significant
figures. As part of your answer, add terms one at a time until the
relative percentage error is less than the stopping criterion for the
desired accuracy .

Solution:
Stopping criteria for three significant figure accuracy "s = 0.5 ⇥ 102 3% =
0.05%

# of terms approx "a % Stop!


1 1 NA No
|0.8 1|
2 1 2(0.1) = 0.8 0.8 100% = 25 No
2 |0.82 0.8|
3 1 2(.1) + 4(.1) /2 = 0.82 0.8 100% = 2.44 No
4 2 3
1 2(.1) + 4(.1) /2 8(.1) /6 = 0.81867 0.16 No
5 0.81873 008 < "s Stop
Stop iteration "a < "s
True value e 0.2 = 0.818730753 and the approximate using only five terms
of the expansion e 0.2 ⇡ 0.81873 has at least 3 significant figures accuracy.

Page 2 of 9
MTH 510 Midterm Test - (Solutions)

9 2. Solve the system of equation using Naive Gauss Elimination with partial pivoting.
Marks

2 32 3 2 3
0 2 5 x1 1
42 1 15 4x2 5 = 415
3 1 0 x3 2

(Use 4 digit arithmetic with chopping)

Solution: Gauss Elimination with partial pivoting, Forward elimination;


2 3 2 3
0 2 5 |1 3 1 0 |2
à = 42 1 1 |15 4 2 1 1 |15
R3 $ R1 R2 (2/3)R1
3 1 0 |2 0 2 5 |1
2 3 2 3
3 1 0 2 3 1 0 2
4 0 0.3333 1 0.33335 40 2 5 1 5
R3 $ R2
0 2 5 1 0 0.3333 1 0.3333 R3 (0.3333/2)R2
2 3
3 1 0 2
40 2 5 1 5
0 0 0.1668 0.4999

The backward substitution


x3 = 0.4999/0.1668 = 2.997
x2 =(1 5x3 )/2 = (1 5( 2.997))/2 = (1 ( 14.98))/2 = 7.990
x1 =(2 x2 )/3 = (2 (7.990))/3 = 1.996

The Solution vector ~x = [ 1.996 7.990 2.997]T

Page 3 of 9
MTH 510 Midterm Test - (Solutions)

8 3. Consider the matrix A


Marks
2 3
5 6 10
A = 40 4 35
1 2 5
a) (4 points) Find the LU decomposition of A and write L and U in the space
provided.

Solution: Forward elimination


2 3 2 3 2 3
5 6 10 5 6 10 5 6 10
40 4 35 40 4 3 5 40 4 3 5
1 2 5 R3 (1/5)R1 0 0.8 3 R3 ( 0.8/4)R2 0 0 3.6

Therefore the lower and upper triangular matrices are


2 3 2 3
1 0 0 5 6 10
L=4 0 1 05 U = 40 4 3 5
0.2 0.2 1 0 0 3.6

b) (4 points) Using the decomposition of A, find the 3rd column of A 1.

Solution: Forward substitution Ld = b


2 32 3 2 3
1 0 0 d1 0 d1 = 0
40 1 05 4d2 5 = 405 =) d2 = 0
0.2 0.2 1 d3 1 d3 = 1 0.2d1 + 0.2d2 = 1

Backward substitution Ux = d
2 32 3 2 3 14.5
5 6 10 x1 0 x1 = (6x2 10x3 )/5 = 5(3.6) = 0.8056
40 4 3 5 4 5 4 5
x2 = 0 =) x2 = ( 3x3 )/(4) = 0.20833
0 0 3.6 x3 1 x3 = 1/3.6 = 0.2777

The 3rd column of the A 1

2 3
0.8056
A 1
=4 0.2083 5
0.2777

Page 4 of 9
MTH 510 Midterm Test - (Solutions)

6 4. Using Newton Raphson’s method find the root of the non-linear equation
Marks

x
e = ln x 1

with three significant digits accuracy. Start with initial guess x0 = 2.5.

Solution: Newton-Raphson’s Iteration Formula;

f (xi ) e xi ln(xi ) + 1
xi+1 = xi = xi
f 0 (xi ) e xi 1/xi
First iteration starting with initial guess x0 = 2

e2.5 + ln(2.5) + 1 0.1658


x1 =2.5 2.5
= 2.5 + = 2.5 + (0.3439) = 2.8439
e + 1/2.5 (0.4828)
Ea =|x1 x0 | = |2.8439 2.5| = 0.3439
Ea 0.3439
"a = 100% = 100% = 12.1%
x1 2.8439

The specified error for 3 significant digit accuracy "s = 0.5 ⇥ 102 3
% = 0.05%

It xi f (xi ) f 0 (xi ) f (xi )/f 0 (xi ) xi+1 Error Ea Rel. "a %


1 2.5 0.165794 -0.48208 -0.34391 2.843911 0.343911 12.09288
2 2.843911 0.013017 -0.40983 -0.03176 2.875674 0.031763 1.104553
3 2.875674 9.1E-05 -0.40412 -0.00023 2.875899 0.000225 0.007827
Stop iteration "a = 0.008% < "s = 0.05%

The root is 2.875899 with a max relative error of "a = 0.007%

Page 5 of 9
MTH 510 Midterm Test - (Solutions)

10 5. Use Jacobi method to solve


Marks

2 32 3 2 3
1 15 2 x1 2
40 2 6 5 4 x2 5 = 4 8 5
5 1 0 x3 1
using the initial trial vector x0 = [0 0 1]T . Iterate until all component-wise approx-
imate percentage relative errors fall below 5%.

Solution:
The coefficient matrix is not SDD, rearrange the rows;
2 32 3 2 3
5 1 0 x1 1
4 1 15 25 4 x2 5 = 4 2 5
0 2 6 x3 8

Now the coefficient matrix is strictly diagonal dominant and therefore should con-
verge for any initial starting vector.

The iteration formula:


1⇣ ⌘
xk+1
1 = 1 + xk2
5
1 ⇣ ⌘
xk+1
2 = 2 + xk1 + 2xk3
15
1⇣ ⌘
xk+1
3 = 8 + 2xk2
6
1st Iteration with x0 = [0 0 1]

(1) 1 0.2 0
x1 = = 0.2; ✏x1 = 100% = 100%
5 0.2
(1) 2 + 0 + 2(1) 4 (0.2667 0)
x2 = = = 0.2667; ✏x2 = 100% = 100%
15 15 0.2667
(1) 8 + 2(0) 1.3333 1
x3 = = 1.3333; ✏x3 = 100% = 0.25%
6 1.3333

⇥ ⇤
2nd Iteration with x(1) = 0.2 0.2667 1.3333

Page 6 of 9
MTH 510 Midterm Test - (Solutions)

(2) 1 1.2667 0.2533 0.200


x1 = (1 + 0.2667)) = = 0.2533; ✏x1 = 100% = 21.1%
5 5 0.2533
(2) 1 |0.2533 0.2667|
x2 = (2 + (0.2000) + 2(1.3333)) = 0.3244 ✏x2 = 100% = 18%
15 0.2533
(2) 1 1.4222 1.3333
x3 = (8 + 2(0.2667))) = 1.4222; ✏x3 = 100% = 6%
6 1.4222
Summery of the iteration

Iteration 0 1 2 3
x1 0 0.2 0.2533 0.2649
x2 0 0.2667 0.3244 0.3398
x3 1 1.3333 1.4222 1.4415
" x1 100 21.1 4.4
" x2 100 18 4.5
" x3 0.25 6 1.3
The maximum component relative error max |"axi | < "s = 5%, stop!! the iteration.

The solution x = [0.2649 0.3398 1.4415]T with a maximum component wise er-
ror of 4.5% after 3 iterations.

Page 9 of 9

You might also like