Docsity

Numerical Analysis I – Complete Lecture Notes, Formulas & Worked Examples, Lecture notes of Mathematical Methods for Numerical Analysis and Optimization

Toggle sidebar
bg1
1
SMA 2321 NUMERICAL ANALYSIS/ TECHNIQUES ONE NOTES
INTRODUCTION
Numerical analysis is the study of approximation techniques applicable in solving problems in
engineering, physical sciences, computer science and social sciences. The result obtained using
these techniques differs from the actual result with a quantity known as an error i.e. if
*
x
is the
approximate result,
x
is the actual result and
e
is the error then
*
xxe
. The error
e
can
arise from one or more of the following
i. Number representation
ii. Simplification of the method
iii. Data used
iv. Type of the computing device used
v. Human mistakes
TYPE OF ERRORS
There exist a number of different types of errors namely:
1) Absolute error: This is defined as the positive difference between the approximate and
actual value and is denoted by
abs
e
i.e. if
x
is the actual value and
*
x
the approximate
value of
then
*
xxeabs
e.g. if
34.2x
and
352.2
*x
then
012.0352.234.2
abs
e
NB: The actual value
x
is given by
abs
exx *
2) Relative error denoted by
r
e
is defined as the ratio of the absolute error to the positive
value (absolute value) of the actual value i.e.
x
e
eabs
r
Note: The maximum relative error can be written as
abs
ebs
rex
e
e
*
max
where
*
x
is the
absolute value of the approximate value
*
x
Proof: Let
x
be the actual vale and
*
x
be its approximate value then
** xxxx
or
xxxx **
then taking the modulus of both sides yields
xxxx **
by triangle
inequality
bs
exx *
abs
absabs
ex
e
x
e
*
then
abs
abs
rex
e
e
*
max
3) Round off error: This is an error introduced in a given value when the number of decimal
places is reduced where number of decimal place is defined as the number of digits
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e

Partial preview of the text

Download Numerical Analysis I – Complete Lecture Notes, Formulas & Worked Examples and more Lecture notes Mathematical Methods for Numerical Analysis and Optimization in PDF only on Docsity!

SMA 2321 NUMERICAL ANALYSIS/ TECHNIQUES ONE NOTES

INTRODUCTION

Numerical analysis is the study of approximation techniques applicable in solving problems in engineering, physical sciences, computer science and social sciences. The result obtained using these techniques differs from the actual result with a quantity known as an error i.e. if x *is the approximate result, x is the actual result and e is the error then exx *. The error e can arise from one or more of the following

i. Number representation ii. Simplification of the method iii. Data used iv. Type of the computing device used v. Human mistakes TYPE OF ERRORS

There exist a number of different types of errors namely:

  1. Absolute error: This is defined as the positive difference between the approximate and actual value and is denoted by eabs i.e. if x is the actual value and x *the approximate value of x then eabsxx * e.g. if x  2. 34 and x *^  2. 352 then eabs  2. 34  2. 352  0. 012 NB: The actual value x is given by xx * eabs
  2. Relative error denoted by er is defined as the ratio of the absolute error to the positive value (absolute value) of the actual value i.e. x

e eabs r

Note: The maximum relative error can be written as abs

r ebs x e

e e

max  (^) * where x * is the

absolute value of the approximate value x *

Proof: Let x be the actual vale and x *be its approximate value then xxx *^  x *or

x  x * x * x  then taking the modulus of both sides yields x  x * x * x  by triangle

inequality xx * ebsabs

abs abs x e

e x

e

 (^) * then abs

r abs x e

e e

max  (^) *

  1. Round off error: This is an error introduced in a given value when the number of decimal places is reduced where number of decimal place is defined as the number of digits

after the decimal point e.g. 3.1423 is a number which is correct to 4 decimal places. The maximum round off error in a value correct to n decimal places is given by 0. 5  10  n

Theorem

Let x be a number which is correct to n significance figures if the first significance figure is K

then the maximum relative error in x is given by 1 10

max 1 er  (^) Kn

Proof:

Case 1: Suppose that x is correct to zero decimal places if k is the first significance figure and the number is correct to zero decimal places i.e. xkd 1 d 2 .......... d (^) n  1 if dis , i  1 , 2 ...... n  1 are

replaced by zeros then xk  10 n ^1  n abs

abs abs

r abs k e

e x e

e e  

max for a number

correct to zero decimal places 2 10 1

max 0. 5 max^0.^5 eabs   erkn  (^1)   kn  (^1)  for any

positive number k ,^1111 10

max^1 10

 

  

n    nrn r n k

e k

k k e

Case 2: suppose that the approximate value x is correct to m decimal places and (^) k is the first significant figure i.e. xkd 1 d 2 ...... d (^) n  1  m. dn  2 ....... dn  1  kd 1 d 2 ........ dn  1  10  m replacing all di , i  1 , 2 , n  1 with zeros then xk  10 n ^1  10  m maximum absolute error in x is

  1. 5  10  m then

1 1 1 10 1 max^1 10

     

 

 (^) n m m n n abs n

m abs

r abs k

e x e k k k

e e

Example

Compute the maximum relative error in the approximate value x  4. 2357

Solution: The given value is correct to five significance figure  n  5 and first significant figure

is k  4  5 1 4 2. 5 105 4 10

max 1  er       

  1. Propagated error: this is defined as the error in the result obtained by an arithmetic operation which is due to the data used

PROPAGATED ERROR IN ARITHEMATIC OPERATIONS

i. Addition and subtraction

NB: The maximum relative error in the quotient *

y x is approximated by

*^2

x y y

x

y

x y  

   

PROPAGATED ERROR IN FUNCTIONAL VALUE

Consider a function of one real variable x say f   x then if x *is the approximate value of the actual value x having an error  x then the error in the functional value computed at the

approximate value x *say  f is given by  f  f   x  f  x *.................   1 now expanding f   x

about x *by Taylor’s expansion yields

f xf x *^  xx * fx * ^1 xx *^2 f  x *  or

f xf x *^  xfx * ^1  x^2 f  x *  substituting   2 in   1 yields

f  xfx *^ ^1  x^2 f  x *  if  x is a very small value this can be approximated

by  f  xf  x *^  0   x  2 .....................  3. Taking the modulus of both sides of equation three

yields  f  xf   x  x f   x^ * (by the Schwartz inequality) thus maximum absolute value in

the approximate functional value f  x^ *is given by max  f  x f  x *.....  A  absolute error

in f  x^ *is in the interval 0  f  x f  x^ *

Example

Given the function   21 x^2 f x e   determine the maximum absolute error in the computed value f  1. 23 

Solution

For x *^  1. 23 the maximum absolute error is  x  0. 5  10 ^2  

 

  1. 23 1. 23 2 0. 135

  2. 232  (^)     f e

thus if  f is the maximum absolute error in (^) f  1. 23 then f  0. 5  10 ^2  0. 135  0. 001

NB: The above maximum absolute error given in  A  can be generalized to a function of more than one independent variables as follows, let fx 1 , x 2 ........., x n be a function of n real

variables xi , i  1 , 2 ......... n if x 1 * , x * 2 .......... x * n are the approximate values of x 1 , x 2 ,........, xn with

respective errors e (^) 1 , e 2 ......... en then the maximum absolute error in the functional value

computed at the approximate values is given by

1 i  x 1 * , x * 2 ,..... xn^ *

n i i (^) x f e f 

 

Example 2

Given that   2

(^23)

3 1 1

2 1 ,^2 , 3 2 3 x

x x x

(^) f x x xx x  determine the maximum absolute error computed at

x 1  1  0. 02 , x 2  3  0. 01 and x 3  2  0. 005

Solution

For the given values the approximate values are x 1 *  1 , x * 2  3 and x 3 *  2 with respective absolute errors e 1  0. 02 , e 2  0. 01 and e 3  0. 005 , for the given function

(^31) , 3 , 2

3 2 121 123 21 3

(^21) , 3 , 2

2 3 22

3 (^21)

1 32 1 2

(^11) , 3 , 2

2 3 21

1 (^21)

3 2 23 1 1

1 * 2 *^ * 3

1 * * 2 * 3

  • 1 * 2 * 3

  

 

  

 

  

 

x x x

x x x

x x x

x

xx x x x f x

f

x

x x x xx f x

f

x

x x x x x x f x

f

If  f is the maximum absolute error in f  1 , 3 , 2 then

f  0. 02  7  0. 014. 22  0. 00511. 667  0. 241

  1. GENERATED ERROR: This is defined as the error in the result obtained by an arithmetic operation due to the computing device used.
  2. ACCUMULATED ERROR: Is the sum of the propagated error and the generated error.

Definition: let RE be the rate of growth of the error E in a given arithmetic operation then if

i. RE  CE where C is a constant then the arithmetic procedure is said to be a linear error growing procedure or the method is said to be stable ii. RE   Cn E where C is a constant and n the number of steps in the procedure the method is said to be unstable FINITE DIFFERENCES

Consider n  1 equally spaced points  x (^) i , fi , i  0 , 1 , 2 .......... n i.e. x (^) i  1  xih where h is equal to a constant then the difference between two consecutive functional values i.e.

..  fnfn  1   fn  1  fn  2  fnfn  1 xn fn PROPERTIES OF FINITE DIFFERENCE TABLES

The following are the properties of a finite difference table:

  1. All the functional values i.e. fi , i  0 , 1 , 2 ,......... n must be given correct to a given number of decimal places
  2. If there are n tabulated points differences are obtained up to difference of order n  1
  3. Decimal and all leading zeros are omitted in differences e.g. if two consecutive functional values are say 1.28 and 2.12 the first order finite difference is
  1. 12  1. 28  0. 84 in a finite difference table this is written as 84 if the functional values are correct to m decimal places the differences in the finite difference table are multiplied by 10  m in order to obtain the actual difference
  1. Round off errors in the functional values can be neglected if higher order difference are equal to a constant or approximately equal to a constant.
  2. The function whose data is given is well behaved (i.e. continuous) if higher order differences either decrease or increases in magnitude rapidly.

Example

Construct a finite difference table for the data given below

x 2.0 2.2 2.4 2. f   x^ 0.3010^ 0.3424^ 0.3802^ 0. Solution

The given data is equally spaced thus its finite difference table is

Difference order x f   x 1 2 3

  1. 0 0. 3010 414
  2. 2 0.3424 - 378 6
  3. 4 0.3802 - 348

NB: From this table the difference are decreasing in magnitude rapidly thus the data is for a well behaved function further differences of order two when multiplied by 10 ^4 are almost equal to a constant thus round off error in the functional values can be neglected.

EXERCISE

i. Compute the maximum absolute and relative errors in each of the following a) 2. 134  0. 67  3. 2  b) 4. 12  3. 67 . 0. 867  c) Functional value of   5 2

x x

f x x computed at 1. 25

d) Functional value   2

3 1

2 3 2

x

x x x

f x x xx x  computed at

x 1  1  0. 04 , x 2  3  0. 006 , x 3  2  0. 023 ii. Construct the finite difference table for each of the following and state whether the round off error can be neglected i. x 2.00 2.15 2.30 2.45 2. f   x^ 1.260^ 1.291^ 1.320^ 1.348^ 1. ii. 0. 2  0. 1  0. 5 21 x^3 e  iii. Compute the maximum absolute error in total cost of the material required to construct a cylindrical closed tank whose radius is 2.^45 m and height is 2.^6 m if the cost of the material is K £ 2. 065 per square meter. TYPES OF FINITE DIFFERENCE OPERATORS There exists three different types of finite difference operators all of which are defined in terms of the shift operator denoted by E which moves a factional in an equally spaced data to the next functional value i.e. considered an equally spaced data  x (^) i , fi , i  0 , 1 , 2 .......... n then Ef (^) 0  f 1 , Ef 1  f 2 .............,. Efn  1  fn in general Efifi  1

NB: E^2 fi  E  Efi  Efi  1  fi  2 , E^3 fi  E  E^2 fi  Efi  2  fi  3 etc. in general E k^ fi  fi  k

which implies that applying the shift operator E to fi k times moves the functional value k steps forward. FORWARD FINITE DIFFERENCE OPERATOR

This operator denoted by  in terms of the shift operator is defined as   E  1 successive application of this operator to a functional value fi ,^ i ^0 ,^1 ,^2 ,.......... n in an equally spaced data

xn  1  fn  1 xn fn

Example 2

Given the equally spaced data  x (^) i , fi , i  0 , 1 , 2 ,........ n express

a) (^) ^5 fi in terms of functional values b) f 6 in terms forward finite differences at x 1

Hence given the data below

x 0.1 0.2 0.3 0.4 0. f   x^ 1.010^ 1.041^ 1.094^ 1.174^ 1. Without constructing the finite difference table determine the value of the fourth order forward finite difference at x 0  0. 1

Solution

a) By definition  E  1 ^5 fi  E  1 ^5 f i expanding the right hand side by the binomial expansion yields

^5 f i  E^5  5 E^4  10 E^3  10 E^2  5 E  1  fi  fi  5  5 fi  4  10 fi  3  10 fi  2  5 fi  1  f i

b) f^ 6 ^ f 1  5  E^5 f 1 ^ ^1 ^5 f 1  f 6 ^5 f 1 ^5 ^4 f 1 ^10 ^3 f 1 ^10 ^2 f 1 ^5  f 1  f 1

Let f  0. 1   f 0 , f  0. 2   f 1 , f  0. 3   f 2 , f  0. 4  f 3 and f  0. 5  f 4 then ^4 f (^) 0  E  1  4 f 0  E^4 f 0  4 E^3 f 0  6 E^2 f 0  4 Ef 0  f 0 or ^4 f 0  f 4  4 f 3  6 f 2  4 f 1  f 0  1. 284  4  1. 174  6  1. 094  4  1. 041  1. 010  0. 002

EXERCISE

  1. Express i. ^8 f 2 in terms of the functional values ii. f 6 in terms of the forward finite differences at x 2

Given the data below determine ^4 f 1 without constructing the finite difference table x 1.0 1.5 2.0 2.5 3.0 3.

f   x^ 0.3716^ 0.4966^ 0.7464^ 0.9511^ 1.1230^ 1.

  1. Prove each of the following

i.  sin ^1 x    x  h  1  x^2  x 1  x  h ^2 where h is the equal spacing of the

values of x

ii.  ex^  ex  e h  1 where h is the equal spacing of the values of x

BACKWARD FINITE DIFFERENCE OPERATOR

This operator denoted by is defined as   1  E ^1 thus if  x i , fi , i  0 , 1 , 2 ,........ n then

fififi  1 which is said to be the first order backward finite difference at xi

NB:

i. If i  0 then  f 0  f 0  f  1 since f  1 is not in the data then the back finite difference at the first tabulated point is defined in other words the operator cannot be applied to the first point of the tabulated points ii.  f 1 (^)  f 1  f 0 which is the first order backward finite at (^) x 1 or the first order forward finite difference at x 0 in general  fi , i  1 , 2 ............. n is the first order backward finite difference at xi or the forward first order finite difference at xi  1 iii. kth order backward finite difference at xi is given by

      ^ ^  

i k k i i k

ik k k k k ik k i k k i

k k i

f kf kk f f

f E f E E f E f E kE kk E f

  

     

       ^      

1 2

1 1 2

 to compute  k^ fi k functional values before fi are required thus the operator is applicable only when xi is near the last tabulated point

Example: Express

i. ^4 fi in terms of the functional values ii. f 9 in terms of the backward finite differences at x 12

Solution

i. By definition

1 1 4 4 4 4 6 4 1 4 6 4

    

           

i i i i i i

i i E E E E f f f f f f

E E E f E E f

ii. f 9  f 12  3  E ^3 f 12  1 ^3 f 12   1  3  3 ^2 ^3  f 12  f 12  3  f 12  3 ^2 f 12 ^3 f 12

Exercise

iii. 0

1 0

n (^2) f fn f k i^   

  iv.  f (^) i^2  fifi  1  f i

v. ^   1

  ^ 

i i

i i i i i

i g g

g f f g g

f

vi. 1

^ 

i i

i i f f

f f

FINITE DIFFERENCE OF POLYNOMIALS

Definition: A polynomial of degree n in the independent variable x denoted by pn   x is given

by (^) pn   xa 0 xna 1 xn ^1  a 2 xn ^2 ............. a n where n is a positive integer and a 0 is said to be the leading coefficient of the polynomial.

Theorem

Consider a polynomial of degree n in the independent variable x with equal spacing h then the nth order finite difference of the polynomial is a constant proportional to hn and is given by a (^) 0 n! hn where a 0 is the leading coefficient of the polynomial and the high order differences equal to zero.

Proof

Let (^) p (^) n   xa 0 xna 1 xn ^1  a 2 xn ^2 ............ a n then if h is the equal spacing in the values of x

then the first order finite difference of pn  ^ x at x is given by

 .......... ...........  1

2 1 0

0 1 1 0 1 1 anhx p x

p x p x h p x a x h a x h a ax ax a n n

n n n n n n n n n  

   

The second order finite difference of pn  ^ x is given by

^2 p n   x  pn   x    a 0 nhxn ^1  pn  2   x  a 0 n  n  1  h 2 xn ^2  pn  3   x .......... .....  2 from  1

and (^)   2 it can be noted that the kth finite difference can be written as

kp (^) n   xa 0 nn  1  n  2 ........  n  k  1  h kxnk^  pn  k  1    x .......... .....  3 replacing k by n in   3 yields  np (^) n   xa 0 nn  1  n  2 .......... .. 1 hnx^0  p  1   xa 0 n! hnp  1   x .........   4 since

polynomials of negative degrees do not exists then  npn   x exists if p  1   x  0 and is given by

n^ p (^) n   xa 0 n! h^ n , and the higher order finite differences equal to zero.

Example

The sales s   x in thousands Kenya pounds from x hundreds bottle of baby shampoo sold is established to be given in the data below

x 1.2 1.4 1.6 1.8 2.0 2. s   x^ 2.730^ 6.530^ 11.946^ 19.362^ 29.200^ 34. Determine the degree and the leading coefficient for the polynomial appropriate to approximate s   x

Solution

Given data is equally spaced thus the finite difference of the same is

x f   xf ^2 f ^3 f ^4 f ^5 f

  1. 2 2. 730 3800
  2. 4 6.530 1616 5416 384
  3. 6 11.946 2000 38 7416 422
  4. 8 19.362 2422 40 9838 462
  5. 0 29.200 2884 12722
  6. 2 41.

As the 4th^ order finite differences tends to a constant then (^) s   x can be approximated with a

polynomial of degree 4. Let a 0 be the leading coefficient then either 38  10 ^3  a 04 ! 2  10 ^1 ^4

or 40  10 ^3  a 04 ! 2  10 ^1 ^4  a 0  1

Exercise

  1. The market research department for a company that produces and sells charcoal grills established that the p   x in Kenya pounds from the sales x grills is as given in the data below x 50 100 150 200 250 p   x 630.00 1480.00 2230.00 2880.00 3430.

From this table it is noted that

i. Number of non-zero values in the columns of the finite differences increases with the increasing order of the difference ii. High order differences has alternating signs of different magnitude iii. The coefficients of the error (^)  in the (^) nth order differences is the some as the binomial coefficients in the expansion of 1  x ^ n iv. Maximum finite difference in magnitude for difference of a given order is directly opposite the function value with an error

NB: If f *is the functional value with an error  then the correct functional value is given by ff *

Example

Find and correct the error in the data given below hence state the degree of the polynomial appropriate to approximate the data

x 5.0 5.1 5.2 5.3 5.4 5.5 5.6 5.7 5. f   x^ 125.000^ 132.651^ 140.608^ 148.877^ 157.464^ 166.357^ 175.616^ 185.193^ 195.

Solution

As the data is equally spaced the finite difference table is as given below

x f   xf ^2 f ^3 f ^4 f ^5 f

  1. 0 125. 7651
  2. 1 132.651 306 7957 6
  3. 2 140.608 312 0

FIG 1

Then   f   x f s fAx x

f x f x x

f f i i i

i i i

i i ................. 1

(^1)        

 

 is said to be the linear forward

interpolation polynomial.

Example

The data in the table below give the total daily cost y in Kenya pounds of producing x dozens of chocolate chips cookies at different production levels

x 50 100 150 200 250 300 y 80 180 280 380 480 580 Approximate the cost of producing 120 dozens

Solution

Given data is equally spaced thus the finite difference table for the data is

x f   xf ^2 f^ ^3 f ^4 f ^5 f 50 80 100 100 180 0 100 0 150 280 0 0 100 0 0

From the table the first order finite differences equal to a constant thus y can be approximate by a linear interpolation polynomial i.e. yyisyi ........  1 since x  120 is in between 100

and 150 the letting xi  100 then 0. 4 , 100 5

 180 ,   ^120 ^100    

i (^) h i yi y s x x

substituting these in   1 yields y  120  180  0. 4  100  K £ 220

Exercise

  1. Given the data below approximate the value of f  0. 925  x 0.90 0.91 0.92 0.93 0.94 0. f   x^ 0.4066^ 0.4025^ 0.3985^ 0.3946^ 0.3906^ 0.
  2. A company producing sound system equipment has found that on average a new employee can assemble (^) N   t components per day after t days of on the job training is as given in the data below t^0 10 20 30 40 N   t 5 10 14 17 19 20 Using linear interpolation polynomial approximate N  15 and N   7
  3. QUADRATIC INTERPOLATIOON Consider the equally spaced data  x (^) i , fi , i  0 , 1 , 2 ,......... n if the second order finite differences equal to a constant or approximately equal to a constant and x is a point in between three adjacent points xi , xi  1 and xi  2 i.e. xxish where 0  s  2 , h is the equal spacing then (^) f   x can be approximate by a polynomial of degree two of the form f   xabxxi   cxxi  xxi  1 .......... ....  (^1) , where a , b and c are to be determined by equating given functional values in the data to values of the polynomial at the tabulated points i.e.    

 (^) ii i i i

i i i

i i

f h

f x f f ch f c

f h f x a bh f b

f x a f

2 (^22) 2 2

1 1

 

 