Methods of Numbers formula sheet
Transcript of Methods of Numbers formula sheet
-
8/11/2019 Methods of Numbers formula sheet
1/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 rangeis called interpolation.
Extrapolation The process of computing the value of a function outside the givenrange 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.
-
8/11/2019 Methods of Numbers formula sheet
2/9
2
Newtons backward difference operator is
= 1 - ENewtons forward interpolation formula is
y = y0+uy0+ u(u1)
2! 2y0+
u(u1)(u2)3!
3y0+...
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
y = yn+uyn+ u(u+1)2! 2yn+ u(u+1)(u+2)3! 3yn+...
where u = (x - xn) / h
The above formula is used mainly for interpolating the values of y near the end ofa 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 variablesare not equally spaced, then we can use following Lagrangians Interpolation formulaand inverse interpolation formula.
Lagrangian interpolation formula for unequal spaces is
y = f(x) = (xx1)(xx2)...(xxn)(x0x1)(x0x2)...(x0xn)
y0+
(xx0)(xx2)(xx3)...(xxn)(x1x0)(x1x2)(x1x3)...(x1xn)
y1+
(xx0)(xx1)(xx3)...(xxn)
(x2x0
)(x2x1
)(x2x3
)...(x2xn
)
y2+
...+ (xx0)(xx1)(xx2)...(xxn1)
(xnx0)(xnx1)(xnx2)...(xnxn1)yn
Lagrangian inverse interpolation formula for unequal spaces is
x = f(y) = (yy1)(yy2)...(yyn)
(y0y1)(y0y2)...(y0yn)x0+
(yy0)(yy2)(yy3)...(yyn)(y1y0)(y1y2)(y1y3)...(y1yn)
x1+
(yy0)(yy1)(yy3)...(yyn)(y2y0)(y2y1)(y2y3)...(y2yn)
x2+
...+ (yy0)(yy1)(yy2)...(yyn1)
(yny0)(yny1)(yny2)...(ynyn1)xn
-
8/11/2019 Methods of Numbers formula sheet
3/9
3
2.3 Divided differences
If the values of x are given at unequal intervals then we use divided differences. Divideddifferences take into consideration the change of the values of the function f(x) and alsothe 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(x0, x1) = f(x1)f(x0)
x1x0
similarly,
f(x1, x2) = f(x2)f(x1)
x2x1
f(xn1, xn) = f(xn)f(xn1)
xnxn1
Second divided difference is
f(x0, x1, x2) = f(x1,x2)f(x0,x1)
x2x0
Third divided difference is
f(x0, x1, x2, x3) = f(x1,x2,x3)f(x0,x1,x2)
x3x0
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 valueof 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 xwhere xi x xi+1 where i = 0,1,2,.. n+1. In this case we have to use cubic splinemethod.
1. f(x) is a cubic polynomial
2. f
(x) is second degree polynomial.
-
8/11/2019 Methods of Numbers formula sheet
4/9
4
3. f
(x) is a first degree polynomial.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
f(x) = 16h
(xi x)3Mi1+ (x xi1)3Mi
+xix
h
yi1 h
2Mi16
+
xxi1h
yi h
2Mi6
where h = xi xi1 for all i
Mi1+ 4Mi+Mi+1= 6h2 [yi1 2yi+yi+1] i
here i = 1,2,3,.. n-1M0= 0Mn = 0f
(xi) = Mi
3 NUMERICAL DIFFERENTIATION AND INTEGRATION
Numerical differentiation is a process of calculating the derivative of the given functionby means of a table of given values of that function. In this process, we have to calculate
dydx
, d2y
dx2
at a given point is called numerical differentiation. In this case, we have to use Newtonsforward and backward difference formula to compute the derivatives.
In the previous units, we are finding the polynomial curves y = f(x) passing throughn+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 usingNewtons formula.
If the derivative required at a point nearer to starting value in table, use newtonsforward 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 orLagrangian interpolation formula.
3.1 Differentiation using interpolation formulae
Newtons forward difference formula is
y = y0+uy0+ u(u1)
2! 2y0+
u(u1)(u2)3!
3y0+...
-
8/11/2019 Methods of Numbers formula sheet
5/9
5
where u = (x - x0) / h
dydx
at(x= x0) =
1hy0
12
2
y0+ 13
3
y0 14
4
y0+...
d2y
dx2
at(x= x0) =
1h2
2y0 3y0+ 11124y0 13165y0+...
d3y
dx3
at(x= x0) =
1h3
3y0 324y0+...
Newtons backward difference formula is
y = yn+uyn+ u(u+1)2! 2yn+ u(u+1)(u+2)3! 3yn+...
where u = (x - xn) / h
dydx
at(x= xn) = 1h
yn+ 1
22yn+
1
33yn+
1
44yn+...
d2y
dx2
at(x= xn) =
1h2
2yn+ 3yn+ 11124yn+...
d3y
dx3
at(x= xn) =
1h3
324yn+...
3.2 Numerical integration by trapezoidal and Simpson 1/3 and 3/8 rules
The term numerical integration is the numerical evaluation of a definite integral sayba
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.
I = h2
[(y0+yn) + 2(y1+y2+...+yn1)]
h is called length of the interval.h= ULLL
no.ofintervals
Simpsons 1/3 rule is
I = h3
[(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 rulethe number of intervals should be even or the number of ordinates must be odd. Insimpsons 1/3 rule, the truncation error is of the order h4. i.e.
|E| (ba)h4M180
where M = max(yiv0 , yiv1 , yiv2 , ..)
-
8/11/2019 Methods of Numbers formula sheet
6/9
6
Simpsons 3/8 rule is
I = 3h8 [(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 thenumber of intervals must be a multiple of 3.
3.3 Rombergs method
Let I = ba
f(x) dx
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
I = I2+ I2I1
3
whereI1 = the value of the definite integral, dividing h into two parts.SimilarlyI2 = the value of the definite integral, dividing h into four parts.Similarly we can calculate the values of
I = I3+ I3I2
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 usingthe following procedure. Transformation formula is
x =a+b2
+
ba2
t
where b is the upper limit and a is the lower limit.
11
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 usingthe following procedure. Transformation formula is
x =a+b2
+
ba2
t
-
8/11/2019 Methods of Numbers formula sheet
7/9
7
where b is the upper limit and a is the lower limit.
11
f(t) dt = A1 f(t1) + A2 f(t2) + A3 f(t3)
whereA1= A3 = 0.5555A2 = 0.88888t1= 0.7745t2 = 0t3= +0.7745
3.5 Double integral using trapezoidal and Simpsons rules
trapezoidal rule is
I = hk4
[sumofthefourcornervalues(circle)+2(sum of values available in rectangular box) + 4(sum of remaining values) ]
simpson rule is
I = hk9
[sumofthefourcornervalues(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 method2. Eulers method3. Rungi-kutta method4. Milnes predictor and corrector method5. Adams predictor and corrector method
4.1 Single step methods
Taylors series method Taylors series about x = x0 is given by
y(x) = y0 + (x - x0) y
0 + (xx0)
2
2! y
0 + (xx0)
3
3! y
0 + (xx0)
4
4! y
v0
wheren0, 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 fxn+ h2 ; yn+ h2f(xn, yn)
-
8/11/2019 Methods of Numbers formula sheet
8/9
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)
K2 = h f(x0+ h2 , y0+ k12)
K3 = h f(x0+ h2, y0+
k22)
K4 = h f(x0+h, y0+k3)
y = (K1+2K2+2K3+K4)6
y1 = y0 + y
x1 = x0 + h
The increments in y for the second interval is computed in a similar manner by thefollowing formulae.
K1 = h f(x1, y1)
K2 = h f(x1+ h2, y1+
k12
)
K3 = h f(x1+ h2, y1+
k22
)
K4 = h f(x1+h, y1+k3)
y =
(K1+2K2+2K3+K4)
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.
-
8/11/2019 Methods of Numbers formula sheet
9/9
9
2. If the initial values are not given, we can obtain these values either by using Taylorsseries method or by R-K method.
3. We can apply milnes corrector formula only after applying milnes predictor for-mula.
Milnes predictor formula is
yn+1,p = yn3+ 4h3
2y
n2 y
n1+ 2y
n
Milnes corrector formula is
yn+1,c = yn1+ h3
y
n1+ 4y
n+y
n+1
Adams predictor and corrector methods Adams predictor formula is
yn+1,p = yn+ h24
55y
n 59y
n1+ 37y
n2 9y
n3
Adams corrector formula is
yn+1,c = yn+ h24
9y
n+1+ 19y
n 5y
n1+y
n2
5 BOUNDARY VALUE PROBLEMS IN ODE AND PDE
to be included later.