Beruflich Dokumente
Kultur Dokumente
Finite Difference
Methods and
Interpolation
Finite Differences
• Numerical technique that lends itself to the
numerical solution of large sets of simultaneous
differential equations that lack analytical
solutions.
• Need to develop the systematic terminology used
in the calculus of finite differences.
• Finite differences also find application in the
derivation of interpolating polynomials.
Symbolic Operators
• Definition of the derivative
df ( x ) f ( x) − f ( x0 )
= f ′( x 0 ) = lim
dx x0
x →x 0 x − x0
h = x − x0
Symbolic Operators
• The derivative may therefore be approximated:
f ( x0 + h ) − f ( x0 )
f ′( x0 ) ≈
h
• Mean Value Theorem states "Let f(x) be continuous in
a ≤ x≤ b, and differentiable in the range a<x<b; then
there exists at least one ξ , a<ξ <b for which
The Mean Value Theorem
f ( b) − f ( a )
f ′( ξ ) =
forms the basis for both
differential and finite difference
b−a calculus
Symbolic Operators
• A function f(x) continuous and differentiable in the
interval [x0, x] can be represented by Taylor series:
f ( x ) = f ( x0 ) + ( x − x0 ) f ′( x0 ) +
( x − x0 ) f ′′( x0 )
2
+
2!
( x − x0 ) 3 f ′′′( x0 ) + + ( x − x0 ) n f ( n ) ( x0 ) + R ( x )
n
3! n!
R n ( x) =
( x − x 0 ) f ( n +1) ( ξ )
n +1
( n + 1) !
• Remainder is of the order (n+1) because it is a function
of a term (x-x0)n+1 and the (n+1)th derivative → O(nn+1)
Linear Symbolic Operators
Operator Definition
D differential
I integral
E shift
∆ forward difference
∇ backward difference
δ center difference
µ average
Linear Symbolic Operators
dy( x )
• Differential Operator, D Dy( x ) = = y′( x )
dx
x+h
• Integral Operator, I Iy ( x ) = ∫ y( x ) dx
x
−1
I=D
Linear Symbolic Operators
Ey ( x ) = y ( x + h )
• Shift Operator, E
E y( x ) = y( x − h )
-1
E y( x ) = y( x + nh )
n
Linear Symbolic Operators
• Express shift operator in terms of differential operator by
expanding y(x+h) into a Taylor series:
h h2 h3
y( x + h ) = y( x ) + y′( x ) + y′′( x ) + y′′′( x ) +
1! 2! 3!
h h2 2 h3 3
y( x + h ) = y( x ) + Dy( x ) + D y( x ) + D y( x ) +
1! 2! 3!
h h2 2 h3 3
y( x + h ) = 1 + D + D + D + y( x ) Content of parantheses is Taylor
series expansion of ehD .
1! 2! 3!
y( x + h ) = e hD y( x ) compare to definition…
E = e hD
Linear Symbolic Operators
• Inverse of shift in terms of differential operator :
h h2 h3
y ( x − h ) = y ( x ) − y′( x ) + y′′( x ) − y′′′( x ) +
1! 2! 3!
h h2 2 h3 3
y ( x − h ) = y ( x ) − Dy ( x ) + D y ( x ) − D y ( x ) +
1! 2! 3!
h h 2 2 h3 3
y ( x − h ) = 1 − D + D − D + y ( x )
1! 2! 3!
y ( x − h ) = e − hD y ( x )
− hD Content of parantheses is Taylor
E =e
-1
series expansion of e-hD .
Backward Finite Difference (BFD)
• Consider the equivalent sets of values:
y i −3 yi−2 y i −1 yi y i +1 yi+2 y i +3
y( x − 3h ) y( x − 2 h ) y( x − h ) y( x ) y( x + h ) y( x + 2 h ) y( x + 3h )
∇y i = y i − y i −1
∇y ( x ) = y ( x ) − y ( x − h )
Backward Finite Difference
The second backward finite difference:
∇ y i = ∇( ∇y i ) = ∇( y i − y i −1 )
2
= ∇y i − ∇y i −1
= ( y i − y i −1 ) − ( y i −1 − y i − 2 )
= y i − 2 y i −1 + y i − 2
∇ y( x ) = y( x ) − 2 y( x − h ) + y( x − 2h )
2
Backward Finite Difference
( )
∇ 3 y i = ∇ ∇ 2 y i = ∇( y i − 2 y i −1 + y i − 2 )
= ∇y i − 2∇y i −1 + ∇y i − 2
= ( y i − y i −1 ) − 2( y i −1 − y i − 2 ) + ( y i − 2 − y i −3 )
= y i − 3y i −1 + 3y i − 2 − y i −3
Backward Finite Difference
n
n!
n
∇ y= ∑ ( − 1)
m =0
m
( n − m ) !m !
yi−m
Backward Finite Difference
Establish relationship between backwards difference
operators and differential operators (i.e, ∇ =f(D)):
∇y ( x ) = y ( x ) − y ( x − h )
= y( x ) − e − hD y( x )
(= 1− e) y( x )
− hD
∇ = hD −
h 2 D 2 h 3 D3
+ −
2 3
∇ = (1 − e ) − hD
∇ 2 = h 2 D 2 − h 3D3 + 127 h 4 D 4 −
∇ = (1 − e )
n − hD n
∇ 3 = h 3 D3 − 32 h 4 D 4 + 54 h 5 D5 −
Relate ∇ to D
∇ = 1 − e hD ∇ 2 ∇3 ∇ 4
2 2 3 3 hD = ∇ + + + + ...
h D hD 2 3 4
∇ = hD − + − ...
2 6 11 4 5 5
h D = ∇ + ∇ + ∇ + ∇ + ...
2 2 2 3
7 4 4 12 6
∇ = h D − h D3 + h D − ...
2 2 2 3
12 3 4 7 5
h D = ∇ + ∇ + ∇ + ...
3 3 3
3 4 4 5 5 2 4
∇ = h D − h D + h D5 − ...
3 3 3
2 4 ∇ 2
∇ 3
∇ 4
h n
D n
= (∇ + + + + ...) n
∇ n = (1 − e − hD ) n 2 3 4
Forward Finite Difference (FFD)
• The first forward ∆y i = y i +1 − y i
finite difference: ∆y( x ) = y( x + h ) − y( x )
∆2 y i = ∆( ∆y i ) = ∆( y i +1 − y i )
• The second
backward = ∆y i +1 − ∆y i
finite difference = ( y i + 2 − y i +1 ) − ( y i +1 − y i )
= y i + 2 − 2 y i +1 + y i
∆2 y( x ) = y( x + 2h ) − 2 y( x + h ) + y( x )
Relate ∆ to D
∆ = e − hD − 1 ∆2 ∆3 ∆4
hD = ∆ − + − + ...
h 2 D 2 h3 D 3 2 3 4
∆ = hD + + + ...
2 6 11 4 5 5
h D = ∆ − ∆ + ∆ − ∆ + ...
2 2 2 3
7 4 4 12 6
∆ = h D + h D3 + h D + ...
2 2 2 3
12 3 4 7 5
h D = ∆ − ∆ + ∆ − ...
3 3 3
3 4 4 5 5 2 4
∆ = h D + h D + h D5 + ...
3 3 3
2 4 ∆ 2
∆3
∆4
h n D n = (∆ − + − + ...) n
∆n = (e − hD − 1) n 2 3 4
Central Finite Difference (CFD)
y i −1½ y i −1 y i −½ yi y i +½ y i +1 y i +1½
y( x − 1½ h ) y( x − h ) y( x − ½ h ) y( x ) y( x + ½ h ) y( x + h ) y( x + 1½ h )
Central Finite Difference
• The first central δy i = y i +½ − y i −½
finite difference:
δy( x ) = y( x + ½ h ) − y( x − ½ h )
δ 2 y i = δ( δy i ) = δ( y i +½ − y i −½ )
• The second
central = δy i +½ − δy i −½
finite difference = ( y i +1 − y i ) − ( y i − y i −1 )
= y i +1 − 2 y i + y i −1
δ 2 y( x ) = y( x + h ) − 2 y( h ) + y( x − h )
Central Finite Difference
The nth forward finite difference:
n
n!
n
δ y= ∑ ( − 1)
m =0
m
( n − m ) !m !
y i − m +½ n
µ δy i = 1
2
[E ½
δy i + E −½ δy i ]
= 1
2
[ δyi +½ + δyi −½ ]
= 12 [ ( y i +1 − y i ) + ( y i − y i −1 ) ]
1
2
( y i +1 − y i −1 )
Relate δ to D
µ δy( x ) = 2 [e − e ] ⋅ y( x )
1 hD − hD
µ δ= sinh ( hD)
Relate δ to D
sin ( hD) = hD +
( hD)
3
+
( hD)
5
+
( hD)
7
+
3! 5! 7!
h 3 D3 h 5 D5 h 7 D 7
= hD + + + +
6 120 5040
Relate δ to D
δ 2 y( x ) = y( x + h ) − 2 y( x ) + y( x − h )
= e hD y( x ) − 2 y( x ) + e − hD y( x )
δ 2
y x = [ e − 2 + e ] ⋅ y( x )
( ) hD − hD
δ = 2[ cosh ( hD) − 1] = E + E − 2
2 −1
Relate δ to D
Expand in Taylor Series (and by analogy, expand to higher
order Central Finite Difference terms):
4 4 6 6 8 8
2 2 2 h D h D h D
δ =h D + + + +
12 360 20160
5 5 7 7
3 3 3 h D h D
µ δ=h D + + +
4 540
6 6 8 8
4 4 4 h D h D
δ =h D + + +
6 80
Relate δ to µ
Start with definitions of µ and δ :
µ= 1
2
[E + E ]
½ −½
µ 2
= [ E + E + 2]
1
4
−1
δ 2 = E + E −1 − 2 2 2
µ = ¼δ + 1
2 −1
δ +2=E+E
Relate δ to µ
• Recall:
µ δ= sinh ( hD) → hD = sinh −1 ( µ δ)
• Expand inverse sine argument:
sinh −1
( µ δ) = µ δ−
( µ δ)
3
+
3( µ δ)
5
−
6 40
• Substitute:
hD = µ δ−
( µ δ)
3
+
3( µ δ)
5
−
6 40
Relate δ to µ
h3 D3 h5 D5 h7 D 7
µ δ= hD + + + + ...
6 120 5040
4 4 6 6 8 8
h D h D h D
δ =h D +
2 2 2
+ + + ...
12 360 20160
5 5 7 7
h D h D
µ δ =h D +
2 3 3
+ + ...
4 40
6 6 8 8
h D hD
δ =h D +
4 4 4
+ + ...
6 80
Relate µδ to D
δ3 δ5 δ7
hD = µ δ − + − + ...
6 30 140
δ 3
δ 4
h2 D2 = δ 2 − + − ...
12 90
δ 5
7δ 7
h D = µ δ −
3 3 3
+ − ...
4 120
δ 7δ 6 8
h D =δ −
4 4
+4
− ...
6 240
Difference Equations and Solution
• Forward, backward, and central FD equations are
used in the solution of differential equations.
• FDs transform differential equations into
difference equations:
f ( y k , y k +1 , , y k + n ) = 0
– Eqns may be linear/nonlinear, may be
homogeneous/non, and may have constant or variable
coefficients
– We will focus on linear, homogeneous systems with
constant coefficients
Order of a Difference Equation
• The order of a difference equation is the
difference between the highest and lowest
subscript of the dependent variable:
order = (k+n)-k=n
• 2nd order homogeneous linear ordinary differential equation
y′′ + 3y′ − 4 y = 0
• 2nd order homogeneous linear difference equation
y k + 2 + 3y k +1 − 4 y k = 0
Solution of a Differential Equation
y′′ + 3y′ − 4 y = 0
D 2 y + 3Dy − 4 y = 0
D 2 + 3D − 4 = 0 Characteristic equation
( D + 4)( D − 1) = 0
λ1 = −4, λ 2 = 1 Eigen values
y = C1e λ1x + C 2 e λ 2 x
y = C1e − 4 x + C 2 e x
Solution of a Difference Equation
y k + 2 + 3y k +1 − 4 y k = 0 real & distinct roots
E 2 y k + 3Ey k − 4 y k = 0 λ1 = −4, λ 2 = 1
k k
2
E + 3E − 4 = 0 y = C1λ1 + C 2 λ 2
( E + 4)( E − 1) = 0 y = C1 ( − 4 ) + C 2
k
y = ( C1 + C 2 k ) λk y = C1 ( α + β i ) + C 2 ( α − βi )
k k
Difference Equation Solution Forms
y k = C1 ( α + βi ) + C 2 ( α − β i )
k k
two complex roots
f ( x + nh ) = (1 + ∆ ) f ( x )
n
recall e hD = 1 + ∆ thus
f ( x) = f ( x0 ) +
( x − x 0 ) ∆f ( x ) + ( x − x 0 )( x − x1 ) ∆2f ( x ) + ( x − x 0 )( x − x1 )( x − x 2 ) ∆3f ( x ) +
0 2 0 3 0
n 2 !h 3 !h
• Generalized as:
n
k −1 ∆k f ( x 0 )
∑∏
f ( x ) = f ( x 0 ) + ( x − x m ) k
k =1 m = 0 k !h
+
( x − x −1 )( x − x 0 )( x − x1 ) 3
µ δf ( x 0 ) +
( x − x −1 )( x − x 0 ) ( x − x1 ) 4
2
δ f ( x0 ) +
3 4
3 !h 4 !h
– pk(x) are nth degree polynomial functions corresponding to each base point
– each weighting function polynomial pk(x) must be chose so that it has the value of
unity when x = xk, and zero at all other base points
n
0 i ≠ k
pk ( x) = pk ( x ) = Ck ∏( x − x ) i
1 i = k i =0
i≠k
selection criteria function form
Lagrange Polynomials
Constants Ck are evaluated to make the second criteria
true (pk(x) = 1 @ i = k): −1
n
Ck = ∏
ii =≠0k
( xk − xi )
n
0 i ≠ k
pk ( x) = pk ( x ) = Ck ∏( x − x )
i
1 i = k i =0
i≠k
selection criteria function form
Lagrange Polynomials
• Combine to yield Lagrange Interpolating Polynomials:
n
x − xi
pk ( x) = ∏
i =0 x k − x i
i≠k
n
f ( n +1) ( ξ )
R n ( x) = ∏
i =0
( x − xi )
( n + 1) !
, x0 < ξ < xn
Spline Interpolation
When dealing with a 3.5
polynomial is likely to
fluctuate between base 2
points.
0.5
1 2 3 4 5 6 7 8 9 10
X
Spline Interpolation
Pi ( x ) = a i x + b i x + c i x + d i
3 2
Pi ( x ) = a i x + b i x + c i x + d i
3 2
Pi ( x ) = 3a i x + 2b i x + c i
′ 2
Pi′′( x ) = 6a i x + 2b i
Cubic Spline
• 2nd derivative of interpolating polynomial at any point [xi-
1, xi] can be given by the 1st order LaGrange interpolation
polynomial:
x − xi x − x i −1
y′′ = y′i′−1 + y′i′
x i −1 − x i x i − x i −1
• Which can be integrated twice as:
y=
( x − xi )
3
y′i′−1 +
( x − xi )
3
+ C1x + C 2
6( x i −1 − x i ) 6( x i −1 − x i )
Cubic Spline
y=
( x − xi )
3
y′i′−1 +
( x − xi )
3
+ C1x + C 2
6( x i −1 − x i ) 6( x i −1 − x i )
1 ( x − xi ) x − xi
3
y= − ( x i −1 − x i )( x − x i ) y′i′−1 + y i −1
6 x i −1 − x i x
i −1 − x i
Eq. 1
1 ( x − xi ) x − x i −1
3
+ − ( x i − x i −1 )( x − x i −1 ) y′i′ + yi
6 x i − x i −1 x
i − x i −1
2( x2 − x0 ) ( x2 − x1 ) 0 0 0 0
(x − x ) 2( x3 − x1 ) ( x3 − x2 ) 0 0 0
2 1
0 ( x3 − x2 ) 2( x4 − x2 ) ( x4 − x3 ) 0 0
0 0 0 ( xn − 2 − x n − 3 ) 2( xn −1 − xn −3 ) ( xn −1 − xn − 2 )
0 0 0 0 2( xn −1 − xn − 2 ) 2( xn − xn − 2 )
y1′′ yx2 −− xy1 y1 − y 0
x1 − x0
or
y′′ y32 − y12
Ay′′ = c
y 2 − y1
2 x3 − x 2 x2 − x1
y3′′ y 4 − y3 y3 − y 2
which we
= 6 4 3
x −x x3 − x2
×
already know
−1
yn′′− 2
yn−1 − yn−2
xn−1 − xn−2
y n−2 − y n−3
xn−2 − xn−3
y′′ = A c how to solve
1
0 if n ≠ m
∫ Pn ( x ) Pm ( x ) dx = 2
−1 2 n +1 if n = m
Legendre Polynomials
Satisfies recurrence: ( n + 1) Pn +1 ( x ) − ( 2n + 1) xPn ( x ) + nPn −1 ( x ) = 0
0 P0 ( x ) = 1
P1 ( x ) = x
1.05 1
1
3x 2 − 1
2 P2 ( x ) =
2 Leg( 0 , x)
0.5
3
5x − 3x
P3 ( x ) =
Leg( 1 , x)
3 Leg( 2 , x)
2 Leg( 3 , x)
1 0.5 0 0.5 1
35x 4 − 30 x 2 + 3
P4 ( x ) =
Leg( 4 , x)
4 Leg( 5 , x)
8
0.5
( 2n − 2m ) !
−1
n 2
Pn ( x ) = ∑ ( − 1) n
1
x n −2m
m
2 m !( n − m ) !( n − 2m ) !
−1 x 1
m =0
Chebyshev Polynomials
Satisfies recurrence: Tn +1 ( x ) − 2 xTn ( x ) + Tn −1 ( x ) = 0
0 T0 ( x ) = 1
1 T1 ( x ) = x
2 T2 ( x ) = 2 x 2 − 1
3 T3 ( x ) = 4 x 3 − 3x
4 T4 ( x ) = 8x 4 − 8x 2 + 1
( n 2)
n(! x 2
− )
1
m
x m −2n
Tn ( x ) = ∑
m = 0 ( 2m ) !( n − 2m ) !