0% found this document useful (0 votes)
50 views95 pages

Math 421 422-Part 1

Numerical analysis provides methods for solving problems that cannot be solved analytically or have complicated analytical solutions. It involves developing arithmetic methods for solving mathematical problems and analyzing the convergence, accuracy, and other properties of such methods. Examples of problems that require numerical methods include finding all roots of polynomials, solving differential equations, and evaluating integrals. Numerical analysis must account for different types of errors that can occur in calculations, such as rounding errors, human errors, empirical errors from measurements, and truncation errors from approximating infinite sums or integrals. The accuracy of approximations is measured using absolute and relative errors. Error in variables can also affect the accuracy of calculations involving functions.

Uploaded by

Juasadf Iesaf
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
50 views95 pages

Math 421 422-Part 1

Numerical analysis provides methods for solving problems that cannot be solved analytically or have complicated analytical solutions. It involves developing arithmetic methods for solving mathematical problems and analyzing the convergence, accuracy, and other properties of such methods. Examples of problems that require numerical methods include finding all roots of polynomials, solving differential equations, and evaluating integrals. Numerical analysis must account for different types of errors that can occur in calculations, such as rounding errors, human errors, empirical errors from measurements, and truncation errors from approximating infinite sums or integrals. The accuracy of approximations is measured using absolute and relative errors. Error in variables can also affect the accuracy of calculations involving functions.

Uploaded by

Juasadf Iesaf
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 95

INTRODUCTION

Numerical Analysis
Numerical methods were developed to help us to solve
problems which we either can not solve at all analytically (
i.e/ by some kind of formula) or where the analytical
solution is so complicated that it is virtually unusable
Numerical analysis : is concerned with the theory of such
methods and the analysis of their convergence and
accuracy properties.
Examples of problems

we can not solve analytically :


1) Find all seven roots of: 3x  4 x  2 x  8  0
7 4

For centuries mathematicians tried to find a formula for solving the


general equation of the 5th degree:

ax  bx  cx  dx  ex  f  0
5 4 3 2

But it was proved by A bell in 1823 that no such formula can exist
2) Solve
x
e  Sin Tx.
Analytically an infinity of roots which approach the positive integers

as x 
3) Solve the differential equation

dy
dx
 x  Sin y
4) Evaluate 1 dx
 0
1 x 5

In order to solve such problems it has been found


necessary to create the subject of numerical analysis,
which is concerned firstly with the development and use of
methods for solving mathematical problems based upon
the operations of arithmetic and secondly with the study of
the convergence and accuracy, and other related
properties of such methods.
ERROR

In numerical analysis error plays a key part. We begin by looking at


the Kind of error that can occur in a calculation there are four main
types.
1) Rounding errors:
Since computers as well as human being can only work to a finite
number of decimal places. Most of the numbers we deal with will be
approximation to their true values.
In a computer working in binary the only numbers accurately
represented are those of the from N where N and K are in
legers. 2k
A number which is irrational i.e/ not representable by a fraction such
as can 2not be accurately represented in any number base

2  1.4142
When we accept an approximation to a real number we are
introducing rounding error.

Definition:
A number y is said to be an approximation to another number x
which is correct to K p.d if.

k
x y  1 10
2
Example:
How accurate an approximation to  is 22 7 ?

Solution:
  3.14159265....
22  3.14285714....
7
Hence   22 7  0.0012....
And since 1 1
2 3
0.005  10  0.0012  10  0.0005
2 2
We see that the approximation is correct to only 2 d.p.
 to 2 d . p is 3.14.error is then 0.0015
  3.15 gires an error 0.0084...(worse )
 to 3d . p is 3.142error is then 0.0004
  3.141 gives an error 0.00059(worse )

A number is said to be rounded to K-places of decimals if it has


k digits after the decimal point and the absolute value of the
difference between the true value of the number and its rounded
value doesn't exceed k
1  10
2
│( true value)- ( Approximate value)│
k
 1 10
2
Effect of rounding errors in along series of calculations:
Take a case such as
19
1

n 11 n
1) work out each value.

1 , 1 , 1 ,..., 1 to 6d . p
11 12 13 19
And then add up =0.618771
= 0.619 to 3 d.p.
2) work out each value 1 , 1 , 1 to 3 p.d and then add up =
11 12 19
0.620
Value correct to 6 d.p is 0.618771
Value after rounding each term correct to 3 d.p and them add up is
0.620
Hence error = 0.0012
Each of the 9th term in the sum is correct to 3 d.p ie/ its error
( rounding) lies between
1 3 3
 10 and  1 10
2 2
So, the accumulated rounding error can not exceed

1
9  103  0.0045
2 1
In fact the accumulated rounding error is only about of this
4
caused by cancellation of positive and negative errors.
19
1
0.614  
n 11 n
 0.623
If we had added N such numbers the worst possible A.R.E would
N 10 3
be 2 from probability theory it is known that if rounding error
are independent then A.R.E is proportional to N
If we carry out a computation involving multiplications or divisions on
numbers which have been rounded to K d.p we can say very little about
the probable A.R.E.
Example:
From the product (3.90+1.22) (5.46+3.59)
(i) Directly :
(ii) As the sum of the four products rounding all numbers
to 2 d.p at each stage?

Solution:

(i) (3.90 + 1.22) ( 5.46+3.59)


= (5.12) (9.05) = 46.43 to 2 d.p
(ii) 3.90 x 5.46 + 3.90 x 3.59 + 1.22 x 5.46 + 1.22x3.59
= 21.29 + 14.00 + 6.66 + 4.38
= 46.33
Had we performed all the intermediate calculation to 4 d.p
we would have obtained 46.3360 which on rounding to 2
d.p agrees with first answer.
The phenomenon is an inevitable consequence of
rounding with experience numerical analysis learn how to
arrange their calculations so that the effect of rounding
errors is minimized.
Hence it is correct to 5 d.p iii  721 228  3.16228076
721
10   0.00000310
228
1 10 6  0.0000031  1 10 5
2 2

Home work No 1.
Q: The fractions 19 ,117 , 721
6 37 228

Are all approximations to 10 : given that

10  3.16227766 to 8d . p
find the accuracy of these approximation?
Solution:

(i ) 10  3.16227766
19  3.16666666
6
 10  19  0.00438900
6
1  10 3  0.00438900  1  10  2
2 2
Hence it is correct to 2d.p
(ii )117  3.16216216
37
10  117  0.00011550
37
1 10  4  0.00011550  1  10 3
2 2
Hence it is correct to 2d.p
2) Human errors:
In hand work or desk machine work human errors are all too
common
The most frequent types are:
a) Transposition of 2 digits e.g/writing 17236 instead of
17326.
b) Repetition of the wrong digit e.g/writing 39967 instead of
39667
c) Forgetting a negative sign infront of a number.
3) Empirical errors:
Measurement of data depends on the instrument.
Hence there is a limited accuracy.
One should not aim for impossible accuracy.
4) Truncation errors:
This occurs if we have to sum an infinite series. e.g/
1) S   1

n 1 n4
we must approximate.
This by stopping after say ( N-terms) thus taking
N
1
S  n 1 n4
the sum of the series we have ignored

1

n  N 1 n4 Is then the truncation error.
2) Another case if

I  f ( x) dx
0

we usually approximate by say



N
0
f ( x) dx In which
N
f ( x ) dx

Is the truncation error.


Thus if we wish to evaluate an infinite sum


S   n 1
an and we stop after N terms.
N
i.e/ S   an
n 1
a
every term of n
is likely to have its own rounding
error adding N such terms produces accumulated
Rounding error (ARE).
The part ignored


n  N 1
an

is the truncation error.


Absolute error and relative error:
The error or as it is also called the absolute error, in an
approximation to a number is defined as follows:
Error = (True value) – ( Approximate value).
The trouble with absolute error is that it is not
immediately obvious how series this is
A better measure of error some times is the
relative error. Which

we define to be relative error= Error


True value
Effect of error in variable in a calculation:

Suppose we have a variable x and that it is Known only to


within an error i.e.
We can only be sure that the tree value of the variable
between x  and xlies
 in the interval
x  , x  
We assume 
is small in relation to x suppose
we wich to compute the value of

some function f x.What


 can we say about
the size of the error when compute f ?x 
Suppose real true value of x is x 0 and the error is
 we thus are computing
f x0  
when we really want

f x0  Now, if f x is continuous and differentiable in the


neighborhood of x 0then.
f  x0    f ( x 0 )
 f \  x0 
x0    x0
f x0    f ( x0 )  f ( x0 )
\

ie/ The error in computing f ( x) at x0 Is approximately

 f ( x) `
e.g / log e x the error would be 
x

more generally if we are computing the value of


function of n variables f ( x1 ,..., xn ) where the error in
xi is i

thus estimate of the error when we compute



f x ,.., x is
1 n 

f f f
 1  2  ...  n
x1 x2 xn
Continuity:
A function f (x) from is discontinuous at a if

f ( x)  f (a) as x  a
f can be discontinuous in three Different, ways

(i) lim xa f ( x) don't exist.

(ii ) lim xa f ( x) exists but f ( x)  f ( a)

(iii ) f (a) (a) is not defined.


Differentiability:
Derivative of a function
f (x) at point a is the rate of change of f with respect to

x at a. So, define derivative of f (x)at a to be

f ( x  h)  f ( a )
lim ha
h
provided this limit exists.
Example:
Suppose x  3 1 , y  5 2 1  0.2 , 2  0.3
y x
Find bounds on the value of ?
y x

Solution:
(i ) y  x  5 2 3 1
 2 2  1
 0.2 1  0.2
 0.3 2  0.3

y x could at worst be = 2 -0.3 – 0.2


 y  x  1.5 OR y  x  2  0.3  0.2 y  x  2.5
1.5  y  x  2.5
(ii ) y  x  8 1  2

i.e / 7.5  y  x  8.5


1.5 yx 2.5
  
8.5 yx 7.5
0.176   0.333
Estimation of truncation error:

xn
compute 
n 1 n4
for  1 x 1
2 2
So that result is correct to at least 6 d.p?
How many terms must we take?

N
xn
Suppose we take n 1 n4
as our approximation then

x n  ( 1 )n  1
N 1
1 N 2


n  N 1 n 4
 
n  N 1
2
n4
 2
N  1 4
 2
N  2 4
 ........


 2

1
N 1
 1  N 1 
4
1  N 1  
4

1       
N  14 
 2 N 2 2  N 3  
N 1
1
 1  12  12 
 
 T .E   2
 1  ....
 N  14 2
2 3


 2
1
N
1 1 1 1 
N  1  2  2 2  2 3  2 4  ....
 
4


 2
1
N

.
N  1
4

T .E  1  10 6
2


 
1
2
N


1
 10 6
 5  10 7

N  1 4
2
when N 9

1 2 
N

 2 10 7  5 10 7
N  14


9 terms required try 8.7

   
N log10 1  4 log10 ( N  1)  log10 1  6 log10 10
2 2
N  0.3  4 log10 ( N  1)   6.3
Home work No. 2

Q1: Estimate the number of terms of the series



x n that we should use if we wish to compute
n 1 n 2 its value correct to 6 d.p for any
(x) in the interval

 1 , 1  ?
2 2
Q2: Estimate the number of terms of the series

 
 n2

 1
n 0
2
that we must take if we are to find its value correct to 3d.p?
Solution1:
1) suppose we take
N
x n as our approximation then T.E is.

n 1 n 2
 n
n N 1
  21 1  1 N 2
x

n  N 1 n 2
 
n  N 1 n 2
 2
N  1 2
 2
N  2 2
 .....


 1
2
 N 1
  N  1 
2
 N  1 
2

1  1 2    1 2   ....
N  12   N 2 2  N 2 


 2

1
N 1

1 
1

1

1
 ...

 N  12  2 22 23 

 2
N
N 1 1
1  
1
   2   10  6
1
T .E  10 6
 2
N  1
2
2  N  1 2

N = 14 is more accurate.
Solution2:
2) Suppose we take N terms

 2
N 1


n 0
1 n2

1 2   2  2  2
 N2 N2  N 12  N  2 2
T .E  
n N
 1  1  1  ...

 1  1  1   1   ...
N2 2 N 1 4n4

2 
 2 2 

 1 
N2

T .E  1  10 3
2
 2
 1
N2
 1  10 3
2
N = 4 the terms required
(( Interpolation))

If we have a table of values of some function


f (x) at a set of points
x1 , x2 , x3, .............
Which not necessarily equal-spaced . If they are:

xi 1  xi  h and h

is called the step size or the interval size) and we wish to find
the value of the function at some point yx i
for any i
Suppose x1  x2  x3  x4 if  xi Such that xi  y  xi 1
we have the problem of interpolation, it y  xn or y  xn
the problem is that of extrapolation.

We suppose f (x) is continuous over  xi , xn 


Draw the graph   f (x) in the region of ( xi , xi 1 )
Mark the point pi xi , f xi  and pi 1 xi 1 , f xi 1 
Join pi and pi 1
by a straight line and let Q be the point on this line
corresponding To x  yThen, the value Z at Q is taken as
the value of the equation
f ( y) of the line is

 y  xi 
Z  f ( xi )  
x x 
  f  xi 1   f  xi 
 i 1 i 
Z
Z  f ( xi )
Pi Q Pi+1

 x2  x1  xi 1 
xi 
Example:
Take f x   x find 2.5

given 1, 2, 3

x x
2 1.4142
3 1.7321
Actually 2.5  1.5811
 2.5  2 
2.5  2  
 3  2


 3 2 
 1.5732
Error  0.0079
A natural generalization is to use the known values of
a function at several points x1 , x2 , x , .............
to fix polynomials of degree (k-1) and use that to
interpolate values at other points.
There are three ways of finding a polynomial.
1)Direct method.
2)Lagrange's method.
3)Newton's method.
We put x  xi i  1,...., K  And equate  xi tof xi 
, this gives us K linear equations in K unknown

k 1
a0  a1 x1  a2 x  .....  ak 1 x
2
1 1  f ( x1 )
k 1
a0  a1 x2  a2 x  ...  ak 1 x
2
2 2  f ( x2 )

a0 a1 xk  a2 xk2  .....  ak 1 xkk 1  f ( xk )

In matrix form:
1 x1 x12  x1k 1   a0   f  x1  
    
1 x2 x 2
2
x2   a1   f  x2  
k 1

    
 .   
.    
    
.    
1 x x 2 K 1   a   f  x 
 k k xk   k 1   k 

on the L.H .S  0
It can be proved that the determination of the matrix
, So these equations have a solution.
This is reasonable way if K is small (2,3,4)
Example:
Find a polynomial which fits the following data.
x 0 1 5

f ( x ) 6 2 6

Solution:
since we have three points we can fit a polynomial containing
three coefficients, i.e/polynomial of degree two let it be.

f ( x)  a x  b x  C
2

Substituting the given data we obtain three linear


equations in the three unknowns a, b, c.
c6

abc  2
25a  5b  c  6
The solution is a  1 b  5 c  6

So that the required polynomial is


x 2  5x  6
1 
 0 0  c  6
     
 1 1 1  b    2
1 a 6
5 25     
 
There exists a polynomial
L(x) of degree at most ( k-1) which takes a given set of values

f (xi ) at a given set of points

xi i  1,2,........, k 
consider the polynomial

K K  x  xj 
L( xi )   f ( xi )   

j 1  xi  x j

i 1
j i

L(x) consists of the sum of K polynomials each of which is of degree at
most (k-1) it follows that L(x
is it )self a polynomial of degree most ( k-
1)

let x rbe one of the K points xi (i  1,2......, k ) Then L( xr )


consists of the sum of K terms of which ( k-1) are zero since they
contain the factor xr  xr  
the only non-zero term is where ir
in the definition above and this term is

K  xr  x j 
f xr     f ( xr )
 
j 1  xr  x j 
j r
So that L( xr )  f ( xr ). i.e

L(x) takes the value f ( xi ) at the points xi i  1,2,........., k 

This completes the proof.


Fit a quadratic to the data:
x 1 x1
2 x2
3 x3

f ( x)  1 1 1
2 3
Solution:

 x  2   x  3  1  x 1   x  3  1  x 1   x  2 
L( x)  1     2   3  
 1 2  1 3   2 1   2  3   3 1   3  2 
x  2 x  3 1 x  1 x  3 1 x  1 x  2
  
2 2 1 3 2

1 2
 x  6 x  11
6

Depends upon the use of divided differences.
As an introduction to newtons method we need finite
differences we begin with forward differences take the
function f ( x)  x 3
x  3, 5, 7, 9, 11, 13
x 3 5 7 9 11 13
f ( x )  27 125 343 729 1331 2197
f  98 218 386 602 866
2 f  120 168 216 264

3 f  48 48 48

4 f  0 0
Given the values f  xof
 a function at a set of
equally spaced points xi i  1, 2, , n 
Where x1  x2  x3    x4and xi 1  xi  h
we define the first forward difference of
f ( x) at xi to be f ( xi 1 )  f ( xi )
and denote it by f i

for K  2 the k  thforward


difference of f x 
at at xi is defned by
K fi  K 1 f xi 1   K 1 f ( xi )
xi
If we have a function which is tabulated at a set of point which are
not equally spaced there is not much point in using forward
differences since important properties of functions, such as the
one just proved for polynomials, will no longer hold.

If the values of a function f (xare


) given at two points,
x ,x
1 2
the first divided difference f (x
at)

x1 and x2 is defined to be

f ( x2 )  f ( x1 ) and is dented by x1 x2 


x2  x1
The second divided difference across three points
x1, x2 , x3 is defined in terms of the first.
x1 x2 x3   x2 x3   x1 x2 
x3  x1
More generally we define the K-th divided difference in
the ( K  1) st for K 2

For K  2 the k-th divided difference at a set of points.


x1, x2 , , xk is defined by:

x1, x2 ,, xk  x2 x3  xk   x1 x2  xk 1 


xk  x1
Example:
Form the divided difference table of
f ( x)  x 4 at x  0,1, 3, 6, 7, 10

 0
x x x x
x 1 3 6 7x 10 x

f ( x)  0 1 81 1296 2401 10000

1st D.D  1 40 405 1105 2533


2 n d D.D  13 73 175 357
3rd D.D  10 17 26
4TH D.D  1 1

5th D.D  0
If a function f (x) takes values f ( xi ) at a set of points

xi i  1, 2,, n not necessarily equally spaced, then

f ( x)  f ( x1 )  ( x  x1 ) x1 x2   x  x1 x  x2 
x1 x2 x3     ( x  x1 ) x  x2 x  xn1 
x1 x2  xn   x  x1 x  x2 x  xn 
x x2  xn 
Or: : f ( x)  f ( x1 )  ( x  x1 ) x1 x2   x  x1 x  x2 x1 x2 x3    
( x  x1 ) ( x  x2 ) x  xN 1  x1 x2  xN 1 xN 
Example:

x
Fit a cubic to the data
0 1 3 6

f (x)  -7 -8 14 197

Using newtons method?


Solution:
x  0 1 3 6

f ( x)  7 8 14 197

1st D.D  1 11 61

2 n d D.D  4 10

3rd D.D  1

Taking x1  0, x2  1, x3  3, x4  6
Newton's formula then gives:

f ( x)  7  1( x)  4 x( x  1)  x( x  1)( x  3)
f ( x)  x  2 x  7
3
Q1: use the direct method and the Lagrange’s method to fit
polynomial to the
Data:
x  1 0 1 2

f ( x)   4 1 0 5
Q2: use newtons method to show that the data below is

consistent with f ( xi )being polynomial and find the


degree of the polynomial and the coefficient of the higher order
term:

x  1 0 1 3 4 6

f ( x)  1 1 3 103 249 853


Solution:

1) The polynomial of degree three let it be

f (x)  ax  bx  cx  d
3 2

Substituting the given data we obtain four linear equations in the


four unknown a, b, c, d.
 4   a  b  c  d .....(1)
1  d ....................( 2)
0  a  b  c  d ......(3)
5  8a  4b  2c  d ..( 4)
From (1) and (3) adding
 4  2b  2 d
2  bd

1  b
Substituting for b and d in (3) and (4) we have .

2x 2 ac

10  8a  2c sub

 6  6 a  1

c  1
The polynomial is f ( x)  x 3  x 2  x  1
Now using Lagrange's method:
K K  x  xj 
L( xi )   f ( xi )   
i 1
 
j 1  xi  x j 
j i

 x  0   x 1   x  2 
 L( x)  4    
 1  0   1 1   1  2 
 x  1   x 1   x  2   x  1   x  0   x 1 
 (1)      0 5    
 0  1   0 1   0  2   2 1   2  0   2 1 

 x   x 1   x  2   x 1   x 1   x  2   x  1   x   x 1 
L( x)  4       5    
 1    2    3   1   1    2   3 2 1 
 x x  1x  2  1 x  1x  1x  2  5 x  1x x  1
4
6 2 6

L( x) 
1
6
    
4 x 3  3x 2  2 x  3 x 3  2 x 2  x  2  5 x 3  x 
1

 6 x3  6 x 2  6 x  6
6

 x3  x 2  x  1
2) x  1 0 1 3 4 6

f ( x )  1 1 3 103 249 853

1st D.D  2 2 50 146 302

2 nd D.D  0 16 32 52

3rd D.D  4 4 4

4th D.D  0 0

x1  1 , x2  0 , x3  1 , x4  3 , x5  4 , x6  6
Newtons formula then gives:
f ( x)  1  (2)( x  1)  (0)( x  1)( x  0)  4 ( x  1)( x  0)( x  1)
 4 x3  2 x  1
Relatively few integrals can be evaluated analytically.
We therefore have to evaluate most integrls numerically for
An integral of single variable.

b
Suppose that we wish to evaluate a
f ( x) dx

Where a, b are fixed finite, given numbers b and


a f (x)
is
a given function of the single variable which is
a xb
finite and continuous throughout the interval
If we draw the curve y  f (x)
then the value of the integral is the same as the area bounded
by the line y  0, x  a, x  b and the arc of the curve
y  f (x) between
xa and xb as shown in the diagram.
P
Q
y  f (x)

x
A B

Where A and B are the points (a,0) and (b,0)


respectively. If P is the point a, f (a) 

and Q is the point b, f (b)  then as a first rather crude approximation

to the area we can take the area of


the trapezium APQB.
We therefore take.

f ( x) dx  (b  a)  f (a)  f (b)
b 1
 a 2
*

In practice we would normally divide the interval


(a, b)into sub-intervals and apply the approximation formula
* to the integral over each sub-interval in turn.
Thus if we divide (a, binto
) n-subintervals by
taking (n  1) points
x1, x2 ,  , xn
Where a0  x0  x1  x2    xn  b Then we have

n 1
f ( x) dx  
b xi 1
(1)   f ( x) dx And as in * we take
a xi
i 0

f ( x) dx  xi 1  xi   f ( xi )  f ( xi 1 )
xi 1 1
(2) 
xi 2
The lengths of the sub-intevals need not all be the same
through, they usually are .
In the case where they are the same we have xi 1  xi h
So that. b  a  nh
And (1) and (2) combined then give us
b x0  nh
a
f ( x) dx  
x0
f ( x)dx

  f ( x0 )  2 f ( x1 )  2 f  x2     2 f  xn 1   f  xn 
h
2
 f ( x0 )  f ( xn ) 
or  h   f  x1   f  x2     f  xn 1 
 2 
and this is the trapezium rule

Example:
Estimate the value of log e 2 by a trapezium rule
approximation
2 dx
 1 x
Taking h 1 ?
3
Solution:

f ( x)  1 in this case and since h 1


x 3
we shall require the
f ( x) at
x  1, 4 , 5 , and 2
3 3
x 1 4 5 2
3 3
f ( x)  1.0000 0.7500 0.6000 0.5000
And the trapezium rule gives:
log e 2  1.000  20.7500  0.600)  0.5000  0.7000
1
6
 4 5 2 
 1  4  5 
3 3

 3 3 
This method is fundamentally similar to the trapezium Rule,
As before we suppose that we wish to evaluate b
a
f ( x)dx

And the diagram as before, but , in addition

we mark the points C ( a  b) ,0



 2 

which is the midpoint of AB and R  a  b  , f ( a  b ) 


 2 2 

where the ordinate through C meets the curve . y  f (x)


We then take the area of the rectangle based on AB and of
height CR to be an approximation
To the area under the curve between A and B.
i.e/ to the value of the integral. Thus our approximation is
b  ab
a
f ( x) dx  (b  a) f 
 2 
 *

This is the midpoint rule for a single interval.


We can easily adopt * to cover the case of several intervals.
If, as before, we subdivide
ab so that a  x0  x1  x2    xn  b
P R Q y : f ( x)

A C B
We have b  a  nhand so
b x0  nh
a
f ( x) dx  
x0
f ( x) dx
n 1
 xi  xi 1 
  xi 1  xi   f 
i 0  2 
Or, if the point x0 , x1 ,, xn
are equally spaced

 
x0  nh n 1

 f ( x) dx  h f x0  (k  1 h 
x0
k 0
2
Example:
Use the midpoint Rule with h 1 to estimate loge 2?
3
Solution:

f ( x) dx  1 we shall require.
x
 3  , f 31  , f 113 
f 7

1
 f    7 , 1 , 3
 3 3 11

2 dx 1  6 2 6 
log e 2       
1 x 3  7 3 11

 0.8571  0.6667  0.5455


1
3
 0.6898 to 4 d . p
A glance at the diagram makes it clear why, in the case
1
y 
of the curve xthe trapezium Rule overestimates
the value of the integral
whereas the midpoint Rule underestimates it.

If we evaluate an integral by
I the Mid-point and the
Trapezium Rules and get values
I M , IT respectively then.
1
(i ) I  I M   ( I  I T )
2
2I M  IT
(ii )
3
gives a better approximation still to I
Truncation errors in the trapezium and midpoint Rules:
By truncation error we mean the error we get if we use
the formula once.
By global truncation error We mean the error we get when
we finally complete the integration
over a fixed interval.
The local truncation error in the T.R:
The T.R is

f ( x)dx   f (0)  f (h)


h h
0 2
We try to find as estimate for the error in a
single application of the T.R.

f ( x)dx   f (0)  f (h)


h h
0 2
By Taylor’s theorem:
x2
f ( x )  f (0)  xf (0)  f (0)  .....
2!
h2 h3
f (1 ) 0  1 h 
h

0
f ( x ) dx  hf (0) 
2
f (0) 
6
h h
f (0)  f ( 0) 
2 2
h h h h2 
f ( h )   f ( 0)  f (0)  f  (0h)   
2 2 1! 2! 
Add +

h2 h3
h
 f (0)  f (h)  h f (0)  f (0)  f (oh)
2 2 4
The error in a single application of T.R is
h3 h3
f ( x)dx   f (0)  f (h)  f 1  
h h

0 2 6 4
f (oh)

If we assume that f (x) is almost constant over o, h

 h3
The T.E is f 1  0  1  h
12
The local truncation error inh the Mid-point Rule:
If we wish to evaluate
0
f ( x)dx The midpoint rule is

h h
0
f ( x)dx  hf  
2
And Taylor’s expansion lead to
 h h2 h3
hf    hf (0)  f (0)  f  2  0 2  h  1
 2  2 8
By Taylor’s theorem:
x2
f ( x )  f (0)  xf (0)  f (0)  
2!
h h
 x2 
0 f ( x)dx  0  f (0)  xf (0)  2! f (0) dx
h2 h3
 h f ( 0)  f (0)  f 1  0  h  2
2 6
h h3 h3
 f 1   f  2 
h
The error is: f ( x) dx  hf   
0
2 6 8
h3
 f  2  0 2  h 
24
Assuming that f (x) is constant over o, h
In both the trapezium Rule and the Mid-point Rule our
approximation to the area
under the curve is obtained by
replacing the arc of the curve between x=a and x=b by a straight
line. In the former case the line
Joined the points at the ends of the arc, in the latter case it
passes through the
mid point of the arc parallel to the x-axis A natural extension of
this idea is to replace
the arc by a curve of the second degree in which passes through
the two end points
and the Mid-point of the arc such a curve is a parabola and has an
equation of the form:

y  Ax  Bx  C.
2
The algebra is simplified if we take a  h and b  hso that
1
a  b   0
2
We then wish to choose A,B,C so that the parabola passes through
the points
 h, f  h, 0, f (0), h, f (h)
the equations defining A, B , C are there fore
Ah  Bh  C  f (  h)
2

C  f (0)
Ah 2  Bh  C  f ( h)
f (  h)  f ( h)  2 f (0)
So that A
2h 2
f ( h)  f (  h)
B
2h
C  f (0)
The parabola so defined coincides with the curve y  f (x)
at the three points

Where x : h, 0,h we may there fore say that.


h

h
f ( x ) dx  
h
h
Ax 2

 Bx  C dx
2
 Ah 3  2ch
3
And substitution of the values of A, B C gives

f ( x)dx   f (h)  4 f (0)  f (h)


h h
h 3
Which is Simpson's Rule for single interval the general form is.
h  Sum of end ordinates 
  4Sum of even ordinates 
3  
 2Sum if oddordinates 
 

Example:
1 dx
h  is

Apply Simpson's Rule with 1
4 ?
0 1 x 2

1 1 3 1
  1  1  3
4 2 4
0
4 2 4
(1) f ( 0)  1

( 2) f 1 4   1  11
16
(3) f 1 2   1 11
4
( 4) f 3  4
 
1
1 9
16
(5) f (1)  1
2
   
1 3    
  2 
dx 1 1 1
 1 x2
 
12  2
 4
1 1

9  1 1 
 1   4 

  16 16  

 0.785392
M. point Rule
h


h
f ( x)dx  2h f (0)  I M
f ( x)dx  h f (h)  f (h)  I
h
T. Rule h
T

2 I M  I T  h f ( h)  4 f (0)  f (h)
2I M  IT
  f (h)  4 f (0)  f (h)
h
3 3
= Simpson's Rule.
Truncation Error in Simpson's Rule:
we take Simpson's rule in the form

f ( x)dx   f (h)  4 f (0)  f (h)


h h
h 3
And estimate the truncation error over the interval  h, h
by Taylor's theorem:
x2 x3 x4
f ( x)  f (0)  xf (0)  f (0)  f (0)  f  
2! 3! 4!

Where 0   x
h h3 h5

h
f ( x)dx  2hf (0) 
3
f (0) 
60
f (  )

For some number in  h, h


Now from Simpson's Rule:

f ( x)dx   f (h)  4 f (0)  f (h)


h h
h 3
And from Taylor's theorem:
h2 h3 h4
f (h)  f (0)  h f (0)  f (0)  f (0)  f ( y )
2! 3! 4!
h2 h3 h4
and f (h)  f (0)  h f (0)  f (0)  f (0)  f ( )
2! 3! 4!

where h  y  0 and 0 3   h5.


So that
h
 f (h)  4 f (0)  f (h)  2h f (0)  f (0)  f ( )
h h
3 3 36

On the assumption that f ( y)  f ( )  f ( )


 h5
The truncation error is f (  ) Assuming that
90
f ( )  f ( ) For some  in  h, h
1 dx
Q1: Evaluate 0 1  x5
using the Mid-point with h 1
4
1  
and compare your result with the exact value  log e 2  
3 3

1 Sin  x
Q2: Estimate the value of I  
0 1 x
dx
(i)Using the Mid-point Rule to give Im.
(ii)Using the Trapezium Rule to give IT.
2I m  IT
In each case taking h 1 Ic
4 Let
3
(iii) Using Simpson's Rule with h  1 and compare it with Ic.
4
b ba
a
f ( x ) dx  (b  n) f 
 2 

1) The Mid-point Rule = 1 dx


0 1 x 3
with h  1
4
1 d x 1 1 3 1
   1  1  3
4 2 4
0 1 x 3 0
4 2 4
 Using the Mid-point Rule.
 
1  
1 dx 1 1 1 1

0 1 x 2 4
1 
 1
3

1  
 3
3

 
1  5
3

 1  7 
3
 8 8 8 8 
 
1 1 1 1 1 
    
4 1  1 27 125 343 
512 1  1 1 
 512 512 512 
1  1 1 1 1 
 512   
4  513 539 637 855 

 128 1.9493 10 3  1.88553 10 3  1.5699 10 3  1.1696 10 3 
 0.1286.5441
to 4 d.p.
 0.8377
But the exact value
1

 log e 2  3
3

1  
 0.693147 
3 1.7321

 0.6932  1.8138
1
3
 0.8357 to 4 d . p

 The error
 0.8377  0.8357
 0.0020 to 4d . p
1 sin  x
2) I  dx with h  1
0 1 x 4
(i) Using the Mid-point Rule


   
1  Sin  0  1 4 1 2 Sin  1 4  2 4 1 2
Sin 
2 3 1



4 


sin  3  4 1
4 2
i I M   4 2 4
4  1 1
2
0 1 
4

1 12 4
1  24

12
1   3 



1 3  4 
1


 24 4 2 4 4 

 3 

1  Sin 8
Sin Sin 5 sin 7 
   8  8  8

4  1 1 1 3 1 5 1 7 
8 8 8 8
 
1  0.3827 0.9239 0.9239 0.3827 
 8   
4  9 11 13 15 
 2 0.0425  0.0840  0.0711  0.0255
 0.4462 to 4d . p.
(ii) Using the Trapezium Rule.

ii IT  b  a  f (b)  f (a)


1
2
  
1  Sin 0 Sin 4   Sin 4 Sin
2   Sin 2 Sin 3   Sin 3 Sin 4 
IT     
4   4 4  4 4 
8 1 1 1   1 1 1 2   1 2 1  3   1  3 1  4 
 4  4 4   4 4   4 4 

1  2 Sin  2 Sin  2 Sin 3 


  Sin 0  4 2 4  Sin  
8  1 1 1 2 1  3 2
 4 4 4 
4 1.4142 2 1.4142 0 
 0     
8 5 6 7 8
 0.50.2828  0.3333  0.2020
 0.40905 to 5d . p.

2 I M  IT 2  0.4462  0.4691
Ic    0.4338 to 4d . p.
3 3
I c is the most accurate value. Because in Ic
the error terms of I M and I T approximately cancelles out.

(iii) Using Simpson's Rule with h 1


4

x 0 1 2 3 1
4 4 4

Sin  x  0 0.7071 1 07071 0

Sin  x
 0 0.5657 0.6667 0.4041 0
1 x
Applying Simpson's Rule
I s  1 40.5657  0.4041  20.6667   3.8792  1.3334
1
12 12
I s  0.4344
I c  I s  0.0006 Error 

The trapezium Rule and Simpson's Rule are the simplest formula of an
infinite class called the Newton cotes formula.
h
For the K-th order Newton cotes formula applied to

f ( x) dx
0

we approximate f (x) by a polynomial of degree K and

seek a formula of the type.


h  2h 
   a k f h 
h

0
f ( x) dx  a0 f (0)  a1 f    a 2 f 
K K 
Where the coefficients a0 , a1 ,.., aare
k
chosen so that

the formula is exact when f ( x)  1, x, x 2 ,..., we


xk
k 1
cannot expect the formula to work when f ( x)  xso

we expect th L.T .Ein the formula to be of the


k 2
form Ah for some constant .A
In fact if k is even

such formula turn out to be exact for f ( x)  x k 1


but not for f ( x)  x k  2so,if is odd
K th L.T .E
k  2 but if
Is of the form Ah is
Keven the L.Tof.E
k 3
The form Ah .we have already seen that this is so for

the tropezium rule ( K  1and


) simpsons rule ( K If2we
)
1 dx
try to integrate 0
1 x
by any Newton cote formula
2
One: that uses f (0) and f (h) such as Simpson's Rule or
trapezium Rule we get into trouble because f (1)  

The integral has a removable singularity at x 1


one possible way out of the difficulty is to use a formula that
doesn’t use the value of f (x) at the end points,

the mid point Rule provides such a formula but we can


construct others e.g/
let us try h h  h  2h  

0
f ( x)dx   f    f  
2  3  3 
put f ( x)  1; h  1  1 Method works
h
2
h 2 h  h 2h  h 2
put f ( x)  x;      Method works
2 2 3 3  2
h 3
h  h 2
4 h 2
 5h 3
put f ( x)  x 2 ;     Method works
3 2 9 9  18
3
Error is h
18

h
 f h   f 1   h 
h
0 f ( x)dx 
2
put f ( x)  1; h  1  1  h
h
it works
2
h2 h h2
f ( x)  x;  h  h1     it works
2 2 2
2
f ( x) : x ;
h3 h
3 2

 h   1    h 2
2
2
it works
These are the same if   1     2 3
2 2

 2 2  2  1  0
3
1 1
3 1 1
  
2 2 12

h h   1 1    1 1  

0
f ( x)dx   f  
2   2
h  f  
12    2
h 
12  
has a L.T.E order at least h4
Such a formula is called a gauss type integration formula .
Example:
1 dx
Find 
0 1 x 2
?

T. Rule gives
1
2
 2 4

1  1  3    3.00

 
1

4
   3.20
 2
M. point Rule gives 4 2
1 1 5
 
 
Gauss formula gives   
1 1

1 
4 2 1 1 
2
1 1  
2

1     1     

  2 12   2 12  
 
1 1 1 
   
24 1 4

1 
3
 12 3 12 
 
8
1  48
  3
     3.1475
2  16  1  61
 9 12 


 x2
Suppose we have an integral such e dx Since

e  x  0 very rapidly we first choose N and approximate by
2

N

 x2
e dx We choose N that T.E
N


N
2 e  x2
dx  Where is less than desired accuracy
N
then use some formula e.g M-point Rule to approximate
N
2 e  x2
dx
0
e.g/ If we take N=10 and h= ½ we get
1  16 
1 9 25 49
   
 e x dx  e e e e  
2
16 16 16
 2 
 1.772458to 6 d . p 
Now 1.772458  3.141607  
2


 
 x2
in fact the e dx 


You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy