Professional Documents
Culture Documents
Prepared by
Rasel Ahmmed
Lecturer, Dept. of EEE
BSMRSTU, Gopalganj
Lecture’s Goals
• Finite Difference Schemes
• Taylor Series Expansion for Differentiation
• Basic Numerical Integration
– Trapezoidal Rule
– Simpson’s Rule
– Midpoint
– Gaussian Quadrature
Calculus - Numerical Methods
Differentiation Integration
v v
dv
dt
t t
a y
b
dv y vdt
a a
dt
t
Numerical Differentiation
• Estimate the derivatives (slope,
curvature, etc.) of a function by using the
function values at only a set of discrete
points
• Ordinary differential equation (ODE)
• Partial differential equation (PDE)
Numerical Differentiation
• Represent the function by Taylor
polynomials or Lagrange interpolation
• Evaluate the derivatives of the
interpolation polynomial at selected
nodal points
Numerical Differentiation
A Taylor series or Lagrange interpolation of points
can be used to find the derivatives. The Taylor
series expansion is defined as:
f xi f x0 x
df
x
2
d2 f
x d 3 f
3
dx xx0 2! dx 2 x x0
3! dx 3
x x0
x xi x0
f ( x )
f xi f xi f xi
x 2! 3!
Forward Differentiation
Error
x f x x 2
f xi
i
2! 3!
Backward Differentiation
Error
x f x x 2
f xi
i
2! 3!
Central Differentiation
Error
x 2
f xi
3!
Differential Error
x x2 x x3
y1
x x1 x x3
y2
x x1 x x2
y3
x1 x2 x1 x3 x2 x1 x2 x3 x3 x2 x3 x1
Lagrange Differentiation
Differentiate the Lagrange interpolation
2 x x2 x3
f x Lx y1
x1 x2 x1 x3
2 x x1 x3 2 x x1 x2
y2 y3
x2 x1 x2 x3 x3 x2 x3 x1
Assume a constant spacing
2 x x2 x3 2 x x1 x3 2 x x1 x2
f x 2
y1 2
y2 2
y3
2x x 2x
Lagrange Differentiation
Differentiate the Lagrange interpolation
2 x x2 x3 2 x x1 x3 2 x x1 x2
f x 2
y1 2
y2 2
y3
2x x 2x
Various locations
2x x x 2x x x 2 x1 x1 x2 3 y1 4 y2 y3
f x1 1 2 2 3 y1 1 1 2 3 y2 y3
2x x 2x 2 2x
2 x2 x2 x3 2 x2 x1 x3 2 x2 x1 x2 y3 y1
f x2 y1 y 2 y 3
2x 2 x 2 2x 2 2x
2 x3 x2 x3 2 x3 x1 x3 2 x3 x1 x2 y1 4 y2 3 y3
f x3 y1 y 2 y3
2x 2 x 2 2x 2 2x
Lagrange Differentiation
To find a higher order derivative from the Lagrange
interpolation for a three point Lagrange
2 x x2 x3 2 x x1 x3 2 x x1 x2
f x 2
y1 2
y2 2
y3
2x x 2x
1 2 1 y1 2 y2 y3
f x 2 y1 2
y 2 2 y3
x x x x 2
Example
• Find a Lagrange differential x f(x)
f’(x) to interpolate the data.
3 3
4 5
5 1
6 6
7 9
20
Partial Derivatives
• Straightforward extension of one-dimensional
formula
(i, j+2)
(i, j-2)
u 1
ux 1 0 1
x 2h
2u 1
u xx 2
2 1 2 1
x h
(i, j+2)
(i, j-2)
Partial Derivatives
Laplacian Operator
2
u u xx u yy
1 j+1
|
1
2
1 4 1 j
h
|
1 j-1
i-1 i i+1
Partial Derivatives
Mixed Derivative
1 0 1 j+1
| | |
1
u xy 2 0 0 0 j
4h
| | |
1 0 1 j-1
i-1 i i+1