BIJU PATNAIK UNIVERSITY OF TECHNOLOGY,
ODISHA
Lecture Notes
On
Prepared by,
Dr. Subhendu Kumar Rath,
BPUT, Odisha.
DIFFERENCE EQUATION AND
ITS APPLICATION
DIFFERENCE EQUATION AND ITS APPLICATION
Dr.Subhendu Kumar Rath
DEFINITIONAn expression which expresses a relation between an independent variable and successive values or Successive differences of dependent variable is called a difference equation.
EXAMPLES
ORDER AND DEGREE
SOLUTION A solution of a difference equation is any
function that satisfies it. The general solution of a difference
equation of order n is a solution that contains n arbitrary constants or n arbitrary function which are periodic with period equal to the interval of differencing.
The particular solution of a difference equation is a solution obtained by assigning particular values to the arbitrary constants or functions.
CONTD…..
LINEAR DIFFERENCE EQATION
CONTD….
APPLICATION Difference equation can be applicable in
the following areas. Numerical methods to solve partial
differential equation. Fourier series Algebra and Analysis
First Derivative Approximations Backward difference: (uj – uj-1) / Δx
Forward difference: (uj+1 – uj) / Δx
Centered difference: (uj+1 – uj-1) / 2Δx
Taylor Expansion u(x + Δx) = u(x) + u΄(x)Δx + 1/2 u˝(x)(Δx)
+ 1/6 u˝΄(x)(Δx) + O(Δx)
u(x – Δx) = u(x) – u΄(x)Δx + 1/2 u˝(x)(Δx) - 1/6 u˝΄(x)(Δx) + O(Δx)
2
3
4
4
2
3
Taylor Expansionu΄(x) = u(x) – u(x – Δx) + O(Δx)
Δxu΄(x) = u(x + Δx) – u(x) + O(Δx)
Δxu΄(x) = u(x + Δx) – u(x – Δx) + O(Δx)
2Δx
2
Second Derivative Approximation Centered difference: (uj+1 – 2uj + uj-1) / (Δx)
Taylor Expansionu˝(x) = u(x + Δx) – 2u(x) + u(x – Δx) + O(Δx)
(Δx)
2
2
2
Function of Two Variables
u(jΔx, nΔt) ~ uj
Backward difference for t and x
(jΔx, nΔt) ~ (uj – uj ) / Δt
(jΔx, nΔt) ~ (uj – uj ) / Δx
n
n n-1
n-1
n
∂u∂t
∂u∂x
Function of Two Variables
Forward difference for t and x
(jΔx, nΔt) ~ (uj – uj ) / Δt
(jΔx, nΔt) ~ (uj – uj ) / Δx
n+1
n+1 n
n∂u∂t
∂u∂x
Function of Two Variables
Centered difference for t and x
(jΔx, nΔt) ~ (uj – uj ) / (2Δt)
(jΔx, nΔt) ~ (uj – uj ) / (2Δx)
n+1
n+1 n-1
n-1∂u∂t
∂u∂x
Partial Differential Equations
Partial Differential Equations (PDEs). What is a PDE? Examples of Important PDEs. Classification of PDEs.
Partial Differential Equations
s)t variableindependen are and example the(inst variableindependen moreor twoinvolves PDE
),(),(
:Example
2
2
tx
ttxu
xtxu
∂∂
=∂
∂
A partial differential equation (PDE) is an equation that involves an unknown function and its partial derivatives.
Notation
.derivativeorder highest theoforder PDE theofOrder
),(
),(
2
2
2
=∂∂
∂=
∂∂
=
txtxuu
xtxuu
xt
xx
Examples of PDEsPDEs are used to model many systems in many different fields of science and engineering.
Important Examples: Laplace Equation Heat Equation Wave Equation
Laplace Equation
Used to describe the steady state distribution of heat in a body.
Also used to describe the steady state distribution of electrical charge in a body.
0),,(),,(),,(2
2
2
2
2
2=
∂∂
+∂
∂+
∂∂
zzyxu
yzyxu
xzyxu
Heat Equation
∂∂
+∂∂
+∂∂
=∂
∂2
2
2
2
2
2 ),,,(
zu
yu
xu
ttzyxu α
The function u(x,y,z,t) is used to represent the temperature at time t in a physical body at a point with coordinates (x,y,z)
α is the thermal diffusivity. It is sufficient to consider the case α = 1.
Simpler Heat Equation
2
2 ),(),(x
txTt
txT∂
∂=
∂∂
T(x,t) is used to represent the temperature at time t at the point x of the thin rod.
x
Wave Equation
∂∂
+∂∂
+∂∂
=∂
∂2
2
2
2
2
22
2
2 ),,,(
zu
yu
xuc
ttzyxu
The function u(x,y,z,t) is used to represent the displacement at time t of a particle whose position at rest is (x,y,z) .
The constant c represents the propagation speed of the wave.
Classification of PDEsLinear Second order PDEs are important sets of equations that are used to model many systems in many different fields of science and engineering.
Classification is important because: Each category relates to specific engineering
problems. Different approaches are used to solve these
categories.
Linear Second Order PDEsClassification
Hyperbolic04
Parabolic04
Elliptic04
:follows as 4 on based classified is
and ,, ,, of functiona is D and of functions are C and B,A,
,0s)t variableindependen-(2 Elinear PDorder second A
2
2
2
2
>−
=−
<−
−
=+++
ACB
ACB
ACB
AC)(B
uuuyxyx
DuCuBuA
yx
yyxyxx
Linear Second Order PDEExamples (Classification)
0sin ,cos
sin ,sin
sin),( :solution possible One
EquationLaplace041,0,1
0),(),(EquationLaplace
2
2
2
2
2
=+
−==
==
=
⇒<−⇒===
=∂
∂+
∂∂
yyxx
xyy
xy
xxx
xx
x
uuyeuyeu
yeuyeu
yeyxu
EllipticisACBCBA
yyxu
xyxu
Linear Second Order PDEExamples (Classification)
HyperbolicisACBCBcA
ttxu
xtxuc
ParabolicisACBCBA
ttxu
xtxu
Equation Wave041 ,0 ,0
0),(),(Equation Wave
______________________________________EquationHeat
040 ,0 ,
0),(),(EquationHeat
22
2
2
2
22
2
2
2
⇒>−⇒−==>=
=∂
∂−
∂∂
⇒=−⇒===
=∂
∂−
∂∂
α
α
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.
)sin()0,(0),1(0),0(
0),(),(:EquationHeat 2
2
xxututu
ttxu
xtxu
π
α
===
=∂
∂−
∂∂
region of interest
x1
t
The Solution Methods for PDEs Analytic solutions are possible for simple
and special (idealized) cases only.
To make use of the nature of the equations, different methods are used to solve different classes of PDEs.
The methods discussed here are based on the finite difference technique.
Parabolic Equations Parabolic Equations Heat Conduction Equation Explicit Method Implicit Method Cranks Nicolson Method
Parabolic Equations
04 if parabolic is
and ,, y,x, of functiona is D yandx of functions are C and B,A,
,0) , st variableindependen-(2 linear PDEorder second A
2 =−
=+++
ACB
uuu
DuCuBuAyx
yx
yyxyxx
Parabolic Problems
solution.a specify uniquely toneeded are conditionsBoundary *)04( problem lic Parabo*
)sin()0,(0),1(),0(
),(),(:EquationHeat
2
2
2
=−
===
∂∂
=∂
∂
ACB
xxTtTtT
xtxT
ttxT
π
xice ice
Finite Difference Methods
t
x
Divide the interval x into sub-intervals, each of width h
Divide the interval t into sub-intervals, each of width k
A grid of points is used forthe finite difference solution
Ti,j represents T(xi, tj) Replace the derivates by
finite-difference formulas
Finite Difference Methods
kTT
tTT
ttxT
tT
hTTT
xTTT
xtxT
xT
jijijiji
jijijijijiji
,1,,1,
2,1,,1
2,1,,1
2
2
2
2
),(
:for Formula DifferenceForward
2
)(2),(
:for Formula DifferenceCentral
formulas difference finiteby sderivative theReplace
−=
∆−
≈∂
∂∂∂
+−=
∆
+−≈
∂∂
∂∂
++
+−+−
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
( )
),(),()21(),(),(
),(),(2),(),(),(
),(),(2),(),(),(
),(),(
2
2
2
2
2
thxTtxTthxTktxThkDefine
thxTtxTthxThktxTktxT
hthxTtxTthxT
ktxTktxT
xtxT
ttxT
++−+−=+
=
++−−=−+
++−−=
−+∂
∂=
∂∂
λλλ
λ
Explicit MethodHow Do We Compute?
meansthxTtxTthxTktxT ),(),()21(),(),( ++−+−=+ λλλ
T(x-h,t) T(x,t) T(x+h,t)
T(x,t+k)
Convergence and Stability
( )
.slowit makes This ansmaller th much is that means This
2
210)21( stability, guarantee To
magnified are errors unstable be Can
),(),()21(),(),(:usingdirectly computed be can),(
2
hk
hk
thxTtxTthxTktxTktxT
≤⇒≤⇒≥−
++−+−=++
λλ
λλλ
Example 1
( ) ( )
),(4),(7),(4),(
0),(),(4),(),(2),(16
0),(),(),(),(2),(
0),(),(
2
2
2
thxutxuthxuktxu
txuktxuthxutxuthxuk
txuktxuh
thxutxuthxut
txux
txu
++−−=+
=−+−++−−
=−+
−++−−
=∂
∂−
∂∂
Example 1),(4),(7),(4),( thxutxuthxuktxu ++−−=+
t=0
t=0.2
t=0.5t=0.7t=1.0
x=0.25
x=0.5
x=0.0
x=0.75
x=1.0
000
00
000
00
Sin(0.25π)
Sin(0. 5π)
Sin(0.75π)
Example 19497.0)2/sin(4)4/sin(70)0,5.0(4)0,25.0(7)0,0(4)25.0,25.0(
−=+−=+−=ππ
uuuu
t=0
t=0.2
t=0.5t=0.7t=1.0
x=0.25
x=0.5
x=0.0
x=0.75
x=1.0
000
00
000
00
Sin(0.25π)
Sin(0. 5π)
Sin(0.75π)
Crank-Nicolson Method
Method). Explicit the to(compared ,larger use can Weerror). of ionmagnificat (No stable is method The
equations.linear of system lTridiagonaa solving involves method The
kh→
Crank-Nicolson Method
22
2 ),(),(2),(),(
),(),(),(:lyrespective formulas and
their withsderivative partial second andfirst the Replace3. widthof lssubinterva into interval the Divide2. widthof lssubinterva into interval the Divide1.
method difference finite theon Based
hthxutxuthxu
xtxu
kktxutxu
ttxu
fferencecentral dibackward
kthx
++−−=
∂∂
−−≈
∂∂
Crank-Nicolson Method
( )
),(),(),( )21(),(
),(),(),(),(2),(
),(),(),(),(2),(
becomes ),(),( :ionHeat Equat
222
2
2
2
2
ktxuthxuhktxu
hkthxu
hk
ktxutxuthxutxuthxuhk
kktxutxu
hthxutxuthxu
ttxu
xtxu
−=+−++−−
−−=++−−
−−=
++−−
∂∂
=∂
∂
Crank-Nicolson Method
),(),(),()21(),(
:becomes equation Heat then Define 2
ktxuthxutxuthxuhk
−=+−++−−
=
λλλ
λ
u(x-h,t) u(x,t) u(x+h,t)
u(x,t - k)
Crank-Nicolson Method
0,41,51,41,3
0,31,41,31,2
0,21,31,21,1
0,11,21,11,0
1,,1,,1
)21( )21( )21( )21(
:)1(fix equations of systema as expanded be can and)21( :as rewritten be can
),(),(),()21(),( :equation The
uuuuuuuuuuuuuuuu
juuuu
ktxuthxutxuthxu
jijijiji
=−++−
=−++−
=−++−
=−++−=
=−++−
−=+−++−−
−+−
λλλ
λλλ
λλλ
λλλ
λλλ
λλλ
Crank-Nicolson Method
hxxxuuhxhxhxhxx
uuuu
uuuu
uu
uuuu
ktxuthxutxuthxu
5 and at aluesboundary v theare and 4 and ,3 ,2 ,at
valuesre temperatuinitial theare and , , , where
2121
2121
:equations of system lTridiagonaa as expressed be can),(),(),()21(),(
001,51,0
0000
0,40,30,20,1
1,50,4
0,3
0,2
1,00,1
1,4
1,3
1,2
1,1
+=++++=
+
+
=
+−−+−
−+−−+
−=+−++−−
λ
λ
λλλλλ
λλλλλ
λλλ
Crank-Nicolson Method
etc. ,3at valuesre temperatucompute tostep above Repeat the and , , , compute To
2121
2121
)2( equations of system al tridiagonseconda Solve2at valuesre temperatu thecompute Toat and , , , valuesre temperatuThe
:produces system al tridiagon theof solution The
0
2,42,32,22,1
2,51,4
1,3
1,2
2,01,1
2,4
2,3
2,2
2,1
0
01,41,31,21,1
ktuuuu
uuuu
uu
uuuu
jktt
kttuuuu
+
+
+
=
+−−+−
−+−−+
=+=
+=
λ
λ
λλλλλ
λλλλλ
Example 2
]1,0[],1,0[for ),( find to25.0,25.0method Nicolson-Crank using Solve
)sin()0,(0),1(),0(
0),(),(
: PDE theSolve
2
2
∈∈==
===
=∂
∂−
∂∂
txtxukhUse
xxututu
ttxu
xtxu
π
Example 2Crank-Nicolson Method
( ) ( )
1,,1,,1
2
2
2
2
4 9 4),(),( 4),( 9),( 4
4
0),(),(4),(),(2),(16
),(),(),(),(2),(
0),(),(
−+− =−+−−=+−+−−
==
=−−−++−−
−−=
++−−
=∂
∂−
∂∂
jijijiji uuuuktxuthxutxuthxu
hkDefine
ktxutxuthxutxuthxuk
ktxutxuh
thxutxuthxut
txux
txu
λ
Example 2
)4/3sin(94 494)2/sin(494494)4/sin( 49 494
1,31,20,31,41,31,2
1,31,21,10,21,31,21,1
1,21,10,11,21,11,0
π
π
π
=+−⇒=−+−
=−+−⇒=−+−
=−⇒=−+−
uuuuuuuuuuuuu
uuuuuu
Example 2Solution of Row 1 at t1=0.25 sec
=
⇒
=
−−−
−
=
21151.029912.021151.0
)75.0sin()5.0sin()25.0sin(
94494
49
:equations of system al tridiagonfollowing theofsolution theis sec 25.0at PDE theof Solution The
1,3
1,2
1,1
1,3
1,2
1,1
1
uuu
uuu
t
πππ
Example 2: Second Row at t2=0.5 sec
21151.094 49429912.049449421151.0 49 494
2,32,21,32,42,32,2
2,32,22,11,22,32,22,1
2,22,11,12,22,12,0
=+−⇒=−+−
=−+−⇒=−+−
=−⇒=−+−
uuuuuuuuuuuuu
uuuuuu
Example 2Solution of Row 2 at t2=0.5 sec
=
⇒
=
=
−−−
−
=
063267.0089473.0063267.0
21151.029912.021151.0
94494
49
:equations of system al tridiagonfollowing theofsolution theis sec 5.0at PDE theof Solution The
2,3
2,2
2,1
1,3
1,2
1,1
2,3
2,2
2,1
2
uuu
uuu
uuu
t
Example 2Solution of Row 3 at t3=0.75 sec
=
⇒
=
=
−−−
−
=
018924.0026763.0018924.0
063267.0089473.0063267.0
94494
49
:equations of system al tridiagonfollowing theofsolution theis sec 75.0at PDE theof Solution The
3,3
3,2
3,1
2,3
2,2
2,1
3,3
3,2
3,1
3
uuu
uuu
uuu
t
Example 2Solution of Row 4 at t4=1 sec
=
⇒
=
=
−−−
−
=
0056606.00080053.00056606.0
018924.0026763.0018924.0
94494
49
:equations of system al tridiagonfollowing theofsolution theis sec 1at PDE theof Solution The
4,3
4,2
4,1
3,3
3,2
3,1
4,3
4,2
4,1
4
uuu
uuu
uuu
t
THANK YOU