You are on page 1of 9

NUMERICAL METHODS - CHEAT SHEET

Compiled from lecture notes of Mrs.V.Valliammal

by Sarath Chandar A P

1 SOLUTION OF EQUATIONS AND EIGENVALUE


PROBLEMS
1.1 Solution of equation
Fixed point iteration: x=g(x) method

Newtons method

1.2 Solution of linear system


Gaussian elimination method

Gauss-Jordan method

Iterative method

Gauss-Seidel method

1.3 Inverse of a matrix by Gauss Jordan method


1.4 Eigen value of a matrix by power method
1.5 Eigen value of a matrix by Jacobi method for symmetric matrix

2 INTERPOLATION AND APPROXIMATION


Interpolation The process of computing the value of a function inside the given range
is called interpolation.

Extrapolation The process of computing the value of a function outside the given
range is called extrapolation.

2.1 Newtons forward and backward difference formulas


E[f(x)] = f(x+h)

[f(x)] = f(x+h) - f(x)

E=1+

Here is called Newtons forward operator and E is called shift operator.


2

Newtons backward difference operator is

=1-E

Newtons forward interpolation formula is

u(u1) 2 u(u1)(u2) 3
y = y0 + uy0 + 2! y0 + 3! y0 + ...

where u = (x - x0 ) / h

The above formula is used mainly for interpolating the values of y near the begin-
ning of a set of tabular values.

Newtons backward interpolation formula is

u(u+1) 2 u(u+1)(u+2) 3
y = yn + uyn + 2! yn + 3! yn + ...

where u = (x - xn ) / h

The above formula is used mainly for interpolating the values of y near the end of
a set of tabular values.

2.2 Lagrangian Polynomials

Newtons forward and backward interpolation formulae can be used only when the val-
ues of dependent variables are equally spaced; where the values of independent variables
are not equally spaced, then we can use following Lagrangians Interpolation formula
and inverse interpolation formula.

Lagrangian interpolation formula for unequal spaces is

(xx1 )(xx2 )...(xxn )


y = f(x) = (x0 x1 )(x0 x2 )...(x0 xn ) y0 +
(xx0 )(xx2 )(xx3 )...(xxn )
(x1 x0 )(x1 x2 )(x1 x3 )...(x1 xn ) y1 +
(xx0 )(xx1 )(xx3 )...(xxn )
(x2 x0 )(x2 x1 )(x2 x3 )...(x2 xn ) y2 +
(xx0 )(xx1 )(xx2 )...(xxn1 )
... + (xn x0 )(xn x1 )(xn x2 )...(xn xn1 ) yn

Lagrangian inverse interpolation formula for unequal spaces is

(yy1 )(yy2 )...(yyn )


x = f(y) = (y0 y1 )(y0 y2 )...(y0 yn ) x0 +
(yy0 )(yy2 )(yy3 )...(yyn )
(y1 y0 )(y1 y2 )(y1 y3 )...(y1 yn ) x1 +
(yy0 )(yy1 )(yy3 )...(yyn )
(y2 y0 )(y2 y1 )(y2 y3 )...(y2 yn ) x2 +
(yy0 )(yy1 )(yy2 )...(yyn1 )
... + (yn y0 )(yn y1 )(yn y2 )...(yn yn1 ) xn
3

2.3 Divided differences

If the values of x are given at unequal intervals then we use divided differences. Divided
differences take into consideration the change of the values of the function f(x) and also
the changes in the values of the arguments of x.
Suppose the function y = f(x) assume the values of f(x0 ), f(x1 ), f(x2 ),....f(xn ) re-
spectively, where the intervals x1 x0 , x2 x1 ,..... xn xn1 need not be equal.
First divided difference of f(x)

f (x1 )f (x0 )
f(x0 , x1 ) = x1 x0

similarly,
f (x2 )f (x1 )
f(x1 , x2 ) = x2 x1

f (xn )f (xn1 )
f(xn1 , xn ) = xn xn1

Second divided difference is

f (x1 ,x2 )f (x0 ,x1 )


f(x0 , x1 , x2 ) = x2 x0

Third divided difference is

f (x1 ,x2 ,x3 )f (x0 ,x1 ,x2 )


f(x0 , x1 , x2 , x3 ) = x3 x0

The above steps are called divided differences of order 1,2,3 respectively.

Property: The divided differences are symmetrical in all the arguments. i.e. the value
of any difference is independent of order of arguments.

Newtons divided difference formula is

f(x) = f(x0 ) + (x x0 )f (x0 , x1 ) + (x x0 )(x x1 )f (x0 , x1 , x2 ) + ...

+ (x x0 )(x x1 )(x xn1 )f (x0 , x1 , ..xn )

2.4 Interpolating with a cubic spline

Suppose n+1 data points are given we have to find the value of y corresponding to x
where xi x xi+1 where i = 0,1,2,.. n+1. In this case we have to use cubic spline
method.

1. f(x) is a cubic polynomial


0
2. f (x) is second degree polynomial.
4

00
3. f (x) is a first degree polynomial.
0 00
4. f(x), f (x), f (x) are continuous at each point (xi , yi ) where i = 0,1,2,..n.

If the above all conditions are satisfied, then f(x) follows cubic spline.

cubic spline formula The cubic spline in xi1 x xi is

h i h i
h2 Mi1 h2 Mi
1
(xi x)3 Mi1 + (x xi1 )3 Mi + xihx yi1 + xxhi1 yi
 
f(x) = 6h 6 6

where h = xi xi1 for all i

6
Mi1 + 4Mi + Mi+1 = h2 [yi1 2yi + yi+1 ] i

here i = 1,2,3,.. n-1


M0 = 0
Mn = 0
00
f (xi ) = Mi

3 NUMERICAL DIFFERENTIATION AND INTEGRATION

Numerical differentiation is a process of calculating the derivative of the given function


by means of a table of given values of that function. In this process, we have to calculate
dy d2 y
dx , dx2

at a given point is called numerical differentiation. In this case, we have to use Newtons
forward and backward difference formula to compute the derivatives.

In the previous units, we are finding the polynomial curves y = f(x) passing through
n+1 points. But in this unit we have to calculate the derivative of such curves at a par-
ticular point say Xk .

If the values of X are equally spaced, we get the interpolating polynomial using
Newtons formula.

If the derivative required at a point nearer to starting value in table, use newtons
forward method and for value at end of the table use newtons backward method.

In the case of unequal intervals, we can use, Newtons divided difference formula or
Lagrangian interpolation formula.

3.1 Differentiation using interpolation formulae

Newtons forward difference formula is


u(u1) 2 u(u1)(u2) 3
y = y0 + uy0 + 2! y0 + 3! y0 + ...
5

where u = (x - x0 ) / h
 
dy 1 1 2 1 3 1 4
 
dx at(x = x0 ) = h y0 2 y0 + 3 y0 4 y0 + ...
 2 
d y 1 11 4 13 5
 2 3

dx2 at(x = x0 ) = h2 y0 y0 + 12 y0 16 y0 + ...
 3 
d y 1 3 4
 3 
dx3 at(x = x0 ) = h3 y0 2 y0 + ...

Newtons backward difference formula is


u(u+1) 2 u(u+1)(u+2) 3
y = yn + uyn + 2! yn + 3! yn + ...

where u = (x - xn ) / h
 
dy 1 1 2 1 3 1 4
 
dx at(x = xn ) = h yn + 2 yn + 3 yn + 4 yn + ...
 2 
d y 1 11 4
 2 3

dx2 at(x = xn ) = h2 yn + yn + 12 yn + ...
 3 
d y 1
3 4 
dx3 at(x = xn ) = h3 2 yn + ...

3.2 Numerical integration by trapezoidal and Simpson 1/3 and 3/8 rules
The
R term numerical integration is the numerical evaluation of a definite integral say
b
a f(x) dx

where a and b are given constants and f(x) be a given function.


When we apply numerical integration to any function of two independent variables,
using double integration is called mechanical cubature.

Trapezoidal rule The follwoing rule is said to be trapezoidal rule.

h
I= 2 [(y0 + yn ) + 2(y1 + y2 + ... + yn1 )]

h is called length of the interval.


U LLL
h= no.of intervals

Simpsons 1/3 rule is

h
I= 3 [(y0 + yn ) + 2(y2 + y4 + ...) + 4(y1 + y3 + ...)]

Note: In simpsons 1/3 rule, y(x) is a polynomial of degree 2. To apply this rule
the number of intervals should be even or the number of ordinates must be odd. In
simpsons 1/3 rule, the truncation error is of the order h4 . i.e.

(ba)h4 M
|E| 180

where M = max(y0iv , y1iv , y2iv , ..)


6

Simpsons 3/8 rule is

3h
I= 8 [(y0 + yn ) + 3(y1 + y2 + y4 + y5 + ... + yn3 ) + 2(y3 + y6 + ...)]

Note: In simpsons 3/8 rule, y(x) is a polynomial of degree 3. To apply this rule the
number of intervals must be a multiple of 3.

3.3 Rombergs method


Let I = ba f(x) dx
R

Using trapezoidal or simpsons rule, let us find the value of the given definite inte-
gral by taking the different values of h or x.

Let us apply trapezoidal rule for several times by the values as h, h/2, h/4, h/8,
h/16...

In this type of problems, let

I2 I1
I = I2 + 3

where I1 = the value of the definite integral, dividing h into two parts.
Similarly I2 = the value of the definite integral, dividing h into four parts.
Similarly we can calculate the values of
I3 I2
I = I3 + 3

This method can continue till we get two successive values are equal.

3.4 Two and Three point Gaussian quadrature formulae


Two point formula In this case change the given interval a to b into -1 to 1 using
the following procedure. Transformation formula is

a+b ba
 
x= 2 + 2 t

where b is the upper limit and a is the lower limit.

1
R
1 f(t) dt = f(1/ 3) + f(-1/ 3)

Three point formula In this case change the given interval a to b into -1 to 1 using
the following procedure. Transformation formula is

a+b ba
 
x= 2 + 2 t
7

where b is the upper limit and a is the lower limit.

1
R
1 f(t) dt = A1 f(t1 ) + A2 f(t2 ) + A3 f(t3 )

where A1 = A3 = 0.5555
A2 = 0.88888
t1 = 0.7745
t2 = 0
t3 = +0.7745

3.5 Double integral using trapezoidal and Simpsons rules


trapezoidal rule is

I = hk
4 [sumof thef ourcornervalues(circle)+
2(sum of values available in rectangular box) + 4(sum of remaining values) ]

simpson rule is

I = hk
9 [sumof thef ourcornervalues(circle)+
4(sum of values available in rectangular box) + 16(sum of remaining values) ]

4 INITIAL VALUE PROBLEMS FOR ODE


There are several methods for solving differential equations numerically.
1. Taylors series method
2. Eulers method
3. Rungi-kutta method
4. Milnes predictor and corrector method
5. Adams predictor and corrector method

4.1 Single step methods


Taylors series method Taylors series about x = x0 is given by
0 (xx0 )2 00 (xx0 )3 000 (xx0 )4 00
y(x) = y0 + (x - x0 ) y0 + 2! y0 + 3! y0 + 4! y0 v

where n0 , y0 denotes the initial values of x and y

Euler method for first order equation eulers method formula or eulers algorithm.
yn+1 = yn + h f(xn , yn ) where n=0,1,2...

modified eulers method formula :

yn+1 = yn + h f xn + h2 ; yn + h2 f (xn , yn )
 
8

Fourth order Runge-Kutta method for solving first and second order equa-
tions in this method , let us assume that
dy
dx = f(x,y) be given

diff eqn, the above eqn can be solved under the condition

y(xo )= y0

let the increment h = length of the interval between two values

fourth order rangi kutta method

K1 = h f(x0 , y0 )
k1
K2 = h f(x0 + h2 , y0 + 2 )

k2
K3 = h f(x0 + h2 , y0 + 2 )

K4 = h f(x0 + h, y0 + k3 )
(K1 +2K2 +2K3 +K4 )
y = 6

y1 = y0 + y

x1 = x0 + h

The increments in y for the second interval is computed in a similar manner by the
following formulae.

K1 = h f(x1 , y1 )
k1
K2 = h f(x1 + h2 , y1 + 2 )

k2
K3 = h f(x1 + h2 , y1 + 2 )

K4 = h f(x1 + h, y1 + k3 )
(K1 +2K2 +2K3 +K4 )
y = 6

y2 = y1 + y

x2 = x1 + h

4.2 Multistep methods

Milnes predictor and corrector methods

1. To use Milnes predictor and corrector formula, we need atleast 4 values.


9

2. If the initial values are not given, we can obtain these values either by using Taylors
series method or by R-K method.

3. We can apply milnes corrector formula only after applying milnes predictor for-
mula.

Milnes predictor formula is


 0 0 0

yn+1,p = yn3 + 4h
3 2yn2 y n1 + 2yn

Milnes corrector formula is


 0 0 0

yn+1,c = yn1 + h3 yn1 + 4yn + yn+1

Adams predictor and corrector methods Adams predictor formula is


 0 0 0 0

h
yn+1,p = yn + 24 55yn 59yn1 + 37yn2 9yn3

Adams corrector formula is


 0 0 0 0

h
yn+1,c = yn + 24 9yn+1 + 19yn 5yn1 + yn2

5 BOUNDARY VALUE PROBLEMS IN ODE AND PDE


to be included later.

You might also like