Numerical Methods and Analysis
Numerical Methods and Analysis
CHAPTE R ONE
Introduction
Numerical technique is widely used by scientists and engineers to solve their problems. A major
advantage for numerical technique is that a numerical answer can be obtained even when a problem
has no analytical solution. However, result from numerical analysis is an approximation, in general,
which can be made as accurate as desired. The reliability of the numerical result will depend on an
error estimate or bound, therefore the analysis of error and the sources of error in numerical
methods is also a critically important part of the study of numerical technique.
1.1. E rrors and Approximations in Computation
A computer has a finite word length and so only a fixed number of digits are stored and used
during computation. This would mean that even in storing an exact decimal number in its
converted form in the computer memory, an error is introduced. This error is machine
dependent and is called machine epsilon. In general, we can say that
= − .
Page 1
Numer ical Methods For Engineer s
( )= ( )+ ( − ) ( )+ ( − ) ( )+ ⋯
1.2.4. Absolute error: is the numerical difference between the true value of a quantity and its
approximate value. Thus if is the approximate value of quantity then | − | is called
the absolute error and denoted by . Therefore = | − | . The unit of exact or unit
of approximate values expresses the absolute error.
Page 2
Numer ical Methods For Engineer s
1.2.6. Percentage error: The percentage error in which is the approximate value of is given
E xample: Find the absolute, relative and percentage errors if is rounded-off to three
decimal digits. Given = 0.005998
Solution: If is rounded-off to three decimal places we get = 0.006. Therefore,
= −
= 0.005998 − 0.006 = −0.000002.
= = | | = 0.000002
.
= = = = 0.0033344 and
.
= = ∗ 100 = 0.33344.
E xample: If = 0.51 and correct to two decimal places then ∆ = 0.005 and the relative
∆ .
accuracy is given by = × 100 = × 100 ≅ 0.98%
.
E xercise:
a. An approximate value of is given by = = 3.1428571 and its true
i. − +
ii. −
Page 3
Numer ical Methods For Engineer s
+ ∆ = ( , , …, )+ ∆ + ∆ + ⋯+ ∆ +
(∆ ) + (∆ ) + ⋯ + (∆ ) + ⋯ ---------------------------------------- (1.3)
∆
Assuming the errors ∆ ,∆ , …. , ∆ in all are small and that ≪ 1 so that the terms containing
E quation (5) represents the general formula for E rrors. If equation (5) divided by we get relative
∆ ∆ ∆ ∆
+ ⋯+
1 2
error = = + ------------------------------------------------------------ (1.6)
1 2
Also from equation (5), by taking modulus we get maximum absolute error,
|∆ | ≤ ∆ 1 + ∆ 2 + ⋯+ ∆ --------------------------------------------------------- (1.7)
1 2
Page 4
Numer ical Methods For Engineer s
∆
Let = − then we have ; which is a maximum relative error. Therefore, it shows
that when the given numbers are added then the magnitude of absolute error is the sum of
the magnitudes of the + ∆ = ( + ∆ ) −( + ∆ )
or + ∆ = ( − ) + (∆ −∆ )
∆ ∆ ∆
∴ Absolute error is given by ∆ = ∆ −∆ and Relative error is = 1
− 2
.
Therefore, on taking modulus of relative errors and absolute errors to get its maximum
value, we have | ∆ | ≤ | ∆ 1 | + | ∆ 2 | which is the maximum absolute error and
∆ ∆ ∆
≤ 1
+ 2
which gives the maximum relative error in subtraction of numbers.
1 … 1 1 … 1 1 … 1
Now, = = , = = ,…, = =
1 … 1 2 … 2 …
∆ ∆ ∆ ∆
+ ⋯+
1 2
Therefore, = +
1 2
∆ ∆ ∆ ∆
⇒ = ≤ + + ⋯+ and
∆ ∆
= = × ( … )
∆ = ∆ 1 + ∆ 2 + ⋯+ ∆
1 2
∆ ∆ ∆ ∆ 1 ∆ ∆ ∆
We have = 1
+
2
= 1
1
× + 1
2
× − 1
=
1
− 2
1 2 2 2 1 2
2 2
∆ ∆ ∆
Therefore, the relative maximum error is ( ) = ≤ + and absolute error is
∆
= |∆ | ≤
Page 5
Numer ical Methods For Engineer s
5 2 10 −15 2
Solution: = 3 , = 3 , = 4 and
∆ = ∆ + ∆ + ∆
In general, the errors ∆ , ∆ , ∆ may be negative or positive and hence we take the absolute
values of the terms of the right side.
This gives, ( ∆ ) = ∆ + ∆ + ∆
Now let ∆ = ∆ = ∆ = 0.001 and = = = 1 then the relative maximum error is given by
(∆ ) .
( ) . = = = 0.006
E xample 2: E valuate the sum = √3 + √5 + √7 to four significant digits and find its absolute
and relative errors.
∆ ∆ ∆ ∆
∆ = ∆ or ∆ = . Similarly we get ∆ = , ∆ = ,…, ∆ = and so on.
E xample: The percentage error in which is given by = + , is not allowed to exceed 0.2% , find
∆
Solution: The percentage error in = × 100 = 0.2
. . . . . × .
Therefore ∆ = × = × + =
× .
Page 6
Numer ical Methods For Engineer s
. × .
∆ ∆ ∆ (∆ ) ( . )
Percentage in = × 100 = × = × = = = 0.12
( . )
E xercise:
a. If = 3 − 6 find the in at = 1, if the error in is 0.05.
d. Find the quotient = , where = 4.536 and = 1.32 both and being correct to the
Page 7
Numer ical Methods For Engineer s
CHAPTE R TWO
NUME RICAL SOLUTIONS OF NON-LINE AR E QUATIONS
Method for finding the root of an equation can be classified as direct and Iterative methods.
i. Direct method: in some cases, roots can be found by using direct/analytical methods.
For a quadratic equation + + = 0 the roots of the equation obtained by
√ √
= and = . These are called closed form solution. Similar
formula also available for cubic and bi-quadratic polynomial equations but we rarely
remember them. For higher order polynomial equations and non-polynomials it is
difficult and in many cases impossible to get closed form solutions.
ii. Iterative method: those methods also known as trial and error methods are based on
the idea of successive approximation starting with one or more initial approximation to
the value of the root to obtain the accurate solution. The above quadratic equation can
be found by iterative method in the following manner.
a. = , = 0,1,2, …
b. = , = 0,1,2, …
c. = , = 0,1,2, …
Step3: If ( ) ∗ ( ) < 0 then set = else = then apply the formula of step2.
Page 8
Numer ical Methods For Engineer s
Step4: stop evaluation when the difference of two successive values of obtained from step2, is numerically less
( )
If an error tolerance has been prescribed in advance, it is possible to determine the number of steps
required in the bisection method. Let be a root in ( , ) and | − |< implies < by
( ) ( )
taking logarithms (with any convenient base), we obtain > ----------------------- (2.1)
= ( ); = ( )
+
= ; = ( )
2
No
Is
. < 0
Yes No
Is
Stop
= ; = − Yes
= ; = <
2
Page 9
Numer ical Methods For Engineer s
E xample:
a. Using Bisection method find the real root of the equation ( ) = 3 − √1 + with the
initial interval ( 0,1) .
b. Find the minimum number of iteration that the bisection method requires to get the
approximate root of the given function with a maximum absolute error of 10 .
Solution:
1st approximation = = 0.5, ( 0.5 ) = 0.2837 > 0 so the root lies between 0 and 0.5 .
.
2nd approximation = = 0.25, ( 0.25 ) = −0.3669 < 0 so the root lies between 0.25
and 0.5 .
. .
3rd approximation = = 0.375, ( 0.375 ) = −0.0439 < 0 so the root lies between
( ) ( )
> = 16.6096, this implies that the minimum number of iteration is 17.
( = , ( ))
( = , ( ))
Page 10
Numer ical Methods For Engineer s
The secant line over the interval [ , ] is the chord between ( , ( ) ) and ( , ( ) ) . The two right
angles in the figure are similar, which mean that = .
( ) ( )
( ) ( ) ( )( )
This implies that =
( )
= − ( )
------------------------------------------------------ (2.2)
( ) ( )
then we can compute ( ) and repeat the process with the interval [ , ] , if ( ) . ( ) < 0 or to
the interval [ , ] , if ( ) . ( ) < 0 .
Step1: Choose two initial guess values (approximations) and (where < ) such that
( )∗ ( ) < 0.
( ) ( )
Step2: Find the next approximation = ; and also evaluate ( ).
( ) ( )
Step3: If ( )∗ ( ) < 0 set = then go to the next step if not, rename = and then go to the
next step.
( ) ( )
Step4: E valuate the successive approximation using the formula =
( )
, = 2,3, …
( )
But before applying the formula for , ensure that whether ( ). ( ) < 0 , if not rename as
and proceed.
Step5: stop the evaluation when | − |< , where is the prescribed accuracy.
E xample: Find a real root of the equation ( ) = − 3 using Regula-falsi method correct to
three decimal places.
( ) ( ) ( . ) ( . )
1st approximation: = = = 1.0352 and
( ) ( ) ( . ) ( . )
( )= ( 1.0352 ) = −0.0852 thus, the root lies between = 1.0352 and = 1.5 .
( ) ( ) . ( . ) ( . )
2nd approximation: = = = 1.0456 and
( ) ( ) ( . ) ( . )
= 1.0498. Hence the approximate root is 1.0498 correct to three decimal places.
Page 11
Numer ical Methods For Engineer s
= ( )
= ( )
= ( )
= ( )
= ( ), = 1,2,3, …
Step4: Stop evaluation where relative error less than the prescribed accuracy .
When | ( )| > 1 ⟹ ( ) > 1 or ( ) < −1 , then it is divergent, and then the iteration
Page 12
Numer ical Methods For Engineer s
E xample1: Find the root of the equation = 3 − 1 correct to three decimal places
Now the given equation can be rewrite as = ( + 1) = ( ) (say) then we can check
= ( )= ( 0 + 1 ) = 0.667
= 0.6072 → = 0.6071
Now, & being almost the same. Hence the required root is given by 0.6071.
method.
We get = ( )= = 0.81649
√ .
= ( )= = 0.7419, … , = ( ) = 0.75487
√ .
Page 13
Numer ical Methods For Engineer s
Tangent line
( )=
= ( )
( ) ( ) ( )
Form the figure = ( )= , ∴ − = , ⇒ = −
( ) ( )
( ) ( )
Still better approximation value = − ( )
in general, = − ( )
, = 0,1,2, ….
The other way of interpreting Newton’s method is the Taylor series at . Thus, we could write
( )
⇒ℎ= −
( )
( )
⇒ − = −
( )
( )
⇒ = −
( )
Page 14
Numer ical Methods For Engineer s
( )
Then, generally = − ( )
, = 0,1,2, …. ----------------------------------------------------- (2.4)
( )
step2: Find next (first) approximation by using the formula = − ( )
.
step3: Follow the above procedure to find the successive approximation using the formula
( )
= − , = 1,2,3, ….
( )
step4: Stop the process when | − |< where is the prescribed accuracy.
( )
= − ( )
= 0.65307940 , ( ) = −0.4606
( )
= − ( )
= 0.53134337 , ( ) = −0.4180 × 10
( )
= − ( )
= 0.51790991 , ( ) = −0.4641 × 10
( )
= − ( )
= 0.51775738 , ( ) = −0.5926 × 10
( )
= − ( )
= 0.51775736 , ( ) = −0.2910 × 10
⇒ | −0.2910 × 10 | < 10
Page 15
Numer ical Methods For Engineer s
Secant line
= ( )
= − ( )
( ) ( )
---------------------------------- (2.7)
, , ,…
This method is also called the modification of Regula-Falsi method.
Given function ( ) and two initial points , the formula is the same with Regula-Falsi
( ) ( )
method can be written as = − ( ) ( )
( ) ( )
This implies that the Secant formula is, = − ( ) ( )
, = 1,2,3, …
Page 16
Numer ical Methods For Engineer s
, , =
( − ) ( )
= −
( )− ( )
= +
| − |< Yes St op
No
Page 17
Numer ical Methods For Engineer s
E xample: Find a real root of the equation ( ) = − 3 using Secant method correct to
three decimal places.
Solution: We have ( ) = − 3 = 0 assume = 1 and = 1.5 as initial guess
values then ( 1 ) = −0.2817 and ( 1.5 ) = 3.7225 therefore the root lies b/n 1 and 1.5 .
( ) ( ) ( . ) .
= − ( ) ( )
= 1.5 −
. ( . )
= 1.0352 ,
( )= ( 1.0352 ) = −0.0852
( ) ( ) ( . . )( . )
= − ( ) ( )
= 1.0352 − = 1.0456,
( . ) .
( ) = ( 1.0456 ) = −0.0252
( ) ( ) ( . . )( . )
= − ( ) ( )
= 1.0456 −
( . ) ( . )
= 1.0500,
( ) = ( 1.0500 ) = 0.0005
( ) ( ) ( . . )( . )
= − ( ) ( )
= 1.0500 −
( . ) ( )
= 1.0499,
.
( ) = ( 1.0499 ) = 0.0000
Therefore, the approximate real root of the equation ( ) = − 3 is 1.0499.
E xercise
1. Find the root of log = cos correct to two decimal places using Bisection method.
2. Use the Bisection method to find a root of the equation − 4 − 9 in the interval ( 2, 3) ,
accurate to four decimal places.
3. How many number of iteration is needed is to find the solution of the equation
cos( ) − + 2 = 0 on the interval [ 0,1 ] having with an accuracy less than = 0.0001
4. Given these three equations
i. − − 10 = 0
ii. − = 0
iii. + 4 = 0
Determine the initial approximation and use those to find the roots correct to three
decimal places with the following methods
a. Regula-Falsi method
b. Secant method
c. Newton Raphson method
5. Find the approximate value of ( 17 ) Using Newton Raphson method, correct to six decimal
places starting with = 2.
6. Find the root of the equations
i. − = 1
ii. −3 − + 2= 0
Page 18
Numer ical Methods For Engineer s
CHAPTE R THRE E
SOLVING SYSTE M OF LINE AR AND NON-LINE AR E QUATIONS
3.1. Direct Methods
Consider a system of linear equations in unknowns.
+ + ⋯+ =
+ + ⋯+ =
------------------------------------------------------------------- (3.1)
⋮
+ + ⋯+ =
Where ( , , = 1,2,3, …, ) , are the known coefficients.
( , = 1,2,3, …, ) , are the known values
( , = 1,2,3, …, ) , are unknown to be determined
In the matrix notation, the system (3.1) can be written as
= ------------------------------------------------------------------------------------------------------ (3.2)
The matrix [ | ] is called the augmented matrix. Where is the column matrix and is the
× matrix. Therefore, the system of equation = can be directly solved in the following
cases.
i. = , the equation (3.2) become
=
=
----------------------------------------------------------------- (3.3)
⋱ ⋮
=
The solution is given by = , ≠0
, , ,…,
ii. = , the equation (3.2) become
=
+ =
+ + = --------------------------------------------------- (3.4)
⋮ ⋱ ⋮
+ + … + =
Solving the first equation and then successively solving the 2nd, 3rd and so on.
We obtain
( − ) ( − − )
= , = , = , …,
∑
= where ≠ 0 , = 1,2,3, …,
This method of solving equation is called forward substitution method.
iii. = , the equation (3.2) become
Page 19
Numer ical Methods For Engineer s
+ + … + =
+ … + =
+ … + =
----------------------------------------- (3.5)
⋱ ⋮
, +
= ,
=
Solving for the unknowns in the in the order , , … , , we get
− ,
−∑
= , = ,
, …, =
Page 20
Numer ical Methods For Engineer s
1 −1 0
= −2 3 −4
−2 3 −3
0 0 1 −3 −1
Therefore, = 3 = −2
−4 3 = 5
3 −3 1 −2 6
−3
Hence, the solution is = = 5
6
3.1.3. Gaussian E limination Method
This is a method reduction of equation (3.1) in to an equivalent upper triangular system
which is then solved by back substitution method.
Consider the 3 × 3 system
+ + =
+ + = --------------------------------------------------------------------- (3.8)
+ + =
In this first stage of elimination: multiply the first row by & respectively
and subtract from the second and third rows. We get
( ) ( ) ( )
+ =
( ) ( ) ( )
----------------------------------------------------------------------------- (3.9)
+ =
( ) ( )
⎧ = − , = − ⎫
⎪ ( ) ( ) ⎪
Where, = − , = − -------------------------------------- (3.10)
⎨ ⎬
⎪ ( )
= − ,
( )
= − ⎪
⎩ ⎭
( )
Second stage of elimination: multiply the first row in (3.4) by ( ) and subtract from
Page 21
Numer ical Methods For Engineer s
Partial pivoting
In the 1st stage elimination: Search an element from the first column which is largest element
in magnitude and brought as the first pivot by interchanging the first equation with the
equation having largest element in magnitude, and the same for the 2nd stage elimination
among the − 1 elements leaving the first equation and the same for the 3rd stage
elimination among the − 2 elements leaving the first and second equations … and so on.
Additionally, to reduce round-off error; it is often necessarily to perform row interchanges
even when the pivot elements are not zero.
E xample: Using the four decimal places computer, solve
0.729 + 0.81 + 0.9 = 0.6867
+ + = 0.8338
1.331 + 1.21 + 1.1 = 1.0000
Its exact solution rounded to four decimal places, is
= 0.2245 , = 0.2814 & = 0.3279
Solution without pivoting
0.729 0.81 0.9 0.6867
1 1 1 0.8338
1.331 1.21 1.1 1.0000
= = 1.372 and ← −
= = 1.826 & ← −
( )
= ( ) = 2.423 and ← −
Page 22
Numer ical Methods For Engineer s
↔ , = = 0.7513 and ← −
= = 0.5477 ← −
( )
↔ , = ( ) = 0.6171 and ← −
2 0.33 34
3 0.333 4
4 0.3333 1
5 0.33333 0.7
6 0.333333 0.67
7 0.3333333 0.667
8 0.33333333 0.6667
The exact solution of this problem is = and = .
Round-off errors can never be completely eliminated. However, they can be minimized
by using high precision arithmetic and pivoting.
Page 23
Numer ical Methods For Engineer s
b. System Condition
A system of equations = is said to be ill-conditioned or unstable if it is highly sensitive to
small changes in and i.e., small change in or causes a large change in the solution of
the system. On the other hand if small changes in and give small changes in the solution,
the system is said to be stable, or, well conditioned. Thus in an ill-conditioned system, even the
small round off errors effect the solutions very badly. Unfortunately it is quite difficult to
recognize an ill-conditioned system.
E xample: Consider the following two almost identical systems
− = 1 − = 1
and
− 1.00001 = 0 − 0.99999 = 0
The respective solutions are: ( 100001, 100000) and ( – 99999, – 100000)
Obviously the two solutions differ very widely as the result of small change in the value of .
Therefore, the system is ill conditioned.
+ + = 1
4 + 3 − = 6
3 + 5 + 3 = 4
1 1 1 0 0 1
4 3 −1 = 0 0 1
3 5 3 0 0 1
= + +
+ + +
Page 24
Numer ical Methods For Engineer s
= 1, = 4, = 3, = −1 , = 2, = −1 and
= 1, = 1, = 5
Page 25
Numer ical Methods For Engineer s
× + × = −5 ⇒ 4 = −12 ⇒ = −3
× + × + × = 83 ⇒ ( ) = 25 ⇒ = 5
Now we have to solve = , that is,
2 0 0 14
1 4 0 = −101
7 −3 5 155
7
Solving the system, then the solution is = −27
5
At the second step, we have to solve = = , that is,
2 1 7 7
0 4 −3 = −27
0 0 5 5
3
Solving the system using backward substitution, then the solution is = −6
1
Page 26
Numer ical Methods For Engineer s
4 + + = 2
+ 5 + 2 = −6 Using Jacobi iteration method
+ 2 + 3 = −4
Page 27
Numer ical Methods For Engineer s
Page 28
Numer ical Methods For Engineer s
This iteration process is continued. The results are tabulated as follows correcting to four decimal
places. (where is the number of iteration)
( ) ( ) ( )
Page 29
Numer ical Methods For Engineer s
Solution:
Step 1: Compute the characteristic polynomial
1− 2 3
det ( − ) = 0 5− 6 = ( 1 − ) [ ( 5 − ) − 36 ]
0 6 5−
= ( 1 − ) ( −1 − ) ( 11 − )
Step 2: The E igen-values are = 11, = 1, = −1 .
Step 3: Compute corresponding eigenvectors
For = 11, we have
1− 2 3 −10 2 3
( − ) = 0 5− 6 = 0 −6 6 = 0
0 6 5− 0 6 −6
1
⇒ = = 2
2
For = 1, we have
1− 2 3 0 2 3
( − ) = 0 5− 6 = 0 4 6 = 0
0 6 5− 0 6 4
1
⇒ = = 0
0
For = −1 , we have
1− 2 3 2 2 3
( − ) = 0 5− 6 = 0 6 6 = 0
0 6 5− 0 6 6
1
⇒ = = 2
−2
Page 30
Numer ical Methods For Engineer s
( )
2. Perform the matrix multiplication: = ( )
3. Scale ( ) so that the unity component remains unity:
( )
= ( ) ( )
( )
4. Repeat steps 2 and 3 with = . Iterate to convergence. At convergence,
the value is the largest (in absolute value) eigenvalue of , and the vector
is the corresponding eigenvector (scaled to unity on the unity component).
The general algorithm for the power method is as follows:
( )
= ( )
= ( ) ( )
------------------------------------------------------------- (3.23)
When the iterations indicate that the unity component could be zero, a different unity
component must be chosen. The method is slow to converge when the magnitudes (in
absolute value) of the largest eigenvalues are nearly the same. When the largest
eigenvalues are of equal magnitude, the power method, as described, fails.
E xample: Find the largest (in absolute value) eigenvalue and the corresponding
eigenvector of the given matrix
8 −2 −2
= −2 4 −2
−2 −2 13
( )
Solution: Assume = [ 1.0 1.0 1.0 ] . Scale the third component to unity.
8 −2 −2 1.0 4.00 0.444444
( )
= −2 4 −2 1.0 = 0.00 , ( )
= 9.00, ( )
= 0.000000
−2 −2 13 1.0 9.00 1.000000
8 −2 −2 0.444444 1.555555
( )
= −2 4 −2 0.000000 = −2.888888 ,
−2 −2 13 1.000000 12.111111
0.128440
( )
= 12.111111, ( )
= −0.238532
1.000000
To generalize in table
The results of the first two iterations presented above and subsequent iterations are
presented in Table. These results were obtained on a 13-digit precision computer. The
iterations were continued until changed by less than 0.000001 between iterations. The
final solution for the largest eigenvalue, denoted as , and the corresponding
eigenvector is
Page 31
Numer ical Methods For Engineer s
Page 32
Numer ical Methods For Engineer s
( )
Solution: Assume = [ 1.0 1.0 1.0 ] . Scale the first component of to
unity. The first step is to solve for and by the Doolittle method. The results are
1 0 0 8 −2 −2
= 1 0 and = 0
1 0 0
( )
Solve for by forward substitution using =
1 0 0
⎡−1 ⎤
1.0
⎢ 1 0⎥
⎢4 ⎥ = 1.0
⎢−1 −5 ⎥ 1.0
⎣4 1⎦
7
= 1.0
−1 5
= 1.0 − ( 1.0 ) =
4 4
−1 −5 5 15
= 1.0 − ( 1.0 ) − =
4 7 4 7
Solve for ( ) by back substitution using ( )
=
8 −2 −2 1.0
⎡ 7 −5 ⎤ ⎡5 ⎤
⎢0 ⎥ ⎢ ⎥
⎢ 2 2 ⎥ = ⎢ 4 ⎥
⎢ 75 ⎥ ⎢ 15 ⎥
⎣0 0 7 ⎦ ⎣7 ⎦
= [ 1.0 − ( −2.0 ) ( 0.5 ) − ( −2 ) ( 0.2) ] ⁄8 = 0.30
5 5
= − − ( 0.2) ( 7 ⁄2) = 0.50
4 2
15 75
= ( ) ( ) = 0.20
7 7
Scale ( ) so that the unity component is unity.
0.30 1.00000
( ) ( ) ( )
= 0.50 = 0.300000 = 1.66667
0.20 0.66667
The results of the first iteration presented above and subsequent iterations are presented
in the Table below. These results were obtained on a 13-digit precision computer. The
iterations were continued until changed by less than 0.000001 between
iterations. The final solution for the smallest eigenvalue and the corresponding
eigenvector is = = = 2.508981 and
.
= [ 1.000000 2.145797 0.599712 ] Therefore, to generalize in table
Page 33
Numer ical Methods For Engineer s
⋮ ⋮ ⋮ ⋮ ⋮
12 0.398568 1.000000 2.145796 0.599712
13 0.398568 1.000000 2.145796 0.599712
⎧ ( 1
⎪ , )+ ∆ + ∆ ( , )+ ∆ + ∆ ( , )+ ⋯= 0
2!
⎨ 1
⎪ ( , )+ ∆ + ∆ ∆ + ∆ ( , ( , )+ ⋯= 0
)+
⎩ 2!
Neglecting 2nd and higher powers of ∆ & ∆ , we obtain
( , )+ ∆ ( , )+ ∆ ( , )= 0
------------------------------------------------------ (3.28)
( , )+ ∆ ( , )+ ∆ ( , )= 0
Since = + ∆ and = + ∆ writing the equation (3.28) in matrix form, we get
( , ) ( , ) ∆ ( , )
= −
( , ) ( , ) ∆ ( , )
Or ∆ = − ( , ) --------------------------------------------------------------------------------------- (3.29)
The solution of the system (3.29) is ∆ = − ( , ) -------------------------------------------- (3.30)
−
where = =
( , ) − ( , )
and = − ( , )
∆ ( , )
Therefore equation (3.30) can be written as = −
∆ ( , )
∆ ( , )
⇒ = + = − , = 0,1,2, …------------------------------ (3.31)
∆ ( , )
Page 34
Numer ical Methods For Engineer s
Or ( )
= ( )
− ( )
----------------------------------------------------------------------- (3.32)
( ) ( ) ( ) ( ) ( ) ( ) ( ) ( )
where = , , = , , ,
The method given by (3.32) is called Newton’s method to the system of 2 × 2 equations.
This method can be easily generalized for solving a system of equations in unknowns.
( , , …, ) = 0
( , , …, ) = 0
--------------------------------------------------------------------------------------- (3.33)
……………
( , , …, ) = 0
Or ( ) = 0 where = [ , , …, ] and = [ , , …, ]
( ) ( ) ( ) ( )
If = , , …, is an initial approximation to the solution vector then we can write
the method as ( )
= ( )
− ( )
, = 0,1,2, …------------------------------------------ (3.34)
⁄ ⁄ , …, ⁄
⁄ ⁄ , …, ⁄
where = is the Jacobian matrix of the functions
⋮ ,⋯ , ⋮
⁄ ⁄ , …, ⁄ ( ( ))
( )
, , …, evaluated at .If the method converges, then its rate of convergence is two.
The iterations are stopped when ( )
− ( ) < , where is the error tolerance.
E xample1: Perform three iterations of the Newton-Raphson method to solve the system of
+ + = 7
equations Take initial approximation as = 1.5 & = 0.5
+ = 9
Solution:
( ) = + + −7 = 0
( ) = + −9 = 0
( , ) ( , ) 2 + + 2
= =
( , ) ( , ) 3 3
3 −( + 2 )
= where = | | = 3 (2 + ) −3 ( + 2 )
−3 2 +
We can write now the method as
1 3 −( + 2 ) + + −7
⇒ = − , = 0,1,2, …
−3 2 + + −9
Using ( , ) = ( 1.5,0.5) , we get
1.5 1 0.75 −2.5 −3.75 2.2675
= − =
0.5 −14.25 −6.75 3.5 −5.50 0.9254
2.2675 1 2.5691 −4.1183 1.0963 2.0373
= − =
0.9254 −49.4951 −15.4247 5.4604 3.4510 0.9645
2.0013
=
0.9987
E xample2: Solve the system by Newton’s method
10 + sin( + ) = 1
8 − ( − )= 1
12 + = 1
Take one step form a suitable starting point. To obtain a suitable starting point, we use the
approximation sin( + ) ≈ 0 , cos( − ) ≈ 1 & ≈ 0 for the system of equations
Page 35
Numer ical Methods For Engineer s
( , , ) = 10 + sin( + ) − 1 = 0
( , , )= 8 − ( − ) −1 = 0
( , , ) = 12 + −1 = 0
and obtain = , = & =
( ) ( ) ( ) 10 + cos( + ) cos( + ) 0
= ( ) ( ) ( ) = 0 8 − sin 2( − ) sin 2( − )
( ) ( )) ( 0 0 12 +
1 1 1 10.939373 0.939373 0
= , , = 0 8.327195 −0.327195
10 4 12
0 0 12.996530
⎡ , , ⎤
0.091413 −0.010312 −0.000260 0.342898
⎢ ⎥
= 0 0.120089 0.003023 and = ⎢ , , ⎥ = 0.027522
0 0 0.076944 ⎢ ⎥ 0.083237
⎣ , , ⎦
Using the Newton’s method ( )
= ( )
−
We obtain for = 0 = −
( ) ( )
Hence, = 0.0689 , = 0.246443 & = 0.076929 are the first iteration solutions of the
equation using Newton’s method.
Page 36
Numer ical Methods For Engineer s
Page 37
Numer ical Methods For Engineer s
Hence, the solution correct to six decimal places is obtained after five iterations. This implies that
using Newton’s method can be obtaining more accurate solution with in small number of iteration.
E xercise
1. Solve the following system of equations using Gauss-E limination method
− + = 1 + 3 + 6 = 2
(a) −3 + 2 − 3 = −6 (b) −4 + 2 = 7
2 −5 + 4 = 5 3 − + 4 = 9
5 + + + = 1
+ 7 + + = 12
c)
+ + 6 + = −5
+ + + = −6
2. Solve the following set of simultaneous linear equations by the matrix inverse method
2 + 3 − = 1
a. − + 2 + = 8
− 3 − 2 = −13
− + 3 − = 1
−3 + 5 = 2
b.
− + = 0
+ 2 − = −5
3. Solve the following set of simultaneous linear equations using the LU decomposition method
+ + = 9
i. 2 − 3 + 4 = 13
3 + + 5 = 40
2 + − = 6
ii. − 3 + 5 = 11
− + 5 + 4 = 13
4. Solve the following set of simultaneous linear equations using Jacobi and Gauss-Seidal iteration
method
2 − + 5 = 15
a. 2 + + = 7
+ 3 + = 10
5 + 2 + = 12
b. + 4 + 2 = 15
+ 2 + 5 = 20
4 + 2 = 4
2 + 8 + 2 = 0
c.
2 + 8 + 2 = 0
3 + 4 = 14
5. Solve the following systems of non-linear equations by any suitable method
+ = 11
a.
+ = 7
= 3 −7
b.
= 2( + 1)
+ + =
c. + = 1
+ =
Page 38
Numer ical Methods For Engineer s
CHAPTE R FOUR
INTE RPOLATION
The word interpolation denotes the method of computing the intermediate
(approximate) values of the function = ( ) for an between different - values
, , …, at which the values of ( ) are given.
Or, given( , ) , ( , ) , ( , ) , …, ( , ) , find the values of ‘ ’ at a values of ‘ ’
in ( , ) is called interpolation.
The process of computing the value of the function outside the given range is called
extrapolation.
Polynomials are most common choice of interpolation because they are easy to
evaluate, differentiate and integrate.
Interpolation is required in many engineering and science applications that use tabular
data as input.
The polynomial through a specific set of points may take many different forms, but all forms are
equivalent. Any form can be manipulated into any other form by simple algebraic rearrangement
The Taylor series is a polynomial of infinite order. Thus,
( ) = ( ) + ( )( − ) + ( )( − ) + ( ) ( − ) + ⋯----------- (4.1)
! !
It is of course, impossible to evaluate an infinite number of terms. The Taylor polynomial of degree
is defined by
( )= ( )+ ( ) ------------------------------------------------------------------------------------- (4.2)
where the Taylor polynomial ( ) , and the remainder term ( ) are given by
( ) = ( ) + ( )( − ) + ( )( − ) + ⋯ + ( )( ) ( − ) --------- (4.3)
! !
( )= ( )( )( − ) ≤ ≤ ----------------------------------------------- (4.4)
( )!
Page 39
Numer ical Methods For Engineer s
∆
∆
∆ ∆
∆ ∆
∆ ∆ ∆
∆ ∆
∆ ∆
∆
∆
The above table is called a diagonal difference table. The first difference term in the table
,∆ ,∆ ,∆ …, ∆ are called the leading differences.
Alternative Notation of forward difference operator is ∆ ( ) = ( + ℎ) − ( )
This follows that ∆ ( + ℎ) = ( + ℎ + ℎ) − ( + ℎ) = ( + 2ℎ) − ( + ℎ)
Similarly, ∆ ( ) = ∆[ ∆ ( ) ]
= ∆[ ( + ℎ) − ( )]
= ∆ ( + ℎ) − ∆ ( )
Page 40
Numer ical Methods For Engineer s
= ( + 2ℎ) − ( + ℎ) − [ ( + ℎ) − ( ) ]
= ( + 2ℎ) − 2 ( + ℎ) + ( )
∆ is called the second difference of ( ) and ℎ is the step size.
∇
∇
∇ ∇
∇ ⋮
∇ ⋮ ∇ ∇
⋮ … ∇
⋮ ∇ …
⋮ ⋮ ∇ ∇
∇ ∇
∇
Page 41
Numer ical Methods For Engineer s
= ∆ ( )
⋮
∇ ( + ℎ) = ∆ ( )
⁄ = − --------------------------------------------------------- (4.13)
…
= ⁄ − ⁄
⁄ ⁄
⁄ ⁄
The values
⁄ ⁄
…
⁄ ⁄
Page 42
Numer ical Methods For Engineer s
= ( )+ ( )+ ( )+ ⋯
! !
(E xpanding by Taylor’s series method)
= 1+ + + ⋯ ( )
! !
∴ ( )= ( )
Hence, the identity is = .
We have already proved that = ∆ + 1 and = . Apply the algorithm,
Page 43
Numer ical Methods For Engineer s
We get
∆ ∆ ∆
⇒ℎ = = [ 1 + ∆] = ∆ − + − + ⋯
∆ ∆ ∆
⇒ = ∆− + − + ⋯ .
Relation between & ∇: ∇ ( ) = ( ) − ( − ℎ) = ( )− ( )
⇒ ∇= 1 −
∇=
Relation between the operators ∆ , , & : From the definition we know that
( )= + ℎ − − ℎ
i. ( )= + ℎ − − ℎ
⁄ ( )− ⁄ ( )
=
⁄ ⁄
= − ( )
⁄ ⁄
∴ = −
⁄ ⁄
Further ( )= ( − 1) ( ) = ∆ ( )
⁄
∴ = ∆
And from the mean operator result we get
⁄
= ∆
ii. ( )= + ℎ + − ℎ
⁄ ⁄ ( )
= +
1 ⁄ ⁄
∴ = +
2
iii. ∇ ( )= [ ( ) − ( − ℎ) ]
= ( )− ( − ℎ)
= ( + ℎ) − ( ) = ∆ ( )
∴ ∇= ∆
and ∇ ( ) = ∇ ( + ℎ)
= ( + ℎ) − ( ) = ∆ ( )
⇒ ∇ = ∆
∴ ∇= ∇
Page 44
Numer ical Methods For Engineer s
Page 45
Numer ical Methods For Engineer s
Solution:
⁄ ⁄ ⁄
a. since 1 + ∆= therefore + = + 1 = 1+ ∆+ 1 = ∆+ 2
∆ ∇ ( )
b. − = − = − = − = ( − )
∇ ∆ ( )
= {( 1 + ∆) − ( 1 − ∇) } = ( ∆ + ∇)
∆ ∇
Hence,
∇
− = ∆ + ∇.
∆
Page 46
Numer ical Methods For Engineer s
Assume =
( )= =
When =
( ) = = + ( − ) = + ℎ
− ∆
= =
ℎ ℎ
When =
( )= = + ( − )+ ( − )( − )
−
= + ( 2ℎ) + ( 2ℎ) ( ℎ) = + 2( − )+ ( 2ℎ )
ℎ
− 2( − )− −2 + ∆
⇒ = = =
2ℎ 2ℎ 2! ℎ
⋮
∆
⇒ = , = 3,4,5, …
!
Substitute the values in (4.14) we get
∆ ∆
( )= + ( − )+ ( − )( − ) + ⋯.
!
∆
+ ( − )( − ) …( − ) ------------------------------- (4.15)
!
Setting = then − = ℎ
− = −+ − = − −( − )= ℎ − ℎ = ( − 1) ℎ
Similarly, − = ( − 2) ℎ
− = ( − 3) ℎ
⋮
− = ( − ( − 1) ) ℎ
E quation (4.15) reduces to
( )
( )= + ∆ + ∆ + ⋯.
! !
( ) …( ( ))
+ ∆ ------------------------------------ (4.16)
!
The above formula is called Newton’s forward interpolation formula.
It is useful for interpolating near the beginning of the tabular values.
The error term for the Newton forward-difference polynomial can be obtained from the
general error term equation (4.13)
( )= ( − )( − ) …( − ) ( )( )
( )!
We know that − = ℎ, − = ( − 1 ) ℎ,…, − = ( − ( − 1) ) ℎ
Therefore the error term can be written as
( )= ( − 1 ) ( − 2 ) …( − ) ℎ ( )( ) ---------------------- (4.17)
( )!
Page 47
Numer ical Methods For Engineer s
Page 48
Numer ical Methods For Engineer s
Page 49
Numer ical Methods For Engineer s
The above formula (4.20) is called Newton’s back ward interpolation formula.
It is useful for interpolating near the end of the tabular values.
The error term of backward interpolation is also can be written as
( )= ( + 1 ) ( + 2 ) …( + )ℎ ( )( ) ---------------------- (4.21)
( )!
E xample: The area of a circle of diameter is given for the following values.
80 85 90 95 100
Page 50
Numer ical Methods For Engineer s
10 11 12 13 14
10 23967 28060 31788 35209 38368
= 10 23967
4093
= 11 28060 −365
3728 58
= 12 31788 −307 −13
3421 45
= 13 35209 −262
3159
= 14 38368
= 12.2 − 12 = 0.2 ≤ 0.5
( )
0.2 1 1 1.2 0.2
= 31788 + ( 3421 + 3728 ) + + ( −307 )
1 2 2 2 2
1.2 1 1 2.2 1.2
+ ( 45 + 58 ) + + ( −13 )
3 2 2 4 4
Page 51
Numer ical Methods For Engineer s
( )
= 31788 + ( 0.1 ) ( 7149 ) + ( 0.02 ) ( −307) + ( −0.016 )( 103)
+ ( −0.0016) ( −13)
1, =
( )= ∏ and ( )=
0, ≠
In general,
( )( ) …( )
⎧ ( ) +
( )( ) …( )
⎪ ( )( ) …( )
( )= ( ) + ⋯ + ------------------------------------------------ (4.23)
⎨ ( )( ) …( )
⎪ ( )
( )( ) …( )
⎩ ( )( ) …( )
In short this one can be written as
( ) = ( ) ( ) + ( ) ( ) + ⋯+ ( ) ( ) ------------------------------------ (4.24)
Page 52
Numer ical Methods For Engineer s
E xample1: Construct the linear Lagrange interpolation polynomial that pass through the
points ( 2,4) and ( 5,1) .
Solution: ( )= = ( − 5) and ( )= = ( − 2)
So that ( )= ( ) ( )+ ( ) ( )
= ( − 5) ( 4) + ( − 2) ( 1)
= − + 6
( 2,4)
( 5,1)
Page 53
Numer ical Methods For Engineer s
E xample2:
a. Use the number (called nodes) = 2, = 2.75 & = 4 to find the second
Lagrange interpolating polynomial for ( ) = 1 ⁄ .
b. Use this polynomial to approximate ( 3 ) = 1 ⁄3.
Solution:
a. We first determine the coefficient polynomials ( ), ( )& ( ) . In nested form
( . )( )
they are ( )= = ( − 2.75) ( − 4)
( . )( )
( )( )
( )= = ( − 2) ( − 4)
( . )( . )
( )( . )
and ( )= = ( − 2) ( − 2.75)
( )( . )
Also, ( ) = ( 2 ) = 1 ⁄2 , ( )= ( 2.75 ) = 4 ⁄11 ( )= ( 4 ) = 1 ⁄4 ,
So, ( )= ∑ ( ) ( )
= ( − 2.75 ) ( − 4 ) − ( − 2) ( − 4) + ( − 2 ) ( − 2.75 )
= − +
b. An approximate to ( 3 ) = 1 ⁄3 is
9 105 49
( 3) ≈ ( 3) = − + ≈ 0.32955
22 88 44
Page 54
Numer ical Methods For Engineer s
[ , ]− [ , ]
= [ , , ] =
−
The third divided difference is given as
[ , , ]− [ , , ]
= [ , , , ]=
−
[ , ,…, ] [ , ,…, ]
In general, = [ , , , …, ]=
The Newton’s Divided Difference table can be construct as (Table 4)
( ) [ , ] [ , , ] [ , , , ] [ , , , , ]
( )
[ , ]
( ) [ , , ]
[ , ] [ , , , ]
( ) [ , , ] [ , , , , ]
[ , ] [ , , , ]
( ) [ , , ]
[ , ]
( )
The advantage of the above method is that there is no need to start all over again if their
additional pairs of data are added. We simply need to compute additional divided
differences.
Since order polynomial interpolation of a given ( + 1) pairs of datais unique, thus the
above polynomial and Lagrangian polynomial are exactly the same.
E xample: Use Newton’s Divided Difference formula and evaluate ( 3.0) , given
3.2 2.7 1.0 4.8 5.6
22.0 17.8 14.2 38.3 51.7
Solution:
( ) [ , ] [ , , ] [ , , , ] [ , , , , ]
3.2 .
.
2.7 17.8 .
2.118 − .
1.0 14.2 2.012 .
6.342 0.0865
4.8 38.3 2. .63
16.750
5.6 51.7
The third degree polynomial fitting all points from = 3.2 to = 4.8 is given by
( )= + ( − )+ ( − )( − ) + ( − )( − )( − )
Page 55
Numer ical Methods For Engineer s
( , )
( , )
( , )
( , )
( , )
Page 56
Numer ical Methods For Engineer s
E xample: The upward velocity of a rocket is given as a function of time in the table
below.
Find the velocity at = 16 seconds.
, ,/ , , /
0 0 0 0
10 227.4 rewrite in to 10 227.4
20 517.35 15 362.78
15 362.78 ascending 20 517.35
22.5 602.97 22.5 602.97
30 901.67 30 901.67
Solution:
−
( )= + ( − ) , ≤ ≤
−
. .
= 362.78 + ( − 15 ) , 15 ≤ ≤ 20
= 362.78 + 30.913 ( − 15 ) , 15 ≤ ≤ 20
( 16 ) ≈ 362.78 + 30.913( 16 − 15 )
= 393.7 ⁄
The most common piecewise polynomial approximation uses cubic polynomials between
each successive pair of nodes is called cubic spline interpolation.
( )
…
Now we have
+ 1 grid points , ( = 0,1, …, )
intervals ≤ ≤ , ( = 0,1, …, − 1)
cubic spline ( ) , ( = 0,1, …, − 1)
− 1 interior grid points , ( = 0,1, …, − 1)
4 coefficient to be determined
Page 57
Numer ical Methods For Engineer s
Page 58
Numer ical Methods For Engineer s
⇒ ( ) = --------------------------------------------------------------------------------------- (4.35)
( ) ( )
= ( )= − ( + 2 ) ----------------------------------------------- (4.36)
for = 1,2, …,
( ) ( ) ( ) ( )
⇒ + + = − ; -------------------- (4.39)
Where, ( ) = ( ), ( )= ( )= ( ) , and ( ) = ( )
Now for equally spaced arguments ℎ = ℎ equation (4.39) becomes
+ 4 + = [ ( ) −2 ( )+ ( )]; = 1,2, …, − 1---------------- (4.40)
While, ( ) for the equally spaced becomes,
( )= [( − ) + ( − ) ]
+ ( − ) ( )−
( ) 1 2 33 244
Page 59
Numer ical Methods For Engineer s
+ 4 + = [ 33 − 2( 2) + 1 ]
Solution: We have ℎ = 1,
+ 4 + = [ 244 − 2( 33) + 2 ]
4 + = 180
⇒
+ 4 = 1056
Solving this system and then = −24 and = 276
1
( ) = [( − ) + ( − ) ]
6
+( − ) ( ) −
+( − ) ( )−
1
( )= [ ( 1 − ) ( 0) + ( − 0 ) ( −24) ]
6
+ ( 1 − ) 1 − ( 0)
+ ( − 0 ) 2 − ( −24 )
= 4 + 5 + 1, 0≤ ≤1
1
( ) = [( − ) + ( − ) ]
6
+( − ) ( ) −
+( − ) ( )−
1
( )= [ ( 2 − ) ( −24) + ( − 1 ) ( 276) ]
6
+ ( 2 − ) 2 − ( −24)
+ ( − 1 ) 33 − ( 276)
= 50 − 162 + 167 − 53, 1≤ ≤2
1
( ) = [( − ) + ( − ) ]
6
+( − ) ( )−
+( − ) ( )−
1
( )= [ ( 3 − ) ( 276) + ( − 2 ) ( 0) ]
6
+ ( 3 − ) 33 − ( 276)
+ ( − 2 ) 244 − ( 0 )
= −46 + 414 − 985 + 715, 2≤ ≤3
( 2.5 ) = −46( 2.5) + 414( 2.5) − 985 ( 2.5) + 715
( 2.5 ) = . ≈ ( 2.5)
Page 60
Numer ical Methods For Engineer s
E xercise
∆
1. E valuate
2. Show that = + ∆ + ∆ + ∆
3. If ( ) = 2 − + 3 + 1 then show that ∆ ( ) = 12 + 10
4. Find the missing figures in the following table
0 5 10 15 20 25
7 11 18 32
9. Use the following table to evaluate 16° and compare with the exact value.
° 0° 5° 10° 15° 20° 25° 30°
° 0 0.0875 0.1763 0.2679 0.3640 0.4663 0.5774
10. Construct the natural cubic spline for the following data.
( )
0.1 −0.62049958
0.2 −0.28398668
0.3 0.00660095
0.4 0.24842440
11. Use the divided-difference method to obtain a polynomial of least degree that fits the
values shown.
a. 0 1 2 −1 3 b. 1 3 −2 4 5
( ) −1 −1 −1 −7 5 ( ) 2 6 −1 −4 2
Page 61
Numer ical Methods For Engineer s
12. The following table gives the normal weights of babies during the first 12 months of life:
Age in months 0 2 5 8 10 12
Weight in lbs. 7.5 10.25 16 18 18 21
Find the weight of babies during 6.1 month of life.
13. A natural cubic spline is defined by
( ) = 1 + ( − 1 ) − ( − 1) 1≤ ≤2
( )= 3
( ) = 1 + ( − 2 ) + ( − 2) + ( − 2) 2≤ ≤3
4
If is interpolates the data( 1,1) ,( 2,1) , and ( 3,0) , find , , , and .
Page 62
Numer ical Methods For Engineer s
CHAPTE R FIVE
LE AST SQUARE ME THOD
= +
To answer this question, suppose that a guess is made about the correct values of
and . This is equivalent to deciding on a specific line to represent the data. In general,
the data points will not fall on the line = + . If by chance the datum falls on
the line, then
+ − = 0
If it does not, then there is a discrepancy or error of magnitude
| + − | ≠0
The total absolute error for all ( + 1) points is therefore
( , ) = ∑ | + − |
In practice, it is common to minimize a different error function of and :
( , ) = ∑ ( + − ) ------------------------------------------------------------- (5.3)
Page 63
Numer ical Methods For Engineer s
E xample1: Find the linear least-squares solution for the following table for the values
4 7 11 13 17
2 0 2 6 7
Plot the original data points and the line using a finer set of grid points.
Solution: To find the values of the normal equations using table
Number of data
0 4 2 8 16
1 7 0 0 49
2 11 2 22 121
3 13 6 78 169
4 17 7 119 289
+ 1= 5
= 52 = 17 = 227 = 644
644 + 52 = 227
52 + 5 = 17
Solving the system of equations, we get = 0.4864 and = 1.6589
Therefore, the linear line that fit the given data points is = 0.4864 − 1.6589
The sum of the total error squares will be obtained as
( , ) = ∑ ( 0.4864 − 1.6589 − )
= 2.9354 + 3.0482 + 2.8612 + 1.7841 + 0.1522 = 10.7813
Page 64
Numer ical Methods For Engineer s
E xample2: Find the best fit values of and so that = + fits the data given in
the table
0 1 2 3 4
1 1.8 3.3 4.5 6.3
= ∑ −2∑ ∑ + ∑ ∑
= ∑ −2∑ ∑ + ∑ ∑ ∑
As in the linear case, for to minimized is necessarily that ⁄ = 0 , ,…,
Thus, for each , we must have
0= = −2 ∑ + 2∑ ∑
This gives ( + 1) normal equations in the ( + 1) unknowns . These are
∑ ∑ = ∑ --------------------------------------------- (5.5)
( , ,…, )
It is helpful to write equation (5.5) as follows:
∑ + ∑ + ∑ + ⋯+ ∑ = ∑
⎧
∑ + ∑ + ∑ + ⋯+ ∑ = ∑
⎨ ⋮
⎩ ∑ + ∑+ + ⋯+ ∑ ∑ = ∑
These normal equations have a unique solution provided that the ’s are distinct.
E xample: Fit the data below with the discrete least squares polynomial of degree at
most 2 .
1 0 1.0000
2 0.25 1.2840
3 0.50 1.6487
4 0.75 2.1170
5 1.00 2.7183
Page 65
Numer ical Methods For Engineer s
Solution: For this problem, = 2, = 5 , and the three normal equations are
∑ + ∑ + ∑ = ∑
∑ + ∑ + ∑ = ∑
∑ + ∑ + ∑ = ∑
5 + 2.5 + 1.875 = 8.7680
2.5 + 1.875 + 1.5625 = 5.4515
1.875 + 1.5625 + 1.3828 = 4.4015
Solving the system of equations gives
{ = 0.9268, = 1.1383, = 0.6401 }
Thus the least squares polynomial of degree 2 fitting the data in the above table is
( ) = 0.9268 + 1.1383 + 0.6401
The total error use this table
1 2 3 4 5
0 0.25 0.50 0.75 1.00
1.0000 1.2840 1.6487 2.1170 2.7183
(
) 0.9268 1.2514 1.6560 2.1406 2.7052
− ( ) 0.0732 0.0326 −0.0073 −0.0236 0.0131
b. E xponential
Suppose an exponential curve of the form =
Taking logarithm on both the sides,
We get log = log + log --------------------------------------------------------- (5.6)
That is, = + where = log , = log , = log
The normal equation for (5.6) is,
∑ = + ∑
---------------------------------------------------- (5.7)
∑ = ∑ + ∑
On solving the above two equations, we get and .
Page 66
Numer ical Methods For Engineer s
Then = log , =
E xample: Fit a curve = to the following data:
x 2 3 4 5 6
y 144 172.8 207.4 248.8 298.5
= ∑ −( + )
By the principle of least square, the value of is minimum
Therefore, = 0 and = 0
= 0 ⟹∑ 2 − − (− ) = 0
⇒ ∑ = ∑ + ∑ ---------------------------------------------------- (5.8)
and = 0 ⟹∑ 2 − − (− ) = 0
⇒ ∑ = ∑ + ∑ ----------------------------------------------- (5.9)
Dropping the suffix in (5.8) and (5.9) then the normal equations are,
Page 67
Numer ical Methods For Engineer s
∑ = ∑ + ∑
√
--------------------------------------------------------------- (5.10)
∑ √ = ∑ + ∑
√
E xample: Use the method of least squares to fit the curve = + √ to the
following table of values:
0.1 0.2 0.4 0.5 1 2
21 11 7 6 5 6
Solution:
√ 1 1 √
√
0.1 21 0.3162 3.1623 100 210 6.6402
0.2 11 0.4472 2.2361 25 55 4.9192
0.4 7 0.6324 1.5811 6.25 17.5 4.4268
0.5 6 0.7071 1.4142 4 12 4.2426
1 5 1 1 1 5 5
2 6 1.4142 0.7071 0.25 3 8.4852
1 1
√ √
√
= 4.2 = 4.5171 = 10.1008 = 136.5 = 302.5 = 33.714
∑ = ∑ + ∑
√ 302.5 = 136.5 + 10.1008
⇒
∑ √ = ∑ + ∑ 33.714 = 10.1008 + 4.2
√
Solving the system of equations we get = 1.9733 and = 3.2815
.
Hence the required curve fit equation is = + 3.2815 √ .
Page 68
Numer ical Methods For Engineer s
Since = ∫ [ ( )] −2∑ ∫ ( ) + ∫ (∑ )
We have, = −2 ∫ ( ) + 2∑ ∫
Hence to find ( ) , the ( + 1) normal equations
∑ ∫ = ∫ ( ) for each = 0,1, …, --------------------------- (5.12)
We will be solved for ( + 1) unknown . The difficulties in obtaining least squares
polynomial approximation ( + 1 ) × ( + 1) linear system for unknowns , ,..,
must be solved and the coefficients in the linear system are of the form
⎡1 ⎤ ⎡ ⎤
⎢ ⎥ ⎢ ⎥
⎢ ⎥ = ⎢ ⎥
⎢ ⎥ ⎢ ⎥
⎣ ⎦ ⎣ ⎦
We get = ≈ −0.050465 = − = ≈ 4.12251
Consequently, the least square approximating polynomial of degree 2 for the function
( )= on the interval [ 0,1] is
( ) = −0.050465 + 4.12251 − 4.12251
Page 69
Numer ical Methods For Engineer s
Now however, assume that we have five times the confidence in the accuracy of the
final two data points, relative to the other points.
Define a square weighting matrix :
1 0 0 0 0
⎛0 1 0 0 0 ⎞
= ⎜0 0 1 0 0 ⎟
0 0 0 5 0
⎝0 0 0 0 5 ⎠
Now we perform the following operations:
∗ =
∗ ∗ = ∗
( ∗ ) ∗( ∗ )∗ = ( ∗ ) ∗ ∗
= [( ∗ ) ∗ ( ∗ )] ∗ ( . ) ∗ ( ∗ )
= [ ∗ ] ∗ ∗ ----------------------------------- (5.13)
0.1365
=
1.5105
Then the best fit estimate is = 0.1365 + 1.5105
b. Weighted Least Square for continuous functions
Definition: An integrable function ( ) is called a weight function on the interval if
( ) ≥ 0 for all in , but ( ) ≠ 0 on any subinterval of .
The purpose of a weighted function is to assign varying degrees of important to
approximations on a certain portions of the interval.
The function which are continuous on [ , ] and are given explicitly, we have
= ∫ ( )[ ( ) − ( )]
Where ( )= + + ⋯+ + = ∑
⇒ = ∫ ( ) ( ) −∑ = minimum
The necessarily condition is to have a minimum value is that = 0 , = 0,1, . . ,
Page 70
Numer ical Methods For Engineer s
= −2 ∫ [ ( 1 + 2 ) −( + + )] = 0
= −2 ∫ [ ( 1 + 2 ) −( + + )] = 0
This gives
⎧ + + =
⎪
⎪
2 3
−
+ + =
⎨ 2 3 4 2
⎪
⎪ 2 −3
⎩3 + + =
4 5 6
Solving the system of equations
= 1.9549, = −0.6079, = 0.0000
( ) = 0.0000 − 0.6079 + 1.9549
For = 2 and ( ) =
We have = ∫ [(1 + 2 )−( + + )]
The normal equations are
= −2 ∫ [ ( 1 + 2 ) −( + + )] = 0
= −2 ∫ [ ( 1 + 2 ) −( + + )] = 0
= −2 ∫ [ ( 1 + 2 ) −( + + )] = 0
This gives
⎧ + + =
⎪
+ + =
⎨
⎪
⎩ + + =
Solving the system of equations
= 3.4441, = −2.5040, = 0.5029
( ) = 0.5029 − 2.5040 + 3.4441
Page 71
Numer ical Methods For Engineer s
E xercise:
1. Fit a straight line = + to the following data by method of least square
0 1 3 6 8
1 3 2 5 4
2. Fit the second degree parabola to the following data by the least square method
1 2 3 4 5
1090 1220 1390 1625 1915
4. A pressure and volume of gas are related by the equation = ( and are
constants). Fit this equation to for the data given below
0.5 1.0 1.5 2.0 2.5 3.0
1.62 1.0 0.75 0.62 0.52 0.46
5. Find the normal equations that arise from filling by the least squares method, an
equation of the form = sin , to set of points ( 0,0 ) , , 1 , ( , 3) and
Page 72
Numer ical Methods For Engineer s
CHAPTE R SIX
NUME RICAL DIF F E RE NTIATION AND INTE GRATION
6.1. Numerical Differentiation
The method of obtaining the derivatives of a function using a numerical technique is
known as Numerical Differentiation. Numerical Differentiation is required for these two
situations
1. The function values are known but the function is unknown, such functions are
called tabular functions.
2. The function to be differentiating is complicated and therefore it is difficult to
differentiate. The choice of formula
a. Newton forward/backward formula – if the derivative at a point near the
beginning/end of a set of values respectively.
b. Newton divided difference/Lagrange Interpolation formula – if the values of
are not equally spaced.
6.1.1. Derivative using Newton’s forward interpolation formula:
Consider Newton’s forward interpolation formula
( ) ( )( )
= + ∆ +
!
∆ +
!
∆ + ⋯------------------- (6.1)
= ----------------------------------------------------------------------------- (6.2)
Differentiation (6.1) with respect to we get
= ∆ + ∆ + ∆ + ⋯------------------------------- (6.3)
Differentiation (6.2) with respect to we get
= -------------------------------------------------------------------------------- (6.4)
⇒ = ∆ + ∆ + ∆ + ⋯ --------------------- (6.5)
= ∆ + ( − 1) ∆ + ∆ + ⋯ ----------- (6.7)
Putting = 0 in (6.7) we have
= ∆ −∆ + ∆ − ⋯ ------------------------------- (6.8)
Page 73
Numer ical Methods For Engineer s
⇒ = ∇ + ∇ + ∇ + ⋯ -------------------- (6.13)
= ∇ + ( + 1) ∇ + ∇ + ⋯ --------------- (6.15)
Putting = 0 in (6.15) we get
= ∇ + ∇ + ∇ + ⋯ --------------------------- (6.16)
Page 74
Numer ical Methods For Engineer s
= 7 − ( 12 ) + ( 6) = 3
= ∆ −∆ + ∆ −⋯
= [ 12 − 6 ] = 6
We have = 1 , ℎ = 1, and = 1.5 ⇒ = 0.5
= ∆ + ∆ + ∆ + ⋯
( . ) ( . ) ( . )
= 7+ ( 12) + ( 6)
= [ 7 − 0.25 ] = 6.75
= ∆ − ∆ + ∆ − ∆ + ⋯
= 19 − ( 18 ) + ( 6 ) = 12
= ∆ −∆ + ∆ −⋯
= [ 18 − 6 ] = 12
E xample 2: A rod is rotating in a plane about one of its ends. If the
following table gives the angle radians through which the rod has turned
for different values of time seconds, find its angular velocity at = 0.7 .
, sec 0 0.2 0.4 0.6 0.8 1
Page 75
Numer ical Methods For Engineer s
.
= = 1, ℎ = 0.2 and = = 0.7 where = = −1.5
.
From Newton’s interpolation formula, we have
= ∇ + ∇ + ∇ + ⋯
.
( . ) ( . ) ( . )
= 1.2 + ( 0.3 ) + ( 0.02 ) + ⋯
.
Page 76
Numer ical Methods For Engineer s
Since, = ⇒ = + ℎ ⇒ = ℎ
= , ⇒ = = = 0, ⇒ = 0
and when ( )
= + ℎ, ⇒ = = = , ⇒ =
E xpression (6.18) can be written as
+ ∆ + ∆ + ∆
= ∫ ℎ
+ ∆ + ⋯
Therefore,
∆ ∆
+ ∆ + − + − +
= ℎ --------- (6.19)
∆
+ − + −3 + ⋯
The equation (6.19) is called General Gauss Legendre Quadrature
formula, for equidistant ordinates from which we can generate any
Numerical integration formula by assigning suitable positive integral value
to .
a. Trapezoidal rule
Substituting = 1 in the relation (6.19) and neglecting all differences
greater than the first we get
= ∫ ( ) = ℎ + ∆ = [2 + − ]
Page 77
Numer ical Methods For Engineer s
= ∫ ( ) = [ + ]
= ∫ ( ) = [ + ]
⋮
= ∫ ( )
( ) = [ + ]
Now adding , , …, we get
+ + ⋯+ =
∫ ( ) + ∫ ( ) + ⋯+ ∫ ( )
( )
= [ + ]+ [ + ] + ⋯+ [ + ]
⇒ ∫ ( ) = [( + )+ ( + ) + ⋯+ ( + )]
= [( + ) + 2( + + ⋯+ ) ] -------------------------- (6.20)
The formula (6.20) is called Trapezoidal rule for numerical integration.
The error committed in this formula is given by
( )
≈− ( ) = − ( ) .
b. Simpson’s ⁄ rule
Substituting = 2 in the General quadrature formula given by (6.19) and
neglecting the third and other higher order differences
We get
∆
= ∫ ( ) = ℎ 2 + 2∆ + −2
= ℎ 2 + 2( − )+ ( −2 + )
= [ + 4 + ]
Similarly,
= ∫ ( ) = [ + 4 + ]
= ∫ ( ) = [ + 4 + ]
⋮
⁄ = ∫ ( )
( ) = [ + 4 + ]
Adding , , …, ⁄ we get,
= + + ⋯+ ⁄ =
∫ ( ) + ∫ ( ) + ⋯+ ∫ ( )
( )
= [ + 4 + ]+ [ + 4 + ]+ ⋯
+ [ + 4 + ]
Page 78
Numer ical Methods For Engineer s
( + )
= +4 ( + + ⋯+ ) -------------------------------------- (6.21)
+ 2( + + ⋯+ )
The above rule is known as Simpson’s one-third rule . The error
committed in Simpson’s one-third rule is given by
( )
≈− ( )( )= − ( )( ) .
c. Simpson’s ⁄ rule
We assume that within any three consecutive sub-intervals of width ℎ,
the interpolating polynomial ( ) approximating ( ) is of degree 3.
Hence substituting = 3, i.e., the General quadrature formula and
neglecting all the differences above ∆ , we get
= ∫ ( )
∆
= ℎ 3 + ∆ + 9− ∆ + − 27 + 9
3 + 9( − )+ ( −2 + )
= ℎ
+ ( −3 + 3 + )
= [ + 3 + 3 + ]
Similarly
= ∫ ( ) = [ + 3 + 3 + ]
⋮
⁄ = ∫ ( )
( ) = [ + 3 + 3 + ]
Adding , , …, ⁄ we get,
= + + ⋯+ ⁄ =
( + )+
= 3( + + + + ⋯+ + ) -------------- (6.22)
+ 2( + + ⋯+ )
Simpson’s three-eighths rule can be applied when the range [ , ]
is divided into a number of subintervals, which must be a
multiple of 3.
The error in Simpson’s three-eighths rule is
≈− ( )( ) .
Page 79
Numer ical Methods For Engineer s
⇒ ∫ ( ) = ∫ +
= ∫ + ---------------------------- (6.25)
a. One point Gaussian quadrature formula
For = 1, 2 − 1 ⇒ 2 ( 1 ) − 1 = 1 (degree one polynomial)
∫ ( ) ≈ ( ), ≤ ≤ , ( )= +
∫ ( + ) = + = ( − )+ - (6.26)
( )= [ + ]= + ( ) ------------------------- (6.27)
From (6.26) and (6.27) = − and =
( )( )
⇒ = ( − ) = = ⇒ =
⇒ ∫ ( ) ≈ ( )= ( − ) ( )
Page 80
Numer ical Methods For Engineer s
+ + + ( )
( )+ ( )=
+ ( + + + )
( + )+ ( + )
= ----------- (6.30)
+ ( + )+ ( + )
We have the four equations
+ = 2
⎫
+ = 0⎪
and can be determine the four
+ = ⎬
⎪
+ = 0⎭
unknowns , , , .
Solving simultaneously, we get = = 1 and
= ± and = ∓ .
√ √
Therefore, the two point Gauss quadrature is given by
∫ ( ) ≈ − + ---------------------------------------- (6.31)
√ √
.
E xample1: E valuate the integral = ∫ . 5 using Gauss
quadrature two point formula.
Solution: first transfer the interval [ 0.1,1.3] to [ −1,1] .
Let = +
1.3 = ( 1) +
⇒ ⇒ = 0.6 and = 0.7
0.1 = ( −1) +
= 0.6 + 0.7
( . . ) . .
Then 5 = 5( 0.6 + 0.7) = ( 3 + 3.5) and
= 0.6
.
Therefore, ∫ . 5 = ∫ ( 0.6) ( 3 + 3.5) . .
= ∫ ( 1.8 + 2.1) . .
.
≈ − +
√ √
. . . .
= ( 1.8( − ) + 2.1) √ + ( 1.8( ) + 2.1) √ ,
√ √
= 0.52299 + 0.38719 = 0.91018
.
The exact solution of the integral ∫ . 5 is 0.8939.
Page 81
Numer ical Methods For Engineer s
Then = = and =
( )
Therefore, ∫ = ∫ = ∫
≈ − + = +
√ √
√ √
= 0.41277 + 0.27954 = 0.69231
c. Three point Gaussian quadrature formula
For = 3, 2 ( 3 ) − 1 = 5 (degree five polynomial)
∫ ( ) ≈ ( )+ ( )+ ( ), ≤ ≤ ,
≤ ≤ and ≤ ≤
Choose the function ( ) = + + + + +
From integral calculus,
∫ ( + + + + + )
= ( 2) + ( 0) + + ( 0) + ( )+ ( 0) ------ (6.32)
And from
( )+ (
)= )+ (
( + + + + + )
+ ( + + + + + )
( + + + + + )
( + + )+ ( + + )
= + ( + + )+ ( + + ) ----- (6.33)
+ ( + + )+ ( + + )
We have the four equations
+ + = 2
+ + = 0⎫
⎪
+ + = ⎪
and can be determine the six
+ + = 0⎬
+ + = ⎪
⎪
+ + = 0⎭
unknowns , , , , , .
Page 82
Numer ical Methods For Engineer s
= , = , = and = ± , = 0, = ∓ .
∫ ( ) ≈ ( )+ ( 0) + (− ) ----------------------- (6.34)
To evaluate = ∫ ≈ 5 ( ) + 8 ( 0) + 5 (− )
= ( 5) + ( 8) + ( 5) = 0.693122
Page 83
Numer ical Methods For Engineer s
= ∫ ∫ ( , ) ------------------------------- (6.35)
. .
E xample: E valuate = ∫ ∫
Take
a. ℎ = 0.2 in -direction by Simpson’s 3 ⁄8 rule, and = 0.3 in
-direction by Simpson’s 1 ⁄3 rule
b. in both direction by Trapezoidal rule
Solution: Calculate the values of ( , ) =
4 4.2 4.4 4.6
Page 84
Numer ical Methods For Engineer s
Then,
2 2.3 2.6
( ) 0.0698 0.0608 0.0538
E xercise
1. find and at = 1, = 2
1 2 3 4 5 6
1 8 27 64 125 216
2. Find the first and second derivative for = 15, = 23
15 17 19 21 23 25
= √ 3.873 4.123 4.359 4.583 4.796 5.000
3. The table given below reveals the velocity ‘ ’ of a body during the time ‘ ’ specified. Find its
acceleration at = 1.1.
1.0 1.1 1.2 1.3 1.4
43.1 47.7 52.1 56.4 60.8
4. A rod is rotating a place the following table given the angle (radian) through with the rod has
turned for various values of the time seconds find
a. the angular velocity of the rod
b. its angular acceleration when = 1.0
0 0.2 0.4 0.6 0.8 1.0 1.2
0 0.122 0.493 1.123 2.022 3.200 4.666
5. E valuate using Trapezoidal rule
i. ∫ ( )
⁄
ii. ∫ (
√
)
6. E valuate the integral using Simpson’s rule dividing the range in to eight equal parts
log( 1 + )
1+
7. E valuate the problem #6 using two point and three point Gauss quadrature formula.
. .
8. Find the value of the double integral = ∫ ∫ (1 − )
a. using Simpson’s rule ℎ = 0.4, = 0.5
b. using Simpson 3⁄8 rule
Page 85
Numer ical Methods For Engineer s
CHAPTE R SE VE N
NUME RICAL SOLUTIONS OF DIF F E RE NTIAL E QUATIONS
Page 86
Numer ical Methods For Engineer s
= + + + + ⋯
! ! !
Now = ( , ) = 1+ = 1 + ( 0.1) 1103 = 1.21103
= ( , )= + = 2.1103 + ( 0.1) 21103 = 2.2314
= ( , )= 2 + = 2( 2.21103 ) + ( 0.1) 2.2314 = 2.6452
. ( . ) ( . )
Therefore, = 2.1103 + ( 1.21103) + ( 2.2314) + ( 2.6452 ) = 2.2430
! ! !
( 0.2) = 2.2430
c. The Taylor’s algorithm for the third approximation is
= + + + + ⋯
! ! !
Now = ( , ) = 1+ = 1.4486
= ( , )= + = 2.53272
= ( , )= 2 + = 3.4037
. ( . ) ( . )
Therefore, = 2.2430 + ( 1.4486) + ( 2.53272) + ( 3.4037 ) = 2.4011
! ! !
( 0.3) = 2.4011
2. E uler’s Method
The Taylor’s series method that we have discussed in the previous section yields solution of
differential equations in the form of a power series.
We now proceed to describe methods which give the solution in the form of table values at equally
spaced points.
Consider the first order differential equation
= ( , ) with initial condition ( )= ---------------------------------------------------------- (7.5)
Suppose that we want to solve (7.5) for at the points = + ℎ( , , ,…)
Integrating (7.5) between the points and we get
∫ = ∫ ( , )
Hence = + ∫ ( , ) ---------------------------------------------------------------------------- (7.6)
Assume that ( , ) = ( , ) in ≤ ≤ , we get
= + ( − ) ( , )
∴ = + ℎ ( , ) -------------------------------------------------------------------------------------- (7.7)
Similarly if ≤ ≤ , we have
= + ( , )
Page 87
Numer ical Methods For Engineer s
Page 88
Numer ical Methods For Engineer s
( )
= = + ℎ ( + ℎ, )
= 2.1105 + 0.1[1 + ( 0.1) ( 2.1105) ] = 2.2316
( ) ( )
= + ( , )+ ,
.
= 2.1105 + [1 + ( 0.1) ( 2.1105 ) + 1 + ( 0.2) ( 2.2316 ) ] = 2.2434
( ) ( )
= + ( , )+ ,
.
= 2.1105 + [1 + ( 0.1) ( 2.1105 ) + 1 + ( 0.2) ( 2.2434) ] = 2.2435
( ) ( )
= + ( , )+ ,
.
= 2.1105 + [1 + ( 0.1) ( 2.1105 ) + 1 + ( 0.2) ( 2.2435) ] = 2.2435
Final value = 2.2435
( )
Starting value of = + ℎ ( + 2ℎ, ) , using Euler’s method
=
= 2.2435 + ( 0.1) [1 + ( 0.2) ( 2.2435) ] = 2.3884
( ) ( )
= + ( , )+ ,
.
= 2.2435 + [1 + ( 0.2) ( 2.2435) + 1 + ( 0.3) ( 2.3884) ] = 2.4018
( ) ( )
= + ( , )+ ,
.
= 2.2435 + [1 + ( 0.2) ( 2.2435) + 1 + ( 0.3) ( 2.4018) ] = 2.4020
( ) ( )
= + ( , )+ ,
.
= 2.2435 + [1 + ( 0.2) ( 2.2435 ) + 1 + ( 0.3) ( 2.4020 ) ] = 2.4020
Final value = 2.4020
Hence, = 2.1105 , = 2.2435 and = 2.4020
4. Runge-Kutta Method
The Taylor’s series method of solving differential equation numerical is handicapped by the problem
of finding the higher order derivatives. Euler’s method is less efficient in practical problems since it
requires ℎ to be small for obtaining reasonable accuracy.
The Runge-Kutta Methods do not require the calculations of higher order derivatives and they are
designed to give greater accuracy with the advantage of requiring only the function values at some
selected points on the sub-interval.
i. First order R-K method
E uler’s method is the R-K method of first order.
ii. Second order R-K method
The Modified Euler’s formula is
ℎ
= + ( , )+ + ℎ, + ℎ ( , )
2
= + ( + ) where = ℎ ( , ) and = ℎ ( + ℎ, + )
Hence the Modified Euler’s method is the R-K method of second order.
iii. Third order R-K method
= + ( + 4 + ) where = ℎ ( , ), = ℎ + ℎ 2, + 2
= ℎ ( + ℎ, + ,) [ ,
= ℎ ( + ℎ, + )]
Page 89
Numer ical Methods For Engineer s
E xercise:
Page 90
Numer ical Methods For Engineer s
1. Use the E uler’s method to solve the following differential equation over the interval [0,1]
With the step size ℎ = 0.2
= − + + , ( 0) = 1
Page 91