Sie sind auf Seite 1von 8

university

of south africa

COS2633 NUMERICAL METHODS 1 October/November 2014

SOLUTIONS

QUESTION 1

(1.1)

(a) Write the Newton formula (recurrence relation) to approximate 3 5. (3)

3 3 3
5 is a solution to the equation x = 5, or equivalently, x − 5 = 0. So if we apply the Newton’s
method to the function f defined by f (x) = x3 − 5, provided x0 is given, we obtain the relation
3
(xn ) − 5
(1) xn+1 = xn − 2 .
3 (xn )
(b) Perform three iterations of the Newton algorithm as given in (1.1(a)), starting at x0 = 2. (3)
Applying the formula in equation (1), we have:
Iteration 1:
3
(x0 ) − 5 23 − 5
x1 = x0 − 2 = 2 − 3(2)2 = 1.75
3 (x0 )
Iteration 2:
3
(x1 ) − 5 (1.75)3 − 5
x2 = x1 − 2 = 1.75 − = 1.7109
3 (x1 ) 3(1.75)2
Iteration 3:
3
(x2 ) − 5 (1.7109)3 − 5
x3 = x2 − 2 = 1.7109 − = 1.7100
3 (x2 ) 3(1.7109)2

x2 y2
(1.2) The ellipse defined by + = 1 and the parabola defined by y = x2 − 2x − 4 intersect at four
16 9
distinct points.
(a) Write the Newton formula (recurrence relation) in the form of a system of equations, to approxi- (6)
mate any of the intersection points.
We define
y2
 2 
x
F (x, y) = 16 + 9 − 1
x2 − 2x − y − 4
The Jacobian is
x 2y
 
JF (x, y) = 8 9
2x − 2 −1
and its inverse is
− 2y
 
−1 1 −1
(JF (x, y)) =−x x
9 .
8 + 49 y(x − 1) −2x + 2 8

The Newton’s formula is given by


   
xn+1 x −1
= n − (JF (xn , yn )) F (xn , yn )
yn+1 yn

[TURN OVER]
2 COS2633
OCTOBER/NOVEMBER 2014

and if we let Dn = det JF (xn , yn ) = − x8n − 49 yn (xn − 1), we obtain


 " x2 2
#
− 2y9n yn
    
xn+1 xn 1 −1 n
+ − 1
= − xn 16 9
yn+1 yn Dn −2xn + 2 8 x2n − 2xn − yn − 4
 2
y2
  
x
−1 16n + 9n − 1 − 2y9n x2n − 2xn − yn − 4
  
xn 1 
= −  2 2
 
yn Dn (−2xn + 2) xn + yn − 1 + xn x2n − 2xn − yn − 4
16 9 8

and therefore the required recurrence relation is


h  2
y2
 i
x
xn+1 = xn − D1n −1 16n + 9n − 1 − 2y9n x2n − 2xn − yn − 4
 2
y2
h  i
x
yn+1 = yn − D1n (−2xn + 2) 16n + 9n − 1 + x8n x2n − 2xn − yn − 4

(b) Perform two iterations of the Newton algorithm as given in (1.2(a)), starting with (x0 , y0 ) = (4, 1). (4)
The results are as follows:
Iteration 1: We have D0 = − x80 − 94 y0 (x0 − 1) = − 84 − 49 × 1 (4 − 1) = − 116 . Then
h  2 2
 i
x y
x1 = x0 − D10 −1 160 + 90 − 1 − 2y90 x20 − 2x0 − y0 − 4

h  2 2
 i
6 4
= 4 + 11 −1 16 + 19 − 1 − 29 42 − 8 − 1 − 4
= 11833 = 3.5758
 2
y2
h  i
x
y1 = y0 − D10 (−2x0 + 2) 160 + 90 − 1 + x80 x20 − 2x0 − y0 − 4
h  2 2
 i
6 4
= 1 + 11 (−2 × 4 + 2) 16 + 19 − 1 + 84 42 − 8 − 1 − 4
16
= 11 = 1.4545
118
Iteration 2: We have D1 = − x81 − 94 y1 (x1 − 1) = − 33 4 16 118 471

− 9 × 11 33 − 1 = − 223 . Then
8
x21 y12
h   i
x2 = x1 − 1
D1 −1 16 + 9 −1 − 2y91 x21 − 2x1 − y1 − 4
118 2 16 2
" ! #
32 
  
118 223 33 11 118 2 118 16
− 1 − 11

= 33 + 471 −1 + 33 −2× 33 − 11 −4
16 9 9
717
= = 3.5320
203
 2
y12
h  i
x x1
y2 = y1 − D11 (−2x1 + 2) 161 + 9 −1 + 8 x21 − 2x1 − y1 − 4
118 2 16 2
" ! #
118 
  
33 11 118 2
= 11 + 471 −2 × 118
16 223 33 118 16
 
33 + 2 + −1 + 33 −2× 33 − 11 −4
16 9 8
1133
= 804 = 1.4092
(c) What is the error of this process, given the fact that the exact solution is (3.5316, 1.4088)? (1)
The error of the process is
p
e = (3.5316 − 3.5320)2 + (1.4088 − 1.4092)2 = 5.6569 × 10−4

[17]

QUESTION 2

(2.1) By means of Gaussian Elimination on a larger augmented matrix A ... I where I is the identity (7)
h i

matrix of appropriate size, and by using exact calculation, find the inverse of the matrix
 
1 2 3
A = 2 3 4 .
3 4 1

[TURN OVER]
3 COS2633
OCTOBER/NOVEMBER 2014

We have the augmented matrix:


..
 
1 2 3 . 1 0 0
 .. 
Row2 ← Row2 − 2Row1
2 3 4 . 0 1 0
  Row ← Row − 3Row
.. 3 3 1
3 4 1 . 0 0 1

.
 
1 2 3 .. 1 0 0
.
0 −1 −2 ..
 
 −2 1 0  Row ← Row − 2Row
. 3 3 2
0 −2 −8 .. −3 0 1
..
 
1 2 3 . 1 0 0
 .. 
0 −1 −2 . −2 1 0
  Row ← 1 Row
.. 3 −4 3
0 0 −4 . 1 −2 1
..
 
1 2 3 . 1 0 0 
 ..  1
Row2 ← −1 (Row2 + 2Row3 )
0
 −1 −2 . −2 1 0 
..
0 0 1 . −1/4 1/2 −1/4
..
 
1 2 3 . 1 0 0  Row1 ← 1 (Row1 − 2Row2 − 3Row3 )
1
 .. 
0 1 0
 . 5/2 −2 1/2 
..
0 0 1 . −1/4 1/2 −1/4
..
 
1 0 0 . −13/4 5/2 −1/4
.
0 ..
 
0
 1 5/2 −2 1/2 
..
0 0 1 . −1/4 1/2 −1/4
Therefore the inverse of A is  
−13/4 5/2 −1/4
A−1 =  5/2 −2 1/2 
−1/4 1/2 −1/4

(2.2) The SOR algorithm, with relaxation parameter ω for solving a linear system Ax = b is defined by the
formula  
i−1 n
[k] [k−1] ω X [k]
X [k−1] 
xi = (1 − ω)xi + bi − aij xj − aij xj .
aii j=1 j=i+1

(a) Perform two iterations of the SOR algorithm to solve the system (4)
    
1 2 x 8
=
3 1 y 9

with ω = 0.5 starting with (x0 , y0 ) = (1, 1).


The results are as follows:
Iteration 1:
ω
x1 = (1 − ω)x0 + [b1 − a12 y0 ]
a11
0.5
= (1 − 0.5)1 + [8 − 2 × 1]
7
1
= 2

[TURN OVER]
4 COS2633
OCTOBER/NOVEMBER 2014

ω
y1 = (1 − ω)y0 + [b2 − a21 x1 ]
a22
0.5 
9 − 3 × 72

= (1 − 0.5)1 +
1
= − 14
Iteration 2:
ω
x2 = (1 − ω)x1 + [b1 − a12 y1 ]
a11
 0.5 
(1 − 0.5) 72 + 8 − 2 × − 41

=
1
= 6
ω
y2 = (1 − ω)y1 + [b2 − a21 x2 ]
a22
0.5
(1 − 0.5) − 14 +

= [9 − 3 × 6]
37
1
= −8

(b) Does the approach in question (2.2(a)) give the exact solution? Justify your answer. (2)
No, because it is an iterative method and it only gives closer approximations to the exact solution,
which in this case is (2, 3).

(2.3) What is the essential difference between direct and iterative methods for solving linear systems? (3)
Direct methods give exact solutions and are more suitable for small scale systems, whereas iterative
methods give approximations to the solutions and are more suitable for large scale systems.
[16]

QUESTION 3

Consider data given by the table


x 0.5 1 1.5 2
f (x) 1.7832 3.5598 7.3875 15.2328
f 0 (x) 2.3105 5.1354 10.8080 21.7318

(3.1) By means of divided differences, determine the Hermite interpolating polynomial of least degree that (7)
matches the data points.
The divided difference table is given as follows:

xi yi f [1] f [2] f [3] f [4] f [5] f [6] f [7]


0.5 1.7832
0.5 1.7832 2.3105
1.0 3.5598 3.5532 2.4854
1.0 3.5598 5.1354 3.1644 1.3580
1.5 7.3875 7.6554 5.0400 1.8756 0.5176
1.5 7.3875 10.8080 6.3052 2.5304 0.6548 0.1372
2.0 15.2328 15.6906 9.7652 3.4600 0.9296 0.1832 0.0307
2.0 15.2328 21.7318 12.0824 4.6344 1.1744 0.2448 0.0411 0.0069

Hence the (seventh degree - 7 = 2 × 4 − 1) Hermite interpolating polynomial is given by

H7 (x) = 0.0069x7 − 0.0248x6 0.1369x5 + 0.0190x4 + 0.6497x3 + 0.7510x2 + 1.0238x + 0.9972

(3.2)

(a) Use the Least Squares method to approximate f with a function of the form kxm . (5)

[TURN OVER]
5 COS2633
OCTOBER/NOVEMBER 2014

Using natural logarithm to linearise the exponential form yields

ln y = ln k + m ln x

If we let z = ln y, a0 = ln k and a1 = m, we obtain

z = a0 + a1 ln x

which means we are fitting the new variable z as a linear combination of ln x. This yields the two
normal equations to be solved for a0 and a1
P P
(2) P N a0 + aP 1 ln xi = P ln Yi
a0 ln xi + a1 (ln xi )2 = ln xi ln Yi

where N = 4. From our data, we get


2
P P
(3) P ln xi = 0.4055 P (ln xi ) = 1.1253
ln Yi = 6.5714 ln xi ln Yi = 2.2977

Solving our normal equations yields

a0 = 1.4903
a1 = 1.5048

Note that a1 = m; since a0 = ln k, we deduce that

k = ea0 = 4.4384

Therefore our approximate function is

y = 4.4384x1.5048

(b) What is the sum of square errors for the approximation in (3.2(a))? (1)
X
S= (yi − kxm 2
i ) = 8.3852

(3.3) Approximate f (1.25) using each of the methods in (3.1) and (3.2). (2)

• With Hermite interpolation, f (1.25) ≈ 5.1221.


• With the kxm approximation, f (1.25) ≈ 6.2096

sin x
(3.4) Assuming the values in the table above are generated by the function f defined by f (x) = xex + , (2)
x
determine the absolute error of the approximation at 1.25 in each case.

• With Hermite interpolation, the absolute error is |f (1.25) − 5.1221| ≈ 1.1830 × 10−5 .
• With the kxm approximation, |f (1.25) − 6.2096| ≈ 1.0875.

[17]

[TURN OVER]
6 COS2633
OCTOBER/NOVEMBER 2014

QUESTION 4

Consider
1
( 
2 x3 − 3x + 2 if 0≤x<2
S(x) = 1

3 2
2 x − 12x + 45x − 46 if 2≤x≤4

(4.1)
(a) Show that S is a cubic spline. (3)
00
S is not a natural cubic spline because S is not continuous at 2.
(b) Is it a natural cubic spline? (2)
It is not a natural cubic spline because it is not a cubic spline in the first place.

(4.2) The equation of the quadratic Bezier curve joining P0 (x0 , y0 ) to P2 (x2 , y2 ) using control point P1 (x1 , y1 )
is given by
x(t) = x0 + 2(x1 − x0 )t + (x2 − 2x1 + x0 )t2

t ∈ [0, 1] .
y(t) = y0 + 2(y1 − y0 )t + (y2 − 2y1 + y0 )t2

(a) Determine the equation of the quadratic Bezier curve joining (0, 1) to (2, 2) using 34 , 1 .

(3)
Straightforward substitution leads to
8 2 2

x(t) = 3t − 3t t ∈ [0, 1] .
y(t) = 1 + t2
8

(b) Determine the equation of the quadratic Bezier curve joining (2, 2) to (4, 3) using 3, 5 . (3)
Straightforward substitution leads to

x(t) = 2 + 43 t + 32 t2

t ∈ [0, 1] .
y(t) = 2 + 6t − 5t2

(c) Connecting the two Bezier curves gives a curve C. Is the curve C smooth at (2, 2)? Justify your (3)
answer.
No, because the points 43 , 1 , (2, 2) and 83 , 5 are not aligned. Indeed, at the end points, the
 

Bezier curve follows the tangent from the end point to the corresponding guide point, and the
tangents would be the same (meaning the curve would be smooth) if the points were aligned.
[14]

QUESTION 5

(5.1) Consider the integral


Z 2
I= x ln(x + 2)dx.
−1

(a) Approximate I using the composite trapezoidal rule with h = 1. (3)


Let f (x) = x ln(x + 2). Then
1
I≈ [f (−1) + 2f (0) + 2f (1) + f (2)] = 2.4849
2
3
(b) Approximate I using the Simpson 8 rule. (4)
With f as defined above, we have
3
I≈ [f (−1) + 3f (0) + 3f (1) + f (2)] = 2.2757
8

[TURN OVER]
7 COS2633
OCTOBER/NOVEMBER 2014

3
(c) The errors due to composite trapezoidal rule and Simpson 8 rule are respectively given by (4)
b − a 2 00 3h5 (4)
h f (ξ) and f (ξ).
12 80
Estimate the errors from the two methods used above in (5.1(a)) and (5.1(b)).
We have
1 2 2 12
f 00 (x) = + and f (4) (x) = +
x + 2 (x + 2)2 (x + 2)3 (x + 2)4
Then the error due to composite trapezoidal rule is
1 00
e1 = f (ξ)
4
3
and the error due to Simpson 8 rule is
3 (4)
e2 = f (ξ)
80

(5.2) We need to estimate by means of a three-term Gaussian quadrature the integral


Z 4
J= 3x5 dx.
0

(a) The third Legendre polynomial is given by L3 (x) = x3 − 53 x.


(i) Determine the roots t0 , t1 and t2 of L3 (x). (3)
The roots are √ √
15 15
x0 = − ; x1 = 0; x2 =
5 5
(ii) For each value of i, determine the coefficient (6)
1 2
x − xj
Z Y
ci = dx.
−1 j=0 i − xj
x
j6=i

From straightforward calculation, we have


5 8 5
c0 = ; c1 = ; c2 = .
9 9 9
(b) By means of an appropriate change of variable x = mt + p, rewrite J in the form (3)
Z 1
J= g(t)dt
−1

where g is a function to be determined.


From straightforward calculation, we have m = p = 2, and thus g(t) = mf (mt + p) = 2f (2t + 2) =
48(t + 1)3 where f (x) = 3x5 . Thus
Z 1
J = 48 (t + 1)3 dt.
−1

(c) From the results obtained in (5.2(a)) and (5.2(b)), estimate J by means of a three-term Gaussian (2)
quadrature.
J = c0 g(x0 ) + c1 g(x1 ) + c2 g(x2 ) = 2048
(d) Why is the result from (5.2(c)) exact? (1)
Because the n−term Gaussian quadrature has degree of precision 2n − 1, in particular the three-
term Gaussian quadrature has degree of precision 3×3−1 = 5 and we are integrating a polynomial
of degree 5.
[26]
8 COS2633
OCTOBER/NOVEMBER 2014

TOTAL MARKS: [90]


c
UNISA 2014

Das könnte Ihnen auch gefallen