Lecture Note 580507181057380
Lecture Note 580507181057380
Lecture Note 580507181057380
ODISHA
Lecture Notes
On
DIFFERENCE EQUATION
AND
ITS APPLICATION
Prepared by,
Dr. Subhendu Kumar Rath,
BPUT, Odisha.
DIFFERENCE EQUATION AND
ITS APPLICATION
2Δx
Second Derivative Approximation
Centered difference: (uj+1 – 2uj + uj-1) / (Δx)
2
Taylor Expansion
2
u˝(x) = u(x + Δx) – 2u(x) + u(x – Δx) + O(Δx)
(Δx)
2
Function of Two Variables
u(jΔx, nΔt) ~ uj
n
Example :
∂ 2 u( x, t ) ∂ u( x, t )
=
∂x 2
∂t
PDE involves two or more independent variables
(in the example x and t are independent variables)
Notation
∂ 2 u ( x, t )
u xx =
∂x 2
∂ 2 u ( x, t )
u xt =
∂x ∂t
Order of the PDE = order of the highest order derivative.
Examples of PDEs
PDEs are used to model many systems in
many different fields of science and
engineering.
Important Examples:
Laplace Equation
Heat Equation
Wave Equation
Laplace Equation
∂ 2u ( x , y , z ) ∂ 2u ( x , y , z ) ∂ 2u ( x , y , z )
+ + =0
∂x 2
∂y 2
∂z 2
A = 1, B = 0, C = 1 ⇒ B 2 − 4 AC < 0
⇒ Laplace Equation is Elliptic
One possible solution : u( x, y ) = e x sin y
u x = e x sin y , u xx = e x sin y
u y = e x cos y , u yy = −e x sin y
u xx + u yy = 0
Linear Second Order PDE
Examples (Classification)
∂ 2u ( x , t ) ∂ u ( x , t )
Heat Equation α − =0
∂x 2
∂t
A = α , B = 0, C = 0 ⇒ B 2 − 4 AC = 0
⇒ Heat Equation is Parabolic
______________________________________
∂ 2
u ( x , t ) ∂ 2
u ( x, t )
Wave Equation c 2
− =0
∂x 2
∂t 2
A = c 2 > 0, B = 0, C = −1 ⇒ B 2 − 4 AC > 0
⇒ Wave Equation is Hyperbolic
Boundary Conditions for PDEs
To uniquely specify a solution to the PDE,
a set of boundary conditions are needed.
Both regular and irregular boundaries are
possible. 2 t
∂ u( x, t ) ∂u( x, t )
Heat Equation : α − =0
∂x 2
∂t region of
u(0, t ) = 0 interest
u(1, t ) = 0
u( x,0) = sin(π x ) 1 x
The Solution Methods for PDEs
Analytic solutions are possible for simple
and special (idealized) cases only.
is parabolic if B 2 − 4 AC = 0
Parabolic Problems
∂ T ( x, t ) ∂ 2 T ( x, t )
Heat Equation : =
∂t ∂x 2
T (0, t ) = T (1, t ) = 0
T ( x,0) = sin(π x ) ice ice
x
* Parabolic problem ( B 2 − 4 AC = 0)
* Boundary conditions are needed to uniquely specify a solution.
Finite Difference Methods
Divide the interval x into sub-intervals,
each of width h
Divide the interval t into sub-intervals,
each of width k t
A grid of points is used for
the finite difference solution
Ti,j represents T(xi, tj)
Replace the derivates by x
finite-difference formulas
Finite Difference Methods
Replace the derivatives by finite difference formulas
∂ 2T
Central Difference Formula for 2 :
∂x
∂ 2T ( x, t ) Ti −1, j − 2Ti , j + Ti +1, j Ti −1, j − 2Ti , j + Ti +1, j
≈ =
∂x 2
( ∆x ) 2
h2
∂T
Forward Difference Formula for :
∂t
∂T ( x, t ) Ti , j +1 − Ti , j Ti , j +1 − Ti , j
≈ =
∂t ∆t k
Solution of the Heat Equation
• Two solutions to the Parabolic Equation
(Heat Equation) will be presented:
1. Explicit Method:
Simple, Stability Problems.
2. Crank-Nicolson Method:
Involves the solution of a Tridiagonal
system of equations, Stable.
Explicit Method
∂T ( x, t ) ∂ 2T ( x, t )
=
∂t ∂x 2
T ( x, t + k ) − T ( x, t ) T ( x − h, t ) − 2T ( x, t ) + T ( x + h, t )
=
k h2
T ( x, t + k ) − T ( x, t ) = 2 (T ( x − h, t ) − 2T ( x, t ) + T ( x + h, t ) )
k
h
k
Define λ = 2
h
T ( x, t + k ) = λ T ( x − h, t ) + (1 − 2 λ ) T ( x, t ) + λ T ( x + h, t )
Explicit Method
How Do We Compute?
T ( x, t + k ) = λ T ( x − h, t ) + (1 − 2 λ ) T ( x, t ) + λ T ( x + h, t )
means
T(x,t+k)
T(x-h,t) T(x,t)
T(x+h,t)
Convergence and Stability
T ( x, t + k ) can be computed directly using :
T ( x, t + k ) = λ T ( x − h, t ) + (1 − 2 λ ) T ( x, t ) + λ T ( x + h, t )
u ( x , t + k ) = 4 u ( x − h, t ) − 7 u ( x , t ) + 4 u ( x + h, t )
Example 1
u ( x , t + k ) = 4 u ( x − h, t ) − 7 u ( x , t ) + 4 u ( x + h, t )
t=1.0 0 0
t=0.7 0 0
t=0.5 0 0
t=0.2 0 0
t=0 0 0
Sin(0.2 Sin(0. Sin(0.75
5π) 5π) π)
x=0. x=0. x=0. x=0. x=1.
0 25 5 75 0
Example 1
u(0.25,0.25) = 4 u(0,0) − 7 u(0.25,0) + 4 u(0.5,0)
= 0 − 7 sin(π / 4) + 4 sin(π / 2) = −0.9497
t=1.0 0 0
t=0.7 0 0
t=0.5 0 0
t=0.2 0 0
t=0 0 0
Sin(0.2 Sin(0. Sin(0.75
5π) 5π) π)
x=0. x=0. x=0. x=0. x=1.
0 25 5 75 0
Crank-Nicolson Method
The method involves solving a Tridiagonal system of linear equations.
The method is stable (No magnification of error).
→ We can use larger h, k (compared to the Explicit Method).
Crank-Nicolson Method
Based on the finite difference method
1. Divide the interval x into subintervals of width h
2. Divide the interval t into subintervals of width k
3. Replace the first and second partial derivatives with their
backward and central difference formulas respectively :
∂u( x, t ) u( x, t ) − u( x, t − k )
≈
∂t k
∂ 2 u ( x , t ) u ( x − h , t ) − 2u ( x , t ) + u ( x + h , t )
=
∂x 2
h2
Crank-Nicolson Method
∂ 2 u ( x, t ) ∂ u ( x, t )
Heat Equation : = becomes
∂x 2
∂t
u ( x − h , t ) − 2u ( x , t ) + u ( x + h , t ) u ( x , t ) − u ( x , t − k )
2
=
h k
k
2
(u( x − h, t ) − 2u( x, t ) + u( x + h, t ) ) = u( x, t ) − u( x, t − k )
h
k k k
− 2 u( x − h, t ) + (1 + 2 2 ) u( x, t ) − 2 u( x + h, t ) = u( x, t − k )
h h h
Crank-Nicolson Method
k
Define λ = 2 then Heat equation becomes :
h
− λ u( x − h, t ) + (1 + 2λ ) u( x, t ) − λ u( x + h, t ) = u( x, t − k )
u(x-h,t) u(x,t)
u(x+h,t)
u(x,t - k)
Crank-Nicolson Method
The equation :
− λ u( x − h, t ) + (1 + 2λ ) u( x, t ) − λ u( x + h, t ) = u( x, t − k )
can be rewritten as :
− λ ui −1, j + (1 + 2λ ) ui , j − λ ui +1, j = ui , j −1
and can be expanded as a system of equations (fix j = 1) :
− λ u0,1 + (1 + 2λ ) u1,1 − λ u2,1 = u1,0
− λ u1,1 + (1 + 2λ ) u2,1 − λ u3,1 = u2,0
− λ u2,1 + (1 + 2λ ) u3,1 − λ u4,1 = u3,0
− λ u3,1 + (1 + 2λ ) u4,1 − λ u5,1 = u4,0
Crank-Nicolson Method
− λ u( x − h, t ) + (1 + 2λ ) u( x, t ) − λ u( x + h, t ) = u( x, t − k )
can be expressed as a Tridiagonal system of equations :
1 + 2λ −λ u1,1 u1,0 + λ u0,1
− λ 1 + 2λ −λ u u
2,1 = 2,0
− λ 1 + 2λ − λ u3,1 u3,0
u u + λ u
− λ 1 + 2λ 4,1 4,0 5,1
where u1,0 , u2,0 , u3,0 , and u4,0 are the initial temperature values
at x = x0 + h, x0 + 2h, x0 + 3h, and x0 + 4h
u0,1 and u5,1 are the boundary values at x = x0 and x0 + 5h
Crank-Nicolson Method
The solution of the tridiagonal system produces :
The temperature values u1,1, u2,1, u3,1, and u4,1 at t = t0 + k
To compute the temperature values at t = t0 + 2k
Solve a second tridiagonal system of equations ( j = 2)
1 + 2λ −λ u1,2 u1,1 + λ u0,2
− λ 1 + 2λ u
−λ 2, 2 =
u
2,1
− λ 1 + 2λ −λ u3,2 u3,1
− λ 1 + 2 λ u
4,2 4,1u + λ u5, 2