Professional Documents
Culture Documents
MIT2 29F11 Lect 12
MIT2 29F11 Lect 12
FINITE DIFFERENCES
Classification of Partial Differential Equations (PDEs) and examples
with finite difference discretizations
Parabolic PDEs
Elliptic PDEs
Hyperbolic PDEs
2.29
Polynomial approximations
Newtons formulas
Lagrange polynomial and un-equally spaced differences
Hermite Polynomials and Compact/Pades Difference schemes
Equally spaced differences
Richardson extrapolation (or uniformly reduced spacing)
Iterative improvements using Roombergs algorithm
2.29
2.29
Classification of
n(x,y2)
n(x1,y)
n(x2,y)
Hyperbolic
Parabolic
Elliptic
n(x,y1)
Equations may change of type from point to point if A, B and C vary with x, y, . etc
Navier-Stokes, incomp., const. viscosity: Du u (u ) u 1 p 2 u g
Dt
2.29
n(x,y2)
n(x1,y)
D(x,y)
n(x2,y)
Hyperbolic
Parabolic
Elliptic
n(x,y1)
x
2.29
Examples:
Poisson Equation
Potential Flow with sources
Heat flow in plate
Helmholtz equation Vibration of plates
U u 2u
Convection-Diffusion
u(x,b) = f2(x)
Equidistant Sampling
Discretization
ua,y)=g2(y)
u0,y)=g1(y)
j+1
j
j-1
Finite Differences
i-1 i i+1
u(x,0) = f1(x)
2.29
y
u(x,b) = f2(x)
Boundary Conditions
ua,y)=g2(y)
u0,y)=g1(y)
j+1
j
j-1
i
i
i-1 i i+1
u(x,0) = f1(x)
x
PFJL Lecture 12,
Elliptic PDE:
Poisson Equation
2.29
2
2u
2 u
(1)
c
x 2
t 2
u
u
(2)
c
0
t
x
u
(3)
(U ) u g
t
(4) (U ) u g
d xc
U( x c (t ))
dt
d xc
U
ds
x, y
PFJL Lecture 11,
10
2u ( x , t )
c
0 x L, 0 t
x 2
Initial Conditions
uL,t)
u0,t)
Boundary Conditions
Wave Solutions
u(x,0), ut(x,0)
2.29
11
2u ( x, t )
t 2
2u ( x , t )
c
x 2
0 x L, 0 t
Discretization:
uL,t)
u0,t)
j+1
j
j-1
i-1 i i+1
u(x,0), ut(x,0)
2.29
12
u0,t)
j+1
j
j-1
Stability Requirement:
i-1 i i+1
c t
1 Courant-Friedrichs-Lewy condition (CFL condition)
x
u(x,0), ut(x,0)
Physical wave speed must be smaller than the largest numerical wave speed, or,
Time-step must be less than the time for the wave to travel to adjacent grid points:
c
2.29
x
x
or t
t
c
13
L ( ) Lx ( ) 0 when x 0
14
x L ( ) Lx ( )
Remember:
does not satisfy the FD eqn.
Lx ( ) x
The truncation error acts as a source for the discretization error, which is
convected and diffused by the operator Lx
2.29
15
Stability
Stability
A numerical solution scheme is said to be stable if it does not amplify
Lx1 Const.
16
Convergence
Convergence
A numerical scheme is said to be convergent if the solution of the
discretized equations tend to the exact solution of the (P)DE as the gridspacing and time-step go to zero
1
Error equation for linear(-ized) systems: Lx ( x )
Lx1 ( x ) Lx1 x
For a consistent scheme: x O (x p ) for x 0
Hence Lx1
x O (x p )
x
17
( xi 1 ) ( xi )
x
x 0
Geometrical Interpretation
Quality of approximation
get closer to xi
D xi+1
D xi
i-2
i-1
i+1
i+2
x
Exact
Backward
Central
Forward
Image by MIT OpenCourseWare.
2.29
18
FINITE DIFFERENCES:
f '(xi )
f ( xi1 ) f ( xi ) x
f ''(xi ) O(x 2 )
x
2!
2.29
19
FINITE DIFFERENCES:
x 2
x 3
x n n
f (xi1 ) f (xi ) x f '(xi )
f ''(xi )
f '''(xi ) ...
f (xi ) Rn
2!
3!
n!
x n1
( n1)
Rn
f
( )
n 1!
x 2
f ( xi1 ) f ( xi ) x f '(xi )
f ''(xi ) O( x 3 )
* ( 2)
2!
f ( xi2 ) 2 f ( xi1 ) f ( xi )
f
''(x
)
O(x)
i
4x 2
x 2
3 * (1)
f (xi2 ) f (xi ) 2x f '(xi )
f ''(xi ) O(x )
2!
f ( xi1 ) f ( xi ) x
f ''(xi ) O( x 2 )
x
2!
f ( xi 1 ) f ( xi ) x f ( xi 2 ) 2 f ( xi 1 ) f ( xi )
f ( xi 2 ) 4 f ( xi 1 ) 3 f ( xi )
2
O
x
O ( x 2 )
f '( xi )
2
x
2!
x
2x
f '( xi )
2.29
20
Forward
Forward finite-divided-difference formulas:
Differences
First Derivative
f (xi1 ) f (xi )
f (xi )
h
f (xi )
2h
Second Derivative
f (xi2 ) 2 f (xi1 ) f (xi )
f "(xi )
h2
f (xi3 ) 4 f (xi2 ) 5 f (xi1 ) 2 f (xi )
f "(xi )
h2
Error
O(h)
O(h2)
O(h)
O(h2)
Third Derivative
f (xi3 ) 3 f (xi2 ) 3 f (xi1 ) f (xi )
O(h)
f '"(xi )
h3
3 f (xi4 ) 14 f (xi3 ) 24 f (xi2 ) 18 f (xi1 ) 5 f (xi )
O(h2)
f '"(xi )
2h 3
2.29
21
Backward
Backward finite-divided-difference formulas:
Differences
First Derivative
f (xi ) f (xi1 )
f (xi )
h
f (xi )
2h
Second Derivative
f (xi ) 2 f (xi1 ) f (xi2 )
f "(xi )
h2
2 f (xi ) 5 f (xi1 ) 4 f (xi2 ) f (xi3 )
f "(xi )
h2
Error
O(h)
O(h2)
O(h)
O(h2)
Third Derivative
f (xi ) 3 f (xi1 ) 3 f (xi2 ) f (xi3 )
f '"(xi )
h3
5 f (xi ) 18 f (xi1 ) 24 f (xi2 ) 14 f (xi3 ) 3 f (xi4 )
f '"(xi )
2h 3
2.29
O(h)
O(h2)
22
First Derivative
O(h)
f (xi1 ) f (xi1 )
f (xi )
2h
2)
f (xi2 ) 8 f (xi1 ) 8 f (xi1 ) f (xi2 )
O(h
f (xi )
12h
Second Derivative
O(h)
f (xi1 ) 2 f (xi ) f (xi1
)
f "(xi )
h 2
O(h2)
f (xi2 ) 16 f (xi1 ) 30 f (xi ) 16 f (xi1 ) f (xi2
)
f "(xi )
12h 2
Third Derivative
O(h)
f (xi2 ) 2 f (xi1 ) 2 f (xi1 ) f (xi2
)
f '"(xi )
2h 3
2.29
23
FINITE DIFFERENCES
Taylor Series, Higher Order Accuracy: EXAMPLE
Problem: Estimate 1st derivative of f = -0.1*x^4 - 0.15*x^3-0.5*x^2-0.25*x +1.2 at
x=0.5, with a step size of 0.25 and using successively higher order schemes.
How does the solution improve?
%Define the function
L11_FD.m
%% Central difference
%Second order:
df=(f(x+h)-f(x-h)) / (2*h);
h=0.25;
%Set point at which to evaluate the derivative
x = 0.5;
%Fourth order:
df=(-f(x+2*h)+8*f(x+h)-8*f(x-h)+f(x-2*h)) /
(12*h);
%First order:
df=(f(x+h)-f(x)) / h;
fprintf('\n\n First order Forward difference: %g, with
error:%g%% \n',df,abs(100*(df+0.9125)/0.9125))
%Second order:
df=(-f(x+2*h)+4*f(x+h)-3*f(x)) / (2*h);
Output
%% Backwards difference
%First order:
df=(-f(x-h)+f(x)) / (h);
%Second order:
df=(f(x-2*h)-4*f(x-h)+3*f(x)) / (2*h);
2.29
24
Approach:
FINITE DIFFERENCES:
General approximation:
s
mu
m ai u ji x
x j i r
25
FINITE DIFFERENCES:
( xi xi xi1 ) , then
2
2
2
2
f ( xi1 ) xi f ( xi1 ) xi1 f ( xi ) xi1 xi
f '( xi )
xi1 xi (xi xi1 )
26
MIT OpenCourseWare
http://ocw.mit.edu
For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms.