Beruflich Dokumente
Kultur Dokumente
Chapter # 2
Solution of Algebraic and Transcendental Equations
Notes:
(1) Linear Equations: An equation in which the highest power of variable is “One”
is called linear equation. e.g.
x+2=0
2x + 10 = 0 etc
(2) Non-Linear Equation: Equation involving higher powers of a variable is called
Non-Linear Equation.e.g.
x3 + 4x2 + 10x + 3 = 0
x4 + 9x2 + 20 = 0
Sinx = 6x + 2
ex – lnx = 20
e-x – Sinx = 0
(4) There are two methods of solving Non-Linear and Transcendental Equations.
Numerical Method.
Analytical Method
Type No # 1
KEY
.f(x) = (Given)
d
Find f ′(x) i.e. f ( x) and put x = xn in f(x) and f ′(x ) .
dx
If f(x) changes its sign for any two close values of x, the interval will be that one
and the small value of the interval will be x0.
f ( xn )
x n +1 = x n − to get x1, x2, x3,………………
f ′( x n )
If the two values of x are approximately equal then we stop the iteration, and the
last value of x will be a positive root of f(x).
Q.21/Page # 47
Apply any numerical method to calculate the square root of 3 up to six decimal places.
Ans:
Square root of 3 = 3
Let x = 3
X2 = 3 ⇒ x2 – 3 = 0
d d
f (x) = ( x2 – 3) ⇒ f ′(x ) = 2x ⇒ f ′( x n ) = 2 xn
dx dx
f ( xn )
x n +1 = x n −
f ′( x n )
2 2 2 2
xn − 3 2xn − xn + 3 xn + 3
x n +1 = x n − = = ----------> (1)
2 xn 2 xn 2xn
To find x0
As f(x) = x2 – 3
2
x0 + 3 1 + 3 4
For n = 0, equation (1) ⇒ x1 = = = =2
2 x0 2 2
2
x1 + 3 2 2 + 3 4 + 3 7
For n = 1, equation (1) ⇒ x 2 = = = = = 1.75
2 x1 2(2) 4 4
2
x 2 + 3 (1.75) 2 + 3 6.0625
For n = 2, equation (1) ⇒ x 3 = = = = 1.732149
2 x2 2(1.75) 3.5
2
x 3 + 3 (1.732149) 2 + 3
For n = 3, equation (1) ⇒ x 4 = = = 1.7320508
2 x3 2 x3
We stop the iteration because the value of x3 and x4 are approximately equal. Hence
the root is x = 1.7320508. (ANSWER)
Q.16/page # 47
Find the +ve real root of xex = 1, using Newton Raphson method.
Use x0=1.
Ans:
d
⇒ f ′(x ) = ( xe x −1) = xex + ex.1 – 0
dx
⇒ f ′(x ) = xex + ex
⇒ f ′( x n ) =exn ( xn + 1)
f ( xn ) x n e xn − 1
x n +1 = xn − => x n +1 = x n − xn
f ′( x n ) e ( x n + 1)
x n e xn ( x n + 1) − ( x n e xn − 1)
x n +1 =
e xn ( x n + 1)
2 2
x n e xn + x/ n e xn − x/ n e xn + 1 x n e xn + 1
⇒ x n +1 = ⇒ x n +1 = xn ---------> (1)
e xn ( x n + 1) e ( x n + 1)
2
x0 e x0 + 1
x1 = x0
e ( x0 + 1)
⇒ x1 = 0.6839
After 3 iterations the values of x2 and x3 coincide. Hence the root is x = 0.5672.
(ANSWER)
TYPE NUMBER 2
SECANT METHOD
Key
The formula for Secant Method is:
x n −1 f ( x n ) − x n f ( x n −1 )
x n +1 =
f ( x n ) − f ( x n −1 )
Interval (x0, x1) will be given or individually the values of x0 and x1 will be given,
if not then 1st we find the values of x0 and x1 by putting x = 0, 1, 2, 3, 4,
………….. to get the change in sign for f(x).
Finally put n = 1, 2, 3, 4, …………….. in the formula. The root will be that for
which two values of x coincide.
(ii) To solve xx = 10 by Secant Method.
xn xn −1
Let f(x) = xx – 10 ⇒ f(xn) = x n − 10 ⇒ f(xn-1) = xn−1 − 10
Using Secant Method
x n −1 f ( x n ) − x n f ( x n −1 )
x n +1 = --------> (1)
f ( x n ) − f ( x n −1 )
x3 x2
x 2 .x 3 − 10 x 2 − x 3 .x 2 + 10 x 3 2.2609( 2.3923 ) 2.3923 − 10( 2.2609 ) − 2.3923( 2.2609 ) 2.2609 + 10( 2.3923 )
x4 = =
x3
x3
− x2
x2
( 2.3923 ) 2.3923 − ( 2.2609 ) 2.2609
182189 − 22.6090 − 15.1290 + 23.9230 4.4039
x4 = = = 2.4546
8.0582 − 6.3240 1.7342
For n = 4, equation (1) ⇒
x4 x3
x 3 .x 4 − 10 x 3 − x 4 .x 3 + 10 x 4 2.3923( 2.4546 ) 2.4546 − 2.4546( 2.3923 ) 2.3923 − 10( 2.3923 ) + 10( 2.4546 )
x5 = =
x4
x4
− x3
x3
( 2.4546 ) 2.4546 − ( 2.3923 ) 2.3923
21.6802 − 19.7798 − 23.9230 + 24.5460 2.5234
x5 = = = 2.5126
9.0625 − 8.0582 1.0043
We stop the iteration because the values of x4 and x5 are approximately equal. Hence
the root is x = 2.5126 (ANSWER)
TYPE NO. 3
METHOD OF FALSE POSITION
OR
REGULA FALSI METHOD
KEY
(1) Formula for False position is
f ( xL )[ xR − xL ]
xi = x L +
f ( xL ) − f ( xR )
Where xL = Lower value of the interval
xR = Upper value of the interval
(2) The function f(x) will be given.
(3) The interval will be given, if not then put x = 0, 1, 2, 3,………….in f(x).
If f(x) changes its sign for any two consecutive values of x, the interval will be
that one.
(4) We put all these values in the formula (1) to get xi.
(5) Find f(xi), if f(xi) is nearly equal to ‘ZERO’ stop the iteration process otherwise
proceed by reducing the interval in the following ways:
Q.14/Page # 46
To solve the question f(x) = sinx – 0.5x by using the False position Method.
From the previous question the root lies in the interval (1,2) ⇒ xL = 1, xR= 2
Now f(xL) = f(1) = sin1 – 0.5(1) = 0.8414 – 0.5 = 0.3414
And f(xR) = f(2) = sin2 – 0.5(2) = 0.9093 – 1 = -0.0907
Using the formula for Regula Falsi Method
f ( x L )[ x R − x L ]
xi = x L +
f ( x L ) − f ( x R ) --------->(1)
0.3414 [ 2 − 1] 0.3414
xi = 1 + =1 + = 1 + 0.7900 = 1.79
0.3414 + 0.0907 0.4321
now f(xi) = f(1.79) = sin(1.79) -0.5(1.79) = 0.9760-0.895=0.081
(Not nearly equal to zero. So we proceed)
We have the following situation
.f(xL) = 0.3414 (+ve)
.f(xR) = - 0.0907 (-ve)
.f(xi) = 0.081 (+ve)
⇒ xi = xL = 1.79, xR = 2
⇒ f(xi) = 0.081 = f(xL) [i.e. we replace xL by xi and f(xL) by f(xi) in (1)]
equation (1) ⇒
0.081[2 − 1.79 ] 0.0170
xi = 1.79 + = 1.79 + = 1.79 + 0.0990 = 1.8890
0.081 + 0.0907 0.1717
Now f(xi) = f(1.8890) = sin(1.8890) – 0.5(1.8890) = 0.0053
Since the value of f(xi) is nearly equal to Zero ⇒ the root is x = 1.8890 Answer
TYPE NO. 4
Prepared by: Inayat Ullah Lecturer in Mathematics Edwardes College Peshawar
Numerical Analysis 9
BISECTION METHOD
OR
BOLZANO METHOD
KEY
• The value of f(x) will be given.
• Find those values of x for which f(x) changes its sign. The root will lie in that
interval.
• Find the mid point of the interval and find f(x) for that value of x.
• Reduce the interval for which f(x) changes its sign [Already discussed in Type #3]
and go on till the value of f(x) nearly equal to zero. This will be your root.
Q.11/Page # 46
Find a positive real root of f(x) = sinx – x/2, with x1 = π /2 and x2 = π using Bisection
Method. Do six iterations.
Ans: Given function is: f(x) = sinx – x/2 -------->(1)
1st we find the interval for which f(x) changes its sign.
Since x1 = π /2 and x2 = π
Therefore f(x1) = f(π /2) = sinπ /2 -π /2/2 = 1 – π /4 = 1 – 0.785 = 0.215 (+ve)
And f(x2) = f(π ) = sinπ - π /2 = 0 – 1.571 = -1.571(-ve)
As f(x) changes its sign for x1 = π /2 and x2 = π
⇒ the interval is (π /2, π ) or (1.571, 3.142)
Now we find the mid point of x1 and x2
x1 + x 2 1.571 + 3.142
Mid point = x = = = 2.356
2 2
CHAPTER # 3
Prepared by: Inayat Ullah Lecturer in Mathematics Edwardes College Peshawar
Numerical Analysis 11
LINEAR EQUATIONS
Consider the system of equations.
2x1 – 3 x2 + 7x3 = 10
8x1 + 2 x2 + 5x3 = 12
4x1 – 3x2 – 9 x3 = 16
All the above equations involve three unknowns i.e. x1, x2, x3 with maximum power
“ONE”. So this system of equations is called system of linear equations. We can write
it in matrix form as:
2 −3 7 x1 10
8 5
2 x 2 = 12
4 −3 −9
x 3
16
i.e. Ax = c
2 −3 7
5
Where A = 8 2 and is called coefficient matrix
4 −3 −9
10
c = 12 which is called column matrix or column vector.
16
Augmented Matrix is:
2 −3 7 10
5 12
Ac = 8 2
4 −3 −9 16
• Direct Method.
• Iterative Method.
• Crammer’s Rule
• Gauss Elimination Method.
• Gauss Jordan Method.
• Method of Inversion.
• Choleski’s Factorization Method.
TYPE NO. 1
CRAMMER’S RULE
KEY
Q.3/Page # 84
Solve the system of equations by using Crammer’s Rule
2.16x1 + 3.75x2 + 0.98x3 = 8.68
4.12x1 + 1.67x2 + 7.21x3 = 0.25
3.14x1 + 4.02x2 + 2.16x3 = 9.16
Ans:
The system can be written in matrix form as:
2.16 3.75 0.98 x1 8.68
4.12 1.67 7.21 x = 0.25
2
3.14 4.02 2.16 x 3 9.16
i.e. Ax = c
⇒ Solution exists.
Type No. 2
Gauss Elimination Method
KEY
• Write the system of equations in matrix form.
• Write the matrix form in tabular form.
• Change the co-efficient matrix to Echelon form.
• Find the values of unknowns. i.e. x1, x2, x3,…………..
• Solution is: x = ( x1 , x2 , x3 )
T
Q.2/Page # 83
Solve by Gauss Elimination Method
2x1 – x2 + 3x3 – x4 = 7
x1 – x2 + 4x3 – 2x4 = 5
3x1 + 2x2 + x3 + 4x4 = 31
4x1 – 3x2 + 3x3 – 3x4 = -5
Ans:
Writing the system of equations in matrix form
2 − 1 3 − 1 x1 7
1 − 1 4 − 2 x 5
2 =
3 2 1 4 x3 3 1
4 − 3 3 − 3 x4 − 5
Ax = c
Using Gauss Elimination Method, We write the system in tabular form as:
Row
Rows X1 X2 X3 X4 C
Explanation
R1 2 -1 3 -1 7 Eq(1)
R2 1 -1 4 -2 5 Eq(2)
R3 3 2 1 4 31 Eq(3)
R4 4 -3 3 -3 -5 Eq(4)
R20 ⇒ x4 = 60/12 = 5
⇒ x4 = 5
5 31 5 31
R19 ⇒ x3 − x4 = ⇒ x 3 − (5) =
14 14 14 14
31 25 31 + 25 56
⇒ x3 = + = = =4
14 14 14 14
R18 ⇒ x2 − 5 x3 + 3x 4 = −3 ⇒ x 2 − 5(4) + 3(5) = −3 ⇒ x2 − 20 + 15 = −3 ⇒ x 2 = −3 + 5 ⇒ x 2 = 2
1 3 1 7 1 3 1 7 5 7
R17 ⇒ x1 − x2 + x3 − x 4 = ⇒ x1 − ( 2) + (4) − (5) = ⇒ x1 − 1 + 6 − =
2 2 2 2 2 2 2 2 2 2
7 5 7 + 5 + 2 − 12 2
⇒ x1 = + + 1 − 6 ⇒ x1 = = =1
2 2 2 2
Hence x = ( x 1 , x 2 , x 3 , x 4 ) T
= (1, 2, 4,5 ) T
Q.1(ii)/Page # 83
X1 + x2 + x3 + x4 = 4
Prepared by: Inayat Ullah Lecturer in Mathematics Edwardes College Peshawar
Numerical Analysis 16
R21 1 0 0 0 1 R20
R22 0 1 0 0 1 R19
R23 0 0 1 0 1 R18
R24 0 0 0 1 1 R17
R24 ⇒ x4 = 1
R23 ⇒ x3 = 1
R22 ⇒ x2 = 1
Prepared by: Inayat Ullah Lecturer in Mathematics Edwardes College Peshawar
Numerical Analysis 17
R21 ⇒ x1 = 1
Hence the solution is: x = ( x1 , x 2 , x3 , x 4 ) = (1,1,1,1) Answer
T T
Type No. 4
Method of Inversion
Key
• Write the system of equation in matrix form.
• Re-write it as x = A-1c
• Find A-1 by Gauss Jordan Method.
• Tabular form of this method contains co-efficient Matrix and the identity matrix.
Change the co-efficient Matrix to identity Matrix by ERO and get the values of
unknowns.
Identity Matrix is:
1 0 0
0
I = 0 1 etc.
0 0 1
Q.4/Page # 84
Solve the system of equation by Inversion of the matrix.
4.65x1 + 1.98x2 – 4.62x3 = 11.25
0.79x1 – 2.54x2 + 3.16x3 = -4.91
4.02x1 – 8.17x2 + 2.93x3 = -6.90
Ans:
Matrix form of the system is
4.65 1.98 − 4.62 x1 11 .25
0.79 − 2.54 3.16
x 2 = − 4.91
4.02 −8.17 2.93
x3 −6.90
Ax = c
x = A-1c -(1)
Row
Rows X1 X2 X3 C1 C2 C3
Explanation
NOTES
(i) Square Matrix
Number of Rows = Number of Columns
2 0 0
0
A= 0 6 where 2, 6, 3 are called diagonal elements.
0
0
3
(iv) Upper Triangular Matrix
If aij = o, for i > j and there exists at least one non-zero entry for i < j .
For example
3 2 5
9
U = 0 7
0 0 6
(v) Lower Triangular Matrix
If aij = 0, for i < j and there exists at least one non-zero entry for i > j
For example
4 0 0
0
L = −9 2
1 6 7
(vi) Singular Matrix
If |A| = 0 ⇒ A is singular.
(vii) Non-singular Matrix
If |A| ≠ 0 ⇒ A is non-singular.
(viii) How to express a Matrix A in the product of L and U.
i.e. A = LU
where L is the unit lower triangular and U is the upper triangular. i.e.
a11 a12 a13
If A = a21 a22 a23 , then
a31 a32 a33
a11 a12 a13 1 0 0 u11 u12 u13
a a22 a23 = l21 1 0 . 0 u 22 u 23
21
a31 a32 a33 l31 l32 1 0 0 u33
TYPE NO. 5
CHOLESKI’S METHOD
KEY
• Given a system of equation: Ax = c
• Find L and U such that: LU = A
• Where L is the lower triangular matrix with diagonal elements “1” and U is upper
triangular Matrix.
• Let y = (y1, y2, y3,…………., yn)T
• Find y by using: Ly = c
• Find x = (x1, x2, x3, ……..xn)T by using Ux = y which is the solution
Prepared by: Inayat Ullah Lecturer in Mathematics Edwardes College Peshawar
Numerical Analysis 20
Q.17/Page # 88
1 2 3
7
Decompose the Matrix A = 2 8 in to the product of LU. Where L is the unit
2 16 12
lower triangular and U is upper triangular. Hence solve the system of equations.
.x1 + 2x2 + 3x3 = 2
2x1 + 8x2 + 7x3 = 7
2x1 + 16x2 + 12x3 = 10
Ans:
1st we express the matrix in the LU form. i.e. A = LU
1 2 3 1 0 0 u11 u12 u13
2
8 7 = l 21 1 0. 0 u 22 u 23
2
16 l
12 l 32 1 0 0 u 33
31
⇒ u11 = 1 u12 + 0 + 0 = 2 u13 + 0 + 0 = 3
l21.u11 + 0 + 0 = 2 ⇒u12 = 2 ⇒ u13 = 3
l21(1) = 2 l21.u12 + u22 = 8 l21.u13 + u23 = 7
⇒ l21= 2 (2)(2) + u22 = 8 (2)(3) + u23 = 7
l31.u11 + 0 = 2 u22 = 8 – 4 = 4 u23 = 7 – 6 = 1
l31(1) = 2 ⇒ u22 = 4 l31.u13 + l32.u23 + u33 = 12
⇒ l31 = 2 l31.u12 + l32.u22 + 0 = 16 2.3 + 3.1 + u33 = 12
2.2 + l32 (4) = 16 u33 = 12 – 6 – 3 = 3
4l32 = 16 – 4 = 12 ⇒ u33 = 3
⇒ l32 = 3
1 0 0 1 2 3
0 and U =
1
hence L = 2 1 0 4
2 3 1
0 0 3
R1 ⇒ y1 = 2
R2 ⇒ 2y1 + y2 = 7
⇒ (2)(2) + y2 = 7
⇒ y2 = 7 – 4 = 3
⇒ y2 = 3
R3 ⇒ 2y1 + 3y2 + y3 = 10
⇒ (2)(2) + (3)(3) + y3 = 10
⇒ y3 = 10 – 4 – 9 = - 3
⇒ y3 = -3
Therefore y = (y1, y2, y3)T = (2, 3, -3)T
Now we find x= (x1, x2, x3)T such that:
U x = y
1 2 3 x1 2
0
4 1
x 2 = 3
0 0
3 −3
x3
x1 +2 x 2 +3 x3 2
0 + 4 x 2 + x3 = 3
0 +0 +3 x −3
3
R3 ⇒ 3x3 = -3
⇒ x3 = -1
R2 ⇒ 4x2 + x3 = 3
⇒ 4x2 + (-1) = 3
⇒ 4x2 = 3 + 1 = 4
⇒ x2 = 1
R3 ⇒ x1 + 2x2 + 3x3 = 2
⇒ x1 + 2.1 + 3. -1 = 2
⇒ x1 + 2 – 3 = 3
⇒ x1 = 4
Hence the solution is: x = (x1, x2, x3)T = (4, 1, -1)T
TYPE NO. 2
ITERATIVE METHODS
Prepared by: Inayat Ullah Lecturer in Mathematics Edwardes College Peshawar
Numerical Analysis 22
Type # 1
Jacobi’s Method
KEY
• Write down the system in Diagonally Dominant form
• Write down the Diagonally Dominant form in Iterative form.
• Find 1st Iteration by Putting x0 = (0, 0, 0, 0,………)T
• We continue this process until we get the required accuracy.
Q.16/ Page # 87
Solve the system of equations
x1 + 0.1x2 = 1.0
0.1x1 + x2 + 0.1x3 = 2
0.1x2 + x3 = 3
Using (i) Jacobi’s Method.
(ii) Gauss Seidel Method.
Ans:
(i) 1st we will use the Jacobi’s Method
x1 + 0.1x2 = 1.0
0.1x1 + x2 + 0.1x3 = 2
0.1x2 + x3 = 3
. x1 = 1 – 0.1x2
. x2 = 2 – 0.1x2 – 0.1x3 -----------------> (A)
. x3 = 3 – 0.1x2
1st Iteration
Put x1 = x2 = x3 = 0 in (A)
⇒ x1 = 1 , x2 = 2 and x3 = 3
2nd Iteration
Put x1 = 1, x2 = 2 and x3 = 3 in (A)
⇒ x1 = 1 – (0.1)2 = 1 – 0.2 = 0.80
x2 = 2 – (0.1) 1 – (0.1) 3 = 2 – 0.1 – 0.3 = 1.6
x3 = 3 – (0.1)2 = 3 – 0.2 = 2.8
3rd Iteration
Put x1 = 0.80, x2 = 1.6 and x3 = 2.8 in (A)
⇒ x1 = 1 – (0.1) (1.60) = 0.84
. x2 = 2 – (0.1)(0.80) – (0.1)(2.8) = 1.64
x3 = 3 – (0.1)(1.6) = 2.836
th
4 Iteration
Put x1 = 0.84, x2 = 1.64 and x3 = 2.836 in (A)
Prepared by: Inayat Ullah Lecturer in Mathematics Edwardes College Peshawar
Numerical Analysis 23
⇒ x3 = 3 – (0.1)(1.632) = 2.836
This converges to the real solution. So the solution is:
x1 = 0.836, x2 = 1.632 and x3 = 2.836
Q.10/Page # 86
Solve the system of equations.
6x1 – 3x2 + x3 = 11
2x1 + x2 – 8x3 = -15
x1 – 7x2 + x3 = 10
Using Gauss Seidel method with initial vector x0 = (0, 0, 0)T
Ans:
1st we will write the system in Diagonally Dominant form by interchanging 2nd and 3rd equations.i.e.
6x1 – 3x2 + x3 = 11
x1 – 7x2 + x3 = 10 -----------> (A)
2x1 + x2 – 8x3 = -15
Q.9/Page # 86
The pair of equations
.x1 + 2x2 = 3.0
.3x1 + x2 = 4.0
Can be re-arranged to give:
x1 = 3 – 2x2
x2 = 4 – 3x1
Apply Jacobi’s Method to this arrangement, beginning with x = (1.01, 1.01)T and notice the system diverges.
Now apply Gauss Seidel method to system and comment which method diverges more rapidly.
Ans: Given that: x1 = 3 – 2x2
.x2 = 4 – 3x1
1st we use Jacobi’s Method
1st Iteration
put x1 = 1.01 and x2 = 1.01 in the above equations.
.x1 = 3 – 2(1.01) = 0.98
.x2 = 4 – 3(1.01) = 0.97
2nd Iteration
x1 = 3 – 2(0.97) = 1.06
x2 = 4 – 3(0.98) = 1.06
3rd Iteration
x1 = 3 – 2(1.06) = 0.88
x2 = 4 – 3(1.06) = 0.82
4th Iteration
x1 = 3 – 2(0.82) = 1.36
x2 = 4 – 3(0.88) = 1.36
5th Iteration
x1 = 3 – 2(1.36) = 0.28
Prepared by: Inayat Ullah Lecturer in Mathematics Edwardes College Peshawar
Numerical Analysis 25
x2 = 4 – 3(1.36) = - 0.08
6th Iteration
x1 = 3 – 2(- 0.08) = 3.16
x2 = 4 – 3(0.28) = 3.16
after 6th Iteration x1 = 3.16 and x2 = 3.16. i.e. x = (3.16, 3.16)T, which is diverging.
Now using Gauss Seidel Method
x1 = 3 – 2x2---------->(1)
x2 = 4 – 3x1---------->(2)
1st Iteration
put x2 = 1.01 in (1)
⇒ x1 = 3 – 2(1.01) = 0.98 put in (2) ⇒ x2 = 4 – 3(0.98) = 1.06
2nd Iteration
equation (1) ⇒ x1 = 3 – 2(1.06) = 0.88
equation (2) ⇒x2 = 4 – 3(0.88) = 1.36
3rd Iteration
equation (1) ⇒ x1 = 3 – 2(1.36) = 0.28
equation (2) ⇒ x2 = 4 – 3(0.28) = 3.16
4th Iteration
equation (1) ⇒ x1 = 3 – 2(3.16) = - 3.32
equation (2) ⇒ x2 = 4 – 3(- 3.32) = 13.96
5th Iteration
equation (1) ⇒ x1 = 3 – 2(13.96) = - 24.92
equation (2) ⇒ x2 = 4 – 3(- 24.92) = 78.76
6th Iteration
equation (1) ⇒ x1 = 3 – 2(78.76) = - 154.52
equation (2) ⇒ x2 = 4 – 3(- 154.52) = 467.56
After 6th Iteration x1 = - 154.52 and x2 = 467.56. i.e. x = (- 154.52, 467.56)T. which is diverging.
Comment: After six iterations we see that Gauss Seidel Method diverges rapidly than the Jacobi’s Method.
CHAPTER#4
Numerical Integration
b 1 1
∫a
f ( x ) dx = h f ( x 0 ) + f ( x1 ) + f ( x 2 ) + .......... .... + f ( x n )
2 2
b −a
Where h=
n
2. Simpson’s Rule
h
[ f ( x0 ) + 4 f ( x1 ) + 2 f ( x 2 ) + 4 f ( x3 ) + 2 f ( x 4 ) + 4 f ( x5 ) + .......... ....... + f ( x n )]
b
∫
a
f ( x) dx =
3
b −a
Where h=
n
Error = Approximate value – True value
Q #1 b 3 1
:∫ f ( x ) dx = ∫ ( x + ) dx
P − 112 x
a 2
1
Here f ( x) = x + , a = 2, b = 3, n = 4
x
b−a 3−2 1
h= = =
n 4 4
1
x f ( x) = x +
x
1
x0 = 2 ⇒ f ( x0 ) = f (2) = 2 + = 2.5
2
1 1
x1 = 2 + = 2.25 ⇒ f ( x1 ) = f ( 2.25 ) = 2.25 + = 2.694
4 2.25
2 1
x2 = 2 + = 2.5 ⇒ f ( x 2 ) = f (2.5) = 2.5 + = 2.9
4 2.5
3 1
x3 = 2 + = 2.75 ⇒ f ( x3 ) = f ( 2.75 ) = 2.75 + = 3.114
4 2.75
4 1
x4 = 2 + =3 ⇒ f ( x 4 ) = f (3) = 3 + = 3.333
4 3
b 1 1
∫
a
f ( x ) dx = h f ( x 0 ) + f ( x1 ) + f ( x 2 ) + f ( x3 ) + f ( x 4 )
2 2
3 1 1 2.5 3.333
∫ ( x + x )dx = 4
2 2
+ 2.694 + 2.9 + 3.114 +
2
Prepared by: Inayat Ullah Lecturer in Mathematics Edwardes College Peshawar
Numerical Analysis 27
1
= (1.25 + 8.708 +1.667 )
4
1
= ×11 .625 = 2.9063
4
For true value
3 1 3 3 1
∫ ( x + x )dx = ∫
2 2
xdx + ∫
2 x
dx
3
x2 3
= + ln x 2
2 2
1 2
= (3 − 2 2 ) + (ln 3 − ln 2)
2
1
= (9 − 4) + (1.099 − 0.693 )
2
= 2.5 + 0.406 = 2.906
Error = Approximate value – True value = 2.9063 − 2.906 = 0.0003
b 2 1
(ii) ∫a
f ( x )dx = ∫
0 e4x
dx
1
Here f ( x) = = e − 4 x , a = 0, b = 2, n = 4
e4x
b−a 2−0 2 1
h= = = =
n 4 4 2
x f ( x ) = e −4 x
x0 = 0 f ( x 0 ) = f (0) = e 0 = 1
1
x1 = 0 + = 0.5 f ( x1 ) = f (0.5) = e −4( 0.5) = 0.135
2
2
x2 = 0 + =1 f ( x 2 ) = f (1) = e −4 = 0.018
2
3
x3 = 0 + = 1.5 f ( x3 ) f (1.5) = e −4 (1.5) = 0.002
2
4
x4 = 0 + =2 f ( x 4 ) = f (2) = e −8 = 0.0003
2
Trapezoidal rule
b 1 1
∫a
f ( x )dx = h f ( x 0 ) + f ( x1 ) + f ( x 2 ) + f ( x3 ) + f ( x 4 )
2 2
1 1 0.0003
= + 0.135 + 0.018 + 0.002 +
2 2 2
1
= ( 0.5 + 0.1550 + 0.0002 )
2
1
= × 0.6550 = 0.3275
2
1
= − (e −8 − e 0 )
4
1
= − (0.0003 −1)
4
1
= − (−0.9997 ) = 0.2499
4
Error = Approximate value – True value
=0.3275-0.2499=0.0776
Q #2 b 2
: ∫ f ( x)dx = ∫ ( x 4 − x 2 +1) dx
P − 112 a 1
Here f ( x) = x 4 − x 2 + 1, a = 1, b = 2, n = 2
b − a 2 −1 1
h= = =
n 2 2
x f ( x ) = x 4 − x 2 +1
x0 =1 f ( x 0 ) = f (1) = 1 −1 +1 = 1
1
x1 = 1 + = 1.5 f ( x1 ) = f (1.5) = (1.5) 4 − (1.5) 2 + 1 = 3.8125
2
2
x2 = 1 + =2 f ( x 2 ) = f ( 2) = ( 2) 4 − ( 2) 2 + 1 = 13
2
Simpson’s Rule
h
[ f ( x0 ) + 4 f ( x1 ) + f ( x 2 )]
b
∫a
f ( x ) dx =
3
1
∫1 ( x − x +1)dx = 2 ×3 [1 + 4(3.8125 ) +13 ]
3
4 2
1
= (1 +15 .2500 +13 )
6
1
= × 29 .2500 = 4.8760
6
b 2
(ii) ∫a
f ( x ) dx =∫ e x sin xdx
0
Here f ( x) = e x sin x, a = 0, b = 2, n = 2
b −a 2−0 2
h= = = =1
n 2 2
x f ( x) = e x sin x
x0 = 0 f ( x 0 ) = f (0) = e 0 sin 0 = 0
x1 = 0 + 1 = 1 f ( x1 ) = f (1) = 2.2874
x 2 0 +1(2) = 2 f ( x 2 ) = f ( 2) = 6.7188
Simpson’s Rule
h
[ f ( x0 ) + 4 f ( x1 ) + f ( x 2 )]
b
∫a
f ( x )dx =
3
1
∫0 e sin xdx = 3 [0 + 4 × 2.2874 + 6.7188 ]
2
x
1
= ×15 .8668
3
= 5.2886
Q #3 b 1
: ∫ f ( x ) dx = ∫ ydx
P − 112 a 0
Trapezoidal Rule
1
f (x0 ) + f (x1 ) + f (x2 ) + f (x3 ) + f (x4 ) + f (x5 ) + f (x6 ) + f (x7 ) + f (x8 ) + f (x9 )
b 2
∫ a 1
f ( x ) d =x h
+ f (x1 )0
2
1 1 0.3 5 9
∫ 0 y d= 0x.1 2 + 0.9 +90.9 +60.9 1+ 04.8 5+ 02.7 7+ 09.6 9+ 07.6 1+ 03.5 2+ 07.4 4+ 5 2
0.1 × 6.7780 = 0.6678
Q #4 b 2 dx
: ∫ f ( x ) dx = ∫
1+ x4
P − 112 a 1
1
Here f ( x) = , a = 1, b = 2, n = 6
1+ x4
b − a 2 −1 1
h= = =
n 6 6
1
x f ( x) =
1+ x4
x0 =1 f ( x 0 ) = 0.5
1
x1 = 1 + = 1 .2 f ( x1 ) = 0.325
6
2
x2 = 1 + = 1.3 f ( x 2 ) = 0.259
6
3
x3 = 1 + = 1.5 f ( x3 ) = 0.165
6
4
x4 = 1 + = 1.7 f ( x 4 ) = 0.107
6
5
x5 = 1 + = 1.8 f ( x5 ) = 0.087
6
6
x6 = 1 + =2 f ( x 6 ) = 0.059
6
Trapezoidal Rule
b 1 1
∫a
f ( x )dx = h f ( x 0 ) + f ( x1 ) + f ( x 2 ) + f ( x3 ) + f ( x 4 ) + f ( x5 ) + f ( x 6 )
2 2
2 1 1 0.5 0.059
∫1 1 + x 4 dx = 6 2 + 0.325 + 0.259 + 0.165 + 0.107 + 0.087 + 2
1
= ×1.223 + 0.205
6
= 0.4088 Answer