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

NUMERICAL METHODS PRACTICE PROBLEMS

B RAJADURAI-2018111086
April 2020

1
Roll number -2018111086 Numerical methods

1 Part A
1.Give the Newton’s iterative formula for finding square root of a number N.
Solution:
let
xk − N = 0
taking,
f (x) = xk − N
we have.
f 0 (x) = kxk−1 (1)
then gives
f (xn )
xn+1 = xn −
f 0 (xn )
xn k − N
xn+1 = xn − (2)
kxn k−1

2. State the condition for convergence of the Gauss-Seidel method.


Solution:
The condition for convergence of the Gauss-Seidel method is that the given system of equations should
form a diagonally dominant matrix.
3. Rewrite the equation x3 + x2 − 1 = 0in a suitable form to apply iteration method of finding the root.
(Do NOT find the root).
Solution:
here

f (0) = − 1
f (1) =1

Thus the root lies between 0 and 1.


Lets rewrite the given Equation as:
x2 (x + 1) − 1 =0
1
x2 =
x+1
  21
1
x=
x+1
1
x =(x + 1)− 2
Lets consider this an f or iteration
1
φ(x) =(x + 1)− 2
1 3
φ0 (x) = − (x + 1)− 2
2
1 3
φ0 (0) = − (1)− 2
2
φ0 (0) = − 0.5
|φ0 (0)| =0.5 < 1
1 3
φ0 (1) = − (2)− 2
2
φ0 (1) = − 0.1768
|φ0 (1)| =0.1768 < 1

BRD Page 2
Roll number -2018111086 Numerical methods

∴ |φ0 (x)| < 1 the function converges.


Thus the suitable equation for iteration is

1
x = (x + 1)− 2

4. Give an advantage and a disadvantage of using Jacobi’s method to find the eigenvalues of a matrix.
Solution:
Advantage This method forms a Diagonal Matrix from which Eigen values can be taken easily.
Disadvantage A disadvantage of Jacobi’s method is that the element annihilated by a transformation,
may not remain zero during the subsequent transformations. Given’s suggested a reduction which does
not disturb zeros already formed. But instead of leading to a diagonal matrix as in Jacobi’s method, the
Given’s method leads to a tri-diagonal matrix. The eigenvalues and eigen vectors of the original matrix
have to be found from those of the tri-diagonal matrix.
5. Give the Newton’s divided difference table for the following data:
Solution:

x 1 2 3 4
y 22 30 82 106
Solution:

x y ∆y ∆2 y ∆3 y
1 22
8
2 30 22
52 -12
3 82 -14
24
4 106
6. State the Newton’s backward difference interpolation formula.
Solution:

p p(p + 1) 2 p(p + 1)(p + 2) 3 p(p + 1)(p + 2)(p + 3) 4


f (x) =f (0) + ∆f (0) + ∆ f (0) + ∆ f (0) + ∆ f (0)..........
1! 2! 3! 4!
x − xn
W here p =
h
∆yn =yn − yn−1

7. State Newton’s divided difference formula.


Solution:

f (x) =y0 + (x − x0 )∆y0 + (x − x0 )(x − x1 )∆2 y0 + (x − x0 )(x − x1 )(x − x2 )∆3 y0 + ......


yn − yn−1
where ∆yn−1 =
xn − xn−1

8. What are the scenarios where you can use (i) Newton’s forward difference formula and (ii) Newton’s
backward difference formula?
Solution:
If the value is close to the value at top we use in newton’s difference table we use forward difference.

If the value is close to the value at Bottom values in newton’s difference table we use Reverse dif-
ference method.

BRD Page 3
Roll number -2018111086 Numerical methods

dy
9.Give the Newton’s forward difference interpolation formula used to obtain dx x=x0

Solution:

1 2p − 1 2 3p2 − 3p + 2 3
f 0 (x) = ∆y + ∆ y+ ∆ y + ...............
h 2! 3!
(x − x0 )
W here p =
h

10. State the Gaussian 2-point and 3-point formulae for evaluating an integral. Solution:

2 P ointf ormula
Z 1    
−1 1
f (x)dx =f √ +f √
−1 3 3
3 P ointf ormula
Z 1 r ! r !!
5 3 3 8
f (x)dx = f − +f + f0
−1 9 5 5 9

dy
11. Give the Newton’s backward difference interpolation formula to obtain dx x=xn

Solution:

1 2p + 1 2 3p2 + 3p + 2 3
f 0 (x) = ∆y + ∆ y+ ∆ y + ...............
h 2! 3!
(x − xn )
W here p =
h

12. State the Simpson’s 3/8th rule and its order of convergence.
Solution:
3h
Tn = [f (x0 , y0 ) + f (x2 , y2 ) + 3f (x1 , y1 )]
8
Order of convergence is
3h5
 
(y IV )
80

13. Given y 0 = x + y, y(1) = 0 , find y(1.1) using Taylor’s series upto second order terms with h = 0.1
Solution:

y1 =0
0
By T ayolr s series
(x − x0 )2 00
f (x) =y0 + (x − x0 )y00 + y0 + ............
2!
y 0 =x + y =⇒ 1
y 00 =y 0 + 1 =⇒ 2
(0.1)2
f (1.1) =0 + (0.1)1 + 2
2!
f (1.1) =0.110

BRD Page 4
Roll number -2018111086 Numerical methods

14. State the modified Euler’s formula.


Solution:
The modified Euler’s formula is as follows

h h
yn+1 =yn + hf (xn + , yn + f (xn , yn ))
2 2

15. State the Euler’s formula for solving first order differential equation.
Solution:
In general Euler’s Formula is as

yn+1 =yn + hf (xn , yn )


16. What is the limitation of using Taylor’s series method?
Solution:
Limitation
This is a single step method and works well so long as the successive derivatives can be calculated easily.
If (x, y) is somewhat complicated and the calculation of higher order derivatives becomes tedious, then
Taylor’s method cannot be used gainfully.
17. Give the standard 5-point formula for solving Poisson equation
Solution:
For Laplace equation of form uxx + uyy = h2 Gi,j
1
ui,j = (ui−1,j + ui+1,j + ui,j−1 + ui,j+1 − 2h2 Gi,j )
4

18. Give the Crank-Nicholson implicit scheme of solving 1-Dimensional heat conduction equation.
Solution:
For the following one- dimensional Heat equation

ut =α utt
General f ormula is
−αui−1,j+1 + 2 + 2αui,j+1 − αui+1,j+1 = − αui−1,j + 2 − 2αui,j + αui+1,j

19. Give the diagonal 5-point formula for solving Laplace equation.
Solution:
For Laplace equation of form uxx + uyy = 0
1
ui,j = (ui−1,j + ui+1,j + ui,j−1 + ui,j+1 )
4

20. State the Schmitd scheme of solving 1-dimensional heat conduction equation and the condition for
its validity.
Solution:

c2
W e have α =k
h2
1
such thts α <
2
In general bendre − Schmit f ormula :
ui−1,j − 2ui,j + ui+1,j
uxx =
h2

BRD Page 5
Roll number -2018111086 Numerical methods

2 Part B
 
1 2 6
1. using Gauss-jordan method, Find the inverse of following matrix: A= 2 5 15
6 15 46
solution
The Augmented matrix [A,I] is given as

 
1 2 6 : 1 0 0
[A, I] = 2 5 15 : 0 1 0
6 15 46 : 0 0 1

 
1 2 6 : 1 0 0
[A, I] = 0 1 3 : −2 1 0
0 3 1 : −6 0 1
 
1 0 0 : 5 −2 0
= 0 1 3 : −2 1 0
0 0 1 : 0 −3 1
 
1 0 0 : 5 −2 0
= 0 1 0 : −2 10 −3
0 0 1 : 0 −3 1
[A, I] =[I, A−1 ]

 
5 −2 0
A−1 =  −2 10 −3 (ANS)
0 −3 1

is the Inverse of given matrix A by Gauss-Jordan method

2. Using Gauss- Seidel method , solve

10X + 2Y − Z = 9
X + 10Y − Z = −22
−2X + 3Y + 10Z = 22

solution
let, the above equations can be rewritten as
9 − 2Yn + Zn
Xn+1 = (1)
10
−22 − Xn+1 + Zn
Yn+1 = (2)
10
22 + 2Xn+1 − 3Yn+1
Zn+1 = (3)
10

BRD Page 6
Roll number -2018111086 Numerical methods

Let X0 = Y0 = Z0 = 0
1st iteration:

X1 = 0.9
Y1 = −2.29
Z1 = 3.06

2nd iteration:

X2 = 1.0513
Y2 = −1.9984
Z2 = 3.0098

3rd iteration:

X3 = 0.998
Y3 = −1.9989
Z3 = 2.9994

4th iteration:

X4 = 0.9998
Y4 = −2.0000
Z4 = 3.0000

5th iteration:

X5 = 1.0000
Y5 = −2.0000
Z5 = 3.0000

thus the required solution is 1 , -2 , 3

3. Solve X 3 = 2X + 5 for the least positive root using fixed point iteration.
Solution
Let

f (X) = X 3 − 2X − 5
f (0) = −5
f (1) = −6
f (2) = −1
f (3) = 16

BRD Page 7
Roll number -2018111086 Numerical methods

Thus the least positive root of above equation lies between 2 and 3.
let us consider a function φ

φ = (2X + 5)1/3

(2X + 5)−2/3
φ0 =
3

φ02 = 0.1540

φ03 = 0.600

hence |φ0 (x)| < 1, the given equation is converging.

hence the required equation for iteration is

X = (2X + 5)1/3 (1)

required itertion equation is

Xn+1 = (2Xn + 5)1/3

let x0 = 0

X1 = 1.7100
X2 = 2.0344
X3 = 2.0854
X4 = 2.0932
X5 = 2.0943
X6 = 2.0945
X7 = 2.0945

Hence X7 X6 < 0.0001,


The least positive root of given equation is 2.0945.

BRD Page 8
Roll number -2018111086 Numerical methods

 
0 1 1
4. using Gauss-jordan method, Find the inverse of following matrix: A= 1 2 0
3 −1 −4
solution
The Augmented matrix [A,I] is given as

 
0 1 1 : 1 0 0
[A, I] = 1 2 0 : 0 1 0
3 1 −4 : 0 0 1
 
1 2 0 : 0 1 0
[A, I] = 0 1 1 : 1 0 0
3 1 −4 : 0 0 1
 
1 2 0 : 0 1 0
= 0 1 1 : 1 0 0
0 −5 −4 : 0 −3 1
 
1 2 0 : 0 1 0
= 0 1 1 : 1 0 0
0 0 1 : 5 −3 1
 
1 2 0 : 0 1 0
= 0 1 0 : −4 −3 −1
0 0 1 : 5 −3 1
 
1 1 0 : 8 −5 2
= 0 1 0 : −4 −3 −1
0 0 1 : 5 −3 1
[A, I] =[I, A−1 ]

 
8 −5 2
A−1 =  −4 −3 −1 (1)
5 −3 1

(1) is the Inverse of given matrix A by Gauss-Jordan method

5 Using Gauss- jacobi method , solve

X + 1Y + 54Z = 110
27X + 6Y − Z = 85
6X + 15Y + 2Z = 72

solution
let, the above equations can be rewritten as

27X + 6Y − Z = 85
6X + 15Y + 2Z = 72
X + 1Y + 54Z = 110

BRD Page 9
Roll number -2018111086 Numerical methods

85 − 6Yn + Zn
Xn+1 = (1)
27
72 − 6Xn − 2Zn
Yn+1 = (2)
15
110 − Xn − Yn
Zn+1 = (3)
54
Let X0 = Y0 = Z0 = 0
1st iteration:

X1 = 3.1481
Y1 = 4.800
Z1 = 2.0370

2nd iteration:

X2 = 2.1569
Y2 = 3.2692
Z2 = 1.8899

3rd iteration:

X3 = 2.4917
Y3 = 3.6853
Z3 = 1.9366

4th iteration:

X4 = 2.4009
Y4 = 3.5451
Z4 = 1.9226

5th iteration:

X5 = 2.4316
Y5 = 3.5836
Z5 = 1.9269

6th iteration:

X6 = 2.4232
Y6 = 3.5704
Z6 = 1.9256

BRD Page 10
Roll number -2018111086 Numerical methods

7th iteration:

X7 = 2.4260
Y7 = 3.5740
Z7 = 1.9260

8th iteration:

X8 = 2.4253
Y8 = 3.5728
Z8 = 1.959

9th iteration:

X9 = 2.4255
Y9 = 3.5730
Z9 = 1.9260

5th iteration:

X10 = 2.4255
Y10 = 3.5730
Z10 = 1.9260

hence X1 0 X9 = Y1 0 Y9 = Z1 0 Z9 < 0.0001,


Thus the required solution is 2.4255 , 3.5730 ,1.9260.

 √ 
√1 2 √2
6. using Jacobi’s method, Find the Eigen values and Eigen vectors of matrix A=  2 √3 2
2 2 1
solution
Here the largest Non-Diagonal element is a13 = a31 = 2 and also a11 = a33 = 1.

2a13
∴ tan2θ =
a11 − a13
2(2)
=
1−1
tan2θ =∞
π
2θ =
2
π
θ=
4

BRD Page 11
Roll number -2018111086 Numerical methods

Then the corresponding orthogonal matrix is given as

cos π4 0 -sin π4
  

B1 =  0  1 0 
sin π4 0 cos π4

 √1
0 − √12

2
= 0 1 0
√1 0 √1
2 2

we know that B1−1 =Ḃ 01

√1 0 √1
 
2 2
B1−1 =  0 1 0
− √12 0 √1
2

F irst transf ormation matrix D1 =B1−1 A B1


 √1 √
0 √12
  √1
0 − √12
 
2 √ 1 2 √2 2
= 0 1 0  2 √3 2  0 1 0
− √12 0 √12 2 2 1 √1
2
0 √1
2
 3 
√3
 √1 √1
√ 2 0 −

√2 √2  2 2
= 2 3 2  0 1 0
1 1 1 1

2
0 √2 √
2
0 √
2
 
3 2 0
D1 = 2 3 0
0 0 −1

Now the largest non-diagonal element is a12 = a21 = 2 and a11 = a22 = 3

2a12
∴ tan2θ =
a11 − a22
2(2)
=
2−2
tan2θ =∞
π
2θ =
2
π
θ=
4

 √1
− √12 0

2
B2 =  √12 √1
2
0
0 0 1

BRD Page 12
Roll number -2018111086 Numerical methods

We have B2−1 = B20 second transformation matrix D2 = B2−1 D1 B2

√1 √1
  √1
0 − √12 0
  
2 2 3 2 0 2
= − √12 √1
2
0 2 3 1
0  √2 √1
2
0
0 0 1 0 0 −1 0 0 1
√5 √5 0 √1 1
− 2 0
   √

2 2 2
= − √12 √1
2
0  √1 2
√1 0
2
0 0 −1 0 0 1
 
5 0 0
D2 = 0
 1 0 (ANS)
0 0 −1

∴The required Eigen values are 5,1,-1

corresponding Eigen vectors are columns of B

W here B =B1 B2

 √1
− √12
  √1
0 − √12 0

2 2
= 0 1 0  √12 √1
2
0
√1 0 √1 0 0 1
2 2

√1 − 21 − √12
 
 √12 √1 0
= 2 2  (ANS)
1
2 − 21 √1
2

7.using Newton’s forward interpolation , find a polynomial of degree 4 degree takes the following values
also find the value of y(1):
Solution:
X 2 4 6 8 10
Y(X) 0 0 1 0 0
solution Newton’s difference are calculated as follows,

x y=f(x) ∆y ∆2 y ∆3 y ∆4 y
2 0
0
4 0 1
1 -3
6 1 -2 4
-1 1
8 0 -1
0
10 0
Here we take,

x0 = 2 h=2

BRD Page 13
Roll number -2018111086 Numerical methods

X−2
p= 2

∴ using Newton’s forward interpolation method

p p(p − 1) 2 p(p − 1)(p − 2) 3 p(p − 1)(p − 1)(p − 3)


f (x) =f (0) + ∆f (0) + ∆ f (0) + ∆ f (0) +
1! 2! 3! 4!

x−2x−41 x−2x−4x−61 x−2x−4x−6x−8 1


=0 + 0 + (1) + (−3) + (4)
2 2 2 2 2 2 6 2 2 2 2 24

x2 − 6x + 8 (x2 − 6x + 8)(x − 6) (x3 − 12x2 + 48x − 48)(x − 8)


= + +
8 −16 64

=(0.125)(x2 − 6x + 8) − (0.0625)(x3 − 12x2 + 44x − 48) + (0.0156)(x4 − 20x3 + 140x2 − 400x + 384)

f (0) =0.0156x4 − 0.3745x3 + 3.059x2 − 9.74x + 9.9904 (1)

(1)is the required 4 degree polynomial equation.


When x = 1

y(1) =0.0156(14 ) − 0.3745(13 ) + 3.059(12 ) − 9.74(1) + 9.9904

=2.9505

∴ y(1) =2.9505

8.Using Lagrange’s interpolation formula, find the value of y(10) from the following table:

x 5 6 9 11
y(x) 12 13 14 16
solution:
By Lagrange’s formula:

(x − 6)(x − 9)(x − 11) (x − 5)(x − 9)(x − 11) (x − 5)(x − 6)(x − 11)


f (x) = (12) + (13) + (14)+
(−1)(−4)(−6) (1)(−3)(−5) (4)(3)(−2)
( (x−5)(x−6)(x−9)
(6)(5)(2) (16))

when x =10

(4)(1)(−1) (5)(1)(−1) (5)(4)(−1) (5)(4)(1)


y(10) = (12) + (13) (14) + (16)
−24 15 −24 60

13 35 16
=2 − + +
3 3 3

y(10) =14.6667

∴ y(10)=14.6667

BRD Page 14
Roll number -2018111086 Numerical methods

9. Fit a natural cubic spline curve that passes through (0,1), (1,4), (2,0) and (3, –2).
Solution:
(i) h = 1
(ii)M0 = M3 = 0

6
(iii)M0 + 4M1 + M2 = (yi−1 − 2yi + yi+1 )
h2
4M1 + M2 =6(y0 − 2y1 + y2 )
=6(1 − 8)
4M1 + M2 = − 42 (1)
M1 + 4M2 + M3 =6(y1 − 2y2 + y3 )
=6(4 − 2)
M1 + 4M2 =12 (2)
On solving (1) and (2) we get
M1 = − 12
M2 =6

(iv) when i = 0

(xi+1 − x)3 (x − xi )3 Mi Mi+1


f (x) = Mi + Mi+1 + (xi+1 − x)(yi − + (x − xi )(yi+1 − )
6h 6h 6h 6h
1 1 12
f (x) = (1 − x)3 (0) + (x − 0)3 (−12) + (1 − x)(1 − 0) + (x − 0)(4 + )
6 6 6
3
f (x) = − 2x + 5x + 1 (ANS)

When i = 1

(x2 − x)3 (x − x1 )3 M1 M2
f (x) = M1 + M2 + (x2 − x)(y1 − + (x − x1 )(y2 − )
6 6 6 6
(2 − x)3 (x − 1)3 −12 6
= (−12) + (6) + (2 − x)(4 − + (x − 1)(0 − )
6 6 6 6
3 3
= − 2(2 − x) + (x − 1) + (2 − x)(6) + (x − 1)(−1)
= − 2(8 − x3 − 12x + 6x2 ) + (x3 − 3x2 + 3x − 1) + 12 − 6x − x + 1
f (x) =3x3 − 15x2 + 20x − 4 (ANS)

when i =2

(x3 − x)3 (x − x2 )3 M2 M3
f (x) = M2 + M3 + (x3 − x)(y2 − + (x − x2 )(y2 − )
6 6 6 6
(3 − x)3 6
= (6) + (3 − x)(0 − + (x − 2)(−2)
6 6
=(3 − x)3 + (3 − x)(−1) − 2x + 4
=27 − x3 − 27x + 9x2 − 3 + x − 2x + 4
f (x) = − x3 + 9x2 − 28x + 28 (ANS)

BRD Page 15
Roll number -2018111086 Numerical methods

R 2.6 R 4.4 dxdy


10. Use Simpson’s rule to evaluate 2 4 xy with ∆x = 0.2∆y = 0.3.
Solution:

1
f(x)= xy

y 4.0 4.2 4.4


2.0 0.1250 0.1190 0.1136 T0
2.3 0.1087 0.1035 0.0988 T1
2.6 0.0962 0.0916 0.0874 T2

Simpson’s one Third rule:

h
T0 = [f (x0 , y0 ) + f (x2 , y2 ) + 4f (x1 , y1 )]
3
0.2
= [0.125 + 0.1136 + 4(0.119)]
3
T0 =0.0476
0.2
T1 = [0.1087 + 0.0988 + 4(0.1035)]
3
T1 =0.0414
0.2
T1 = [0.0962 + 0.0874 + 4(0.0916)]
3
T1 =0.0367
k
I = [T0 + T2 + 4T1 ]
3
I =0.0250 (ANS)

Simpson’s three-eight rule:

3h
T0 = [f (x0 , y0 ) + f (x2 , y2 ) + 3f (x1 , y1 )]
8
0.6
= [0.125 + 0.1136 + 3(0.119)]
8
T0 =0.0447
0.6
T1 = [0.1087 + 0.0988 + 3(0.1035)]
8
T1 =0.0389
0.6
T1 = [0.0962 + 0.0874 + 3(0.0916)]
8
T1 =0.0344
3k
I = [T0 + T2 + 3T1 ]
8
I =0.0220 (ANS)

BRD Page 16
Roll number -2018111086 Numerical methods

R 1.5 2
11. Evaluate 0.2 e−x dx using the Gaussian 3-point quadrature.
Solution:
To change the limit

1 1
x = (b − a)u + (b + a)
2 2
1 1
= (1.3)u + (1.7)
2 2
1
x = [1.3u + 1.7]
2
1 2x − 1.7
dx = (1.3)du u=
2 1.3

x → 0.2 to 1.5
u → -1 to 1

Z 1.5 Z 1
2 1 2 1
e−x dx = e−( 2 (1.3u+1.7)) (1.3)du
0.2 −1 2
1.3 − 1 (1.3u+1.7)2
= e 4 du
2
1 2
F (u) =e− 4 (1.3u+1.7)

r !
3 1
√3 2
r !
3 1
√3 2
F − =e− 4 (1.3(− 5 )+1.7) F =e− 4 (1.3( 5 )+1.7)
5 5
r ! r !
3 3
F − =0.8869 F =0.1601
5 5

F (0) =0.4855

" " r ! r !# #
Z 1
1.3 1.3 5 3 3 8
F (u)du = F − +F + f (0)
2 −1 2 9 5 5 9
 
1.3 5 8
= (0.0889 + 0.1601) + (0.4855)
2 9 9
Z 1
1.3
F (u)du =0.6586
2 −1
Z 1.5
2
e−x dx =0.6586 (ANS)
0.2

BRD Page 17
Roll number -2018111086 Numerical methods

12. The population of a certain town is given below. Find the rate of growth of the population in
1961 and 1971:
x 1931 1941 1951 1961 1971
Y 40.62 60.8 79.95 103.56 132.65
Solution:
The difference table is as follows:

x y ∆y ∆2 y ∆3 y ∆4 4y
1931 40.6
20.2
1941 60.8 -1.05
19.15 5.51
1951 79.95 4.46 -4.49
23.61 1.02
1961 103.56 5.48
29.09
1971 13.65

(x − xn )
p=
h
x − 1971
∴p=
10

we have

3p2 + 3p + 2 3
 
0 1 2p + 1 2
f (x) = ∆y + ∆ y+ ∆ y + ...............
h 2! 3!
whenx =1971 p = o
1 1 2
f 0 (1971) = [∆y + ∆2 y + ∆3 y + ...............]
h 2! 3!
1 1 2 1
= [(29.09) + (5.48) + (1.03) + (−4.49)]
10 2 3 4
1
= (31.0489)
10
f 0 (1971) =3.1048

when x = 1961 let xn be 1961 so that P=0

1 1 2
f 0 (1971) = [∆y + ∆2 y + ∆3 y + ...............]
h 2! 3!
1 1 2
= [(23.61) + (4.46) + (5.51)+
10 2 3
1
= (27.6767)
10
f 0 (1971) =2.7676

thus the growth rate at year 1961 and 1971 are 2.7676 and 3.1048 respectively.

BRD Page 18
Roll number -2018111086 Numerical methods

R5
13. From the following data, evaluate 1
logxdx using Simpson’s 1/3rd rule: Solution:

x 1 1.5 2 2.5 3 3.5 4 4.5 5


R5
1
logxdx 0.0000 0.4055 0.6931 0.9163 1.0986 1.2528 1.3863 1.5041 1.6094
By Simpson 1/3r d rule:

Z 5
h
logxdx = [(y1 + y5 ) + 4(y1.5 + y2.5 + y3.5 + y4.5 ) + 2(y2 + y3 + y4 )]
1 3
hereh =0.5
0.5
= [(1.6094 + 0) + 4(0.4055 + 0.9163 + 1.2528 + 1.5041) + 2(0.6931 + 1.0986 + 1.5041)]
3
0.5
= (24.2805)
3
Z 5
logxdx =4.0468 (ANS)
1

14. Using fourth order Runge-Kutta method obtain y(0.2) correct to 4 decimal places, given that
dy
dx = x + y, y(0) = 1 with h = 0.1.
solution:

x0 =0 y0 = 1
k1 =hf (x0 , y0 )
=0.1f (0, 1)
=0.1(0.1)
k1 =0.1

h k1
k2 =hf (x0 + , y0 + )
2 2
=0.1f (0.05, 1.05)
=0.1(1.1)
k1 =0.11
h k2
k3 =hf (x0 + , y0 + )
2 2
=0.1f (0.05, 1.055)
=0.1(1.105)
k3 =0.110
k4 =hf (x0 + h, y0 + k3 )
=0.1f (0.1, 1.2105)
=0.1211
1
k = [k1 + 2K2 + 2k3 + k4 ]
6
=0.1104
yn+1 =yn + k
y( 0.1) =y( 0) + 0.1104
y( 0.1) =1.104

BRD Page 19
Roll number -2018111086 Numerical methods

To find y( 0.2)

x1 =0.1 y1 = 1.1104
k1 =hf (x1 , y1 )
=0.1f (0.1, 1.1104)
=0.1(1.2100)
k1 =0.1210
h k1
k2 =hf (x1 + , y1 + )
2 2
=0.1f (0.15, 1.1709)
=0.1(1.3212)
k1 =0.1321
h k2
k3 =hf (x1 + , y1 + )
2 2
=0.1f (0.15, 1.1765)
=0.1(1.3273)
k3 =0.1327
k4 =hf (x1 + h, y1 + k3 )
=0.1f (0.2, 1.2431)
=0.1443
1
k = [k1 + 2K2 + 2k3 + k4 ]
6
=0.1325
yn+1 =yn + k
y( 0.2) =y( 0.1) + 0.1325
y( 0.2) =1.104 + 0.1325
y( 0.2) =1.2429 (ANS)

dy
15.Given dx = y + ex , y(0) = 0, find y(0.2) and y(0.4) by modified Euler’s method by taking h = 0.2
Solution:

f(x,y) = y + ex
The Modified Euler’s formula is

h h
yn+1 =yn + hf (xn + , yn + f (xn , yn ))
2 2

To find y(0.2)
here x0 = y0 = 0 and h = 0.2

0.2 0.2
y1 (0.2) =y0 + 0.2f (x0 + , y0 + f (x0 , y0 ))
2 2
y1 (0.2) =0.2f (0.1, 0.1)
y1 (0.2) =2.410 (ANS)

BRD Page 20
Roll number -2018111086 Numerical methods

To find y(0.4)
here x1 = 0.2y1 = 2.410 and h = 0.2

0.2 0.2
y2 (0.4) =y1 + 0.2f (x1 + , y1 + f (x1 , y1 ))
2 2
y2 (0.4) =0.2410 + 0.2f (0.3, 0.3141)
y2 (0.4) =0.5738 (ANS)

dy
16. Given that dx = 12 (1 + x2 )y 2 , y(0)=1 , y(0.1) = 1.06 , y(0.2) = 1.12, y(0.3) = 1.21
Find y(0.4) and y(0.5) Miline’s Predictor and corrector Method.
Solution:
In General Predicted*(1) and corrected(2) Miline’s Formula

(P ) 4 0 0
yn+1 =yn−3 + h[2yn−2 − yn−1 + 2yn0 ] (1)
3
(C) 1 0
yn+1 =yn−1 + h[yn−1 + 4yn0 + yn+1
0
] (2)
3

To find y(0.4)

(P ) 4
y4 (0.4) =y0 + h[2y10 − y20 + 2y30 ]
3
=1 + 0.1333[2(0.5674) − (0.6525) + 2(0.7979)]
(P )
y4 (0.4) =1.2770

(C) 1
y4 (0.4) =y2 + h[y20 + 4y30 + y40 ]
3
(C)
y4 (0.4) =1.12 + 0.033[0.6525 + 2(0.7979) + 0.9458]
(c)
y4 (0.4) =1.2781 (ANS)

To find y(0.5)

(P ) 4
y5 (0.5) =y1 + h[2y20 − y30 + 2y40 ]
3
=1.06 + 0.1333[2(0.6525) − (0.7979) + 2(0.9474)]
(P )
y5 (0.5) =1.3802

(C) 1
y5 (0.5) =y3 + h[y30 + 4y40 + y50 ]
3
(C)
y5 (0.5) =1.21 + 0.033[0.7979 + 2(0.9475) + 1.1906]
(C)
y5 (0.5) =1.4007 (ANS)

BRD Page 21
Roll number -2018111086 Numerical methods

17.Using 4th order R K Method Obtain y(0.2)


Given that :

y” =xy 02 − y 2 y(0) = 1y 0 (0) = 0

Solution:
Let y’= z
then z’= xz 2 − y 2

When x = 0 , y = 1 , z = 0
h = 0.2

f (x, y, z) =z φ(x, y, z) =xz 2 − y 2


k1 =0.2f (0, 1, 0) l1 =0.2φ(0, 1, 0)
k1 =0 l1 = − 0.2

h k1 l1 h k1 l1
k2 =hf (x0 + , y0 + , z0 + ) l2 =hφ(x0 + , y0 + , z0 + )
2 2 2 2 2 2
=0.2f (0.1, 1, −0.1) =0.2φ(0.1, 1, −0.1)
k2 = − 0.02 l2 = −0.1998

h k2 l2 h k2 l2
k3 =hf (x0 + , y0 + , z0 + ) l3 =hφ(x0 + , y0 + , z0 + )
2 2 2 2 2 2
=0.2f (0.1, 0.99, −0.0999) =0.2φ(0.1, 0.99, −0.0999)
k3 = − 0.02 l3 = − 0.1958

k4 =hf (x0 + h, y0 + k3 , z0 + l3 ) l4 =hφ(x0 + h, y0 + k3 , z0 + l3 )


=0.2f (0.20.98, −0.1958) =0.2f (0.20.98, −0.1958)
= − 0.0392 = − 0.1905
1 1
k = [k1 + 2K2 + 2k3 + k4 ] l = [l1 + 2l2 + 2l3 + l4 ]
6 6
k = − 0.0199 y = − 0.1970

yn+1 =yn + k
y( 0.2) =y( 0) − 0.0199
y( 0.2) =1 − 0.0199
y( 0.2) =0.9801 (ANS)

BRD Page 22
Roll number -2018111086 Numerical methods

dy
18. Given dx = y−x
y+x with initial condition y(0) = 1, find y(0.1) by Euler’s method in 5 steps.
Solution:
In general Euler’s Formula is as

yn+1 =yn + hf (xn , yn )

here x0 = 0y0 = 1
dy
f(x,y) = dx
since we have find in five steps let h=0.02
step 1

n =0
y1 =y0 + hf (x0 , y0 )
=1 + (0.02)f (0, 1)
y1 =1.02

step 2

n =1
y2 =y1 + hf (x1 , y1 )
=1.02 + (0.02)f (0.02, 1.02)
y2 =1.0392

step 3

n =2
y3 =y2 + hf (x2 , y2 )
=1.0392 + (0.02)f (0.04, 1.0392)
y3 =1.0577

step 4

n =3
y4 =y3 + hf (x3 , y3 )
=1.0577 + (0.02)f (0.06, 1.0577)
y4 =1.0756

step 5

n =4
y5 =y4 + hf (x4 , y4 )
=1.0756 + (0.02)f (0.08, 1.0756)
y5 =1.0928

∴ y(0.1) =1.0928 (ANS)

BRD Page 23
Roll number -2018111086 Numerical methods

19. If dx x
dy = 2e y, y( 0) = 2, then find y(4) using Adams-Bashforth predictor corrector method by
calculating y( 1), y( 2)y( 3) using modified Euler’s method.
Solution:

y 0 =2ex y y(0) =2 x0 = 0 y0 = 2

h h
yn+1 =yn + hf (xn + , yn + f (xn , yn ))
2 2
f or y1 (0.1)
h h
y1 =y0 + hf (x0 + , y0 + f (x0 , y0 ))
2 2
0.1 0.1
y1 =2 + (0.1)f (0 + , y0 + f (0, 2))
2 2
y1 =2 + 0.1f (0.05, 2.2)
y1 =2.4626
f or y2 (0.2)
0.1 0.1
y2 =2.4626 + (0.1)f (0.1 + , 2.4626 + f (0.1, 2.4626))
2 2
y2 =2.4626 + 0.1f (0.15, 2.7348)
y2 =3.0981
f or y3 (0.3)
0.1 0.1
y3 =3.0981 + (0.1)f (0.2 + , 3.0981 + f (0.2, 3.0981))
2 2
y3 =3.0981 + 0.1f (0.15, 2.7348)
y3 =3.9909

Adams-Bashforth predictor corrector method to find f(0.4)

(p) h
yn+1 =yn + (55yn0 − 59yn−1
0 0
− 37yn−2 0
− 9yn−3 )
24
(p) 0.1
y4 =y3 + (55y30 − 59y20 − 37y10 − 9y 0 0)
24
=3.9909 + 1.2978
(p)
y4 =5.2882 (predicted)

For corrected

(c) h
yn+1 =yn + (9y 0 + 9yn0 − 5yn−1
0 0
+ yn−2 )
24 n+1
(c) 0.1
y4 =yn + (9y40 + 9y30 − 5y20 + y10 )
24
=3.9909 + 1.3097
(c)
y4 =5.3006 (ANS)

The value of y(0.4)= 5.3006

BRD Page 24
Roll number -2018111086 Numerical methods

20. Using Crank-Nicolson method, solve the initial boundary value problem ut = utt ; u(0,t) = u(1,t) =
0, t ≥ 0 ; u(x, 0) = sinx, 0 ≤ x ≤ 1 by taking h = 1/3 and k = 1/36.
Solution:

ut =utt
c2 =1
c2
α =k
h2
1 1
α =( ) 1 2
36 ( 3 )
1
α=
4

The general Crank Nicholson Formula is;

−αui−1,j+1 + 2 + 2αui,j+1 − αui+1,j+1 = − αui−1,j + 2 − 2αui,j + αui+1,j

1 1 1 1 1 1
− ui−1,j+1 + 2 + ui,j+1 − ui+1,j+1 = − ui−1,j + 2 − ui,j + ui+1,j
4 2 4 4 2 4
5 1 3
ui,j+1 = (ui−1,j+1 + ui−1,j+1 + ui−1,j + ui−1,j ) + ui,j
2 4 2

1 2
t 0 3 3 1
0 0.0000 0.8660 0.8660 0.0000
1/36 0.0000 u1 u2 0.0000
2/36 0.0000 u3 u4 0.0000
When i =1 and j=0

5 1 3
u1,1 = (u0,0 + u0,1 + u2,0 + u2,1 ) + u1,0
2 4 2
5 1 3
u1 = (0 + 0.8660 + u2 + 0) + 0.8660
2 4 2
10u1 − u2 =6.0620 (1)

When i =2 and j=0

5 1 3
u2,1 = (u1,0 + u1,1 + u3,0 + u3,1 ) + u2,0
2 4 2
5 1 3
u2 = (0.8660 + 0 + u1 + 0) + 0.8660
2 4 2
10u2 − u1 =6.0620 (2)

On solving (1) and (2),


We get

u1 =0.6740 u2 =0.6736 (ANS)

BRD Page 25
Roll number -2018111086 Numerical methods

When i =1 and j=1

5 1 3
u1,2 = (u0,1 + u2,1 + u0,2 + u2,2 ) + u1,1
2 4 2
5 1 3
u3 = (0 + 0.6736 + 0 + u2 ) + 0.6740
2 4 2
10u3 − u4 =4.7176 (3)

When i =2 and j=1

5 2 3
u2,2 = (u,1 + u3,1 + u1,2 + u3,2 ) + u2,1
2 4 2
5 1 3
u4 = (0 + 0.6740 + 0 + u2 ) + 0.6736
2 4 2
10u4 − u3 =4.7156 (4)

On solving (3) and (4),


We get

u3 =0.5242 u4 =0.5240 (ANS)

21. Using finite difference method, solve the boundary value problem: y”+ y =x, y(0)= 0, y(1) = 2 to
find y(0.25), y(0.5) y(0.75). Solution:

giventhat yi ” + yi − xi =0 (1)
yi−1 − 2yi + yi−1
butwehave yi ” =
h2
yi−1 − 2yi + yi−1
(1) =⇒ + yi − xi =0
h2
here
h =0.25
when i =1
16(y2 − 2y1 + y0 ) + y1 − x1 =0
∴ y0 =0
16y2 − 31Y1 − 0.25 =0 (2)

W hen i =2
16(y3 − 2y2 + y1 ) + y2 − x2 =0
16y3 − 31y2 + 16y1 =0.5 (3)

W hen i =3
16(y4 − 2y3 + y2 ) + y3 − x3 =0
16y4 − 31y3 + 16y2 =0.75
∴ y4 =2
−31y3 + 16y2 = − 31.25 (4)

BRD Page 26
Roll number -2018111086 Numerical methods

On solving Eqn. (1), (2),(3)

y1 (0.25) =0.54427
y2 (0.50) =1.07015
y3 (0.75) =1.56040

22.Using Leibmann’s method with Gauss-Seidel iterations, solve the Poisson equation
uxx + uyy = −10(x2 + y 2 − 5) in the domain 0 ≤ x, y ≤ 1 subject to the conditions u = 0 at x = 0,
x=1, y = 0 u = 1 at y = 1, 0 ≤ x ≤1 with mesh size h=1/3 in both the directions.
Solution:
Given the Poisson equation is uxx + uyy = −10(x2 + y 2 − 5)
Boundary conditions are
u = 0 at x = 0, x = 1, y = 0
u = 1 at y = 1
h = 13 in both directions.
1 2
t\x 0 3 3 1
0 0.0000 0.0000 0.0000 0.0000
1
3 0.0000 u1 u2 0.0000
2
3 0.0000 u 3 u4 0.0000
1 0.0000 1.0000 1.0000 0.0000
By Poisson approximation Equation

1
ui,j = (ui−1,j + ui+1,j + ui,j−1 + ui,j+1 − 2h2 Gi,j )
4  
1 −10 2
ui,j = (ui−1,j + ui+1,j + ui,j−1 + ui,j+1 − (x + y 2 − 5) (1)
4 9
W hen i = 1 j = 1
  
1 −10 1 1
u1,1 = (u0,1 + u2,1 + u1,0 + u1,2 − + −5 )
4 9 9 9
  
1 −10 1 1
u1 = (0 + u2 + u3 + 0 − + −5 )
4 9 9 9
4u1 =u2 + u3 + 6.1728
4u1 − u2 − u3 =5.8025 (2)

W hen i = 2 j = 1
  
1 −10 1 4
u2,1 = (u1,1 + u3,1 + u2,0 + u2,2 − + −5 )
4 9 9 9
4u2 − u1 − u4 = 6.1728 (3)

W hen i = 1 j = 2
  
1 −10 4 1
u1,2 = (u0,1 + u2,1 + u1,0 + u1,2 − + −5 )
4 9 9 9
4u3 − u1 − u4 = 7.1728 (4)

BRD Page 27
Roll number -2018111086 Numerical methods

W hen i = 2 j = 2
  
1 −10 4 4
u2,2 = (u1,1 + u3,1 + u2,0 + u2,2 − + −5 )
4 9 9 9
4u4 − u2 − u3 = 7.5432 (5)

Let us rewrite these equations as:


1
u1 = (u2 + u3 + 5.8025)
4
1
u2 = (u1 + u4 + 6.1728)
4
1
u3 = (u1 + u4 + 7.1728)
4
1
u4 = (u2 + u3 + 7.5432)
4

By gauss seidel iteration:


Let u2 = u3 = u4 = 0 for the Zeorth iteration

1st Iteration
u1 =1.4506 u2 =1.9059
u3 =2.1559 u4 =2.9030

2nd Iteration
u1 =2.4661 u2 =2.8850
u3 =3.1350 u4 =3.1460

3rd Iteration
u1 =2.9556 u2 =3.0686
u3 =3.3186 u2 =3.4826

4th Iteration
u1 =3.0474 u2 =3.1757
u3 =3.4257 u2 =3.5362

5th Iteration
u1 =3.1010 u2 =3.2025
u3 =3.4525 u2 =3.5496

6th Iteration
u1 =3.1144 u2 =3.2092
u3 =3.4592 u2 =3.5525

BRD Page 28
Roll number -2018111086 Numerical methods

Thus the required solution is

u1 =3.1
u2 =3.2
u3 =3.5
u2 =3.5

23. Solve utt = uxx upto t = 0.5 with a step-size of 0.1 along x-direction subject to the conditions
u(0,t) = 0,u(1,t) = 0,ut (x,0) = 0, u(x,0) =10+ x(1+ x).
Solution

c2 =1 h =0.1
k
α= αc =1
h
h
k=
c
0.1
α =1 k=
1
αc = 1 =0.1

The required formula is:

ui,j−1 =ui+1,j + ui+−,j − ui,j−1


u(0, t) = u(1, t) =ut (x, 0) = 0
u(x, 0) =10 + x(1 − x)

y\x 0.00 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0
0.0 0.00 10.09 10.16 10.21 10.24 10.25 10.24 10.21 10.16 10.09 0.00
0.1 0.00 5.080 10.15 10.2 10.23 10.24 10.23 10.2 10.15 5.080 0.00
0.2 0.00 0.06 5.12 10.17 10.20 10.21 10.20 10.17 5.12 0.06 0.00
0.3 0.00 0.04 0.08 5.12 10.15 10.16 10.15 5.12 0.08 0.04 0.00
0.4 0.00 0.02 0.04 0.06 5.080 10.09 5.080 0.06 0.04 0.02 0.00
0.5 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00

BRD Page 29
Roll number -2018111086 Numerical methods

24. Using Bendre-Schmidt method, solve the initial boundary value problem ut = uxx ;
u(0, t) = u(1, t) = 0; u(x,0) = sin, 0 ≤ x ≤1 by taking h = 0.2 and the mesh ratio parameter α =1/ 2 .
Solution:

ut =U xx
c2
W ehaveα =k
h2
herec =1
1 12
=k
2 0.022
k =0.02
U singbendre − Schmitmethod :
ui−1,j − 2ui,j + Ui+1,j
uxx =
h2

We get the following data:

y\x 0 0.2 0.4 0.8 1


0.0000 0.5877 0.9511 0.9511 0.5877 1.0000
0.0200 0.4756 0.7695 0.7695 0.4756 1.0000
0.0400 0.3848 0.6226 0.6226 0.3848 1.0000
0.0600 0.3113 0.5037 0.5037 0.3113 1.0000
0.0800 0.2519 0.4075 0.4075 0.2519 1.0000
0.1000 0.2056 0.3295 0.3295 0.2056 1.0000

25. Using Leibmann’s method with Gauss-Seidel iterations, solve the Laplace equation uxx + uyy = 0
for the following mesh by performing 5 iterations:Solve:

1000 1000 1000 1000


2000 u1 u2 500
2000 u3 u4 0
1000 500 0 0

Solution: To get the initial values assume u4 = 0;


1
u1 = (1000 + 1000 + 2000 + 0) (DFPF)
4
=1000
1
u2 = (u1 + 500 + 1000 + 0) (SFPF)
4
=625
1
u3 = (2000 + 500 + u1 + 0) (SFPF)
4
=875
1
u4 = (u2 + u3 + 0 + 0) (SFPF)
4
=375

By Gauss-Seidel Iteration:

BRD Page 30
Roll number -2018111086 Numerical methods

1
un+1
1 = (1000 + 2000 + un3 + un2 )
4
n+1 1 n+1
u2 = (u1 + 500 + 1000 + un4 )
4
1
u3 = (2000 + 500 + un4 + un+1
n+1
1 )
4
1
un+1
4 = (un+1 + un+1 + 0 + 0)
4 2 3

1st Iteration

1
u11 = (1000 + 2000 + 875 + 625)
4
=1125
1
u12 = (1125 + 500 + 1000 + 375)
4
=750
1
u13 = (2000 + 500 + +375 + 1125)
4
=1000
1
u14 = (750 + 1000 + 0 + 0)
4
=473.5

2nd Iteration

u21 =1187.5
u22 =781.25
u23 =1031.25
u24 =453.125

3rd Iteration

u31 =1203.125
u32 =789.0625
u33 =1039.0625
u34 =457.0313

4th Iteration

u41 =1207.0313
u42 =791.0157
u43 =1041.0157
u44 =458.0079

BRD Page 31
Roll number -2018111086 Numerical methods

5th Iteration

u51 =1208.0079
u52 =791.504
u53 =1041.5040
u54 =458.252

∴ Solution is

u1 =1208
u2 =791
u3 =1041
u4 =458

BRD Page 32

You might also like