Professional Documents
Culture Documents
Numerical Methods: Marisa Villano, Tom Fagan, Dave Fairburn, Chris Savino, David Goldberg, Daniel Rave
Numerical Methods: Marisa Villano, Tom Fagan, Dave Fairburn, Chris Savino, David Goldberg, Daniel Rave
Marisa Villano
Finite Differences
Approximating the derivative with a
difference quotient from the Taylor series
2
u(x – Δx) = u(x) – u΄(x)Δx + 1/2 u˝(x)(Δx)
3 4
- 1/6 u˝΄(x)(Δx) + O(Δx)
Taylor Expansion
u΄(x) = u(x) – u(x – Δx) + O(Δx)
Δx
u΄(x) = u(x + Δx) – u(x) + O(Δx)
Δx
2
u΄(x) = u(x + Δx) – u(x – Δx) + O(Δx)
2Δx
Second Derivative Approximation
2
Centered difference: (uj+1 – 2uj + uj-1) / (Δx)
Taylor Expansion
2
u˝(x) = u(x + Δx) – 2u(x) + u(x – Δx) + O(Δx)
2
(Δx)
Function of Two Variables
n
u(jΔx, nΔt) ~ uj
Backward difference for t and x
∂u n n-1
(jΔx, nΔt) ~ (uj – u ) / Δt
j
∂t
∂u n n-1
(jΔx, nΔt) ~ (uj – u ) / Δx
j
∂x
Function of Two Variables
∂u n+1
(jΔx, nΔt) ~ (u j
n
– uj ) / Δt
∂t
∂u n+1
(jΔx, nΔt) ~ (u j
n
– uj ) / Δx
∂x
Function of Two Variables
∂u n+1
(jΔx, nΔt) ~ (u j
n-1
– u ) / (2Δt)
j
∂t
∂u n+1
(jΔx, nΔt) ~ (u j
n-1
– u ) / (2Δx)
j
∂x
Error
Truncation Error: introduced in the solution by the
approximation of the derivative
Local Error: from each term of the equation
Global Error: from the accumulation of local
error
Dave Fairburn
Example from 8.1
Consider ut = uxx u(x,0) = h(x)
We will use the finite difference method to
approximate the solution
Forward difference for ut
j values
Analysis of Solution
Is this solution viable?
Maximum principle states that the solution must
be between 0 and 1 given our initial data
At n = 4, our solution has already ballooned to u
= 19!
Clearly, there are cases when the finite
difference method can pose serious problems.
Charting the Error
Assume the solution is constant and equal to 0.5 (halfway between
the possible 0 and 1)
Lessons Learned
While the finite difference method is easy
and convenient to use in many cases,
there are some dangers associated with
the method.
We will investigate why the assumption
that allowed us to simplify the scheme
could have been a major contributor to
the large error.
Approximations of Diffusions
Chris Savino
Approximations of Diffusions
Errors have accumulated from the
approximations of the derivatives using the
previous scheme
The problem is the choice of the mesh Δt
to the mesh Δx
t
Let s= (x)2
ux (0, t ) g (t ) ux (l , t ) h(t )
u1n u 0 n uj n uj 1n
gn hn
x x
To get smallest error, we use centered
differences for the derivatives on the boundary
Introduce ghost points
u 1
n uj 1n
Boundary Conditions become
n n
u u
1 1 n uj 1n uj 1n
g hn
2x 2x
Crank-Nicolson Scheme
Can avoid any restrictions on stability
conditions
Unconditionally stable no matter what the
value of s is.
Centered Second Difference:
uj 1n 2uj n uj 1n 2 n
2
( u )j
( x )
Pick a number theta between 0 and 1
Theta scheme:
uj n 1 uj n
(1 )( u 2 ) j n ( u 2 ) j n 1
t
We analyze the scheme by plugging in a
separated solution
uj n (eik x ) j ( (k )) n
Therefore
Therefore
1 2 0
is always true
1
1
If 2 then there is no restriction on the size
of s for stability to hold
The scheme is unconditionally stable
When theta = ½ it is called the Crank-Nicolson
scheme
If theta < ½ then the scheme is stable if
t 1
2
s
( x ) 2 4
Stability Criterion
David Goldberg
Stability Criterion
The method of finite differences gives an
answer, but it does not guarantee that this
answer is meaningful.
Values must be chosen appropriately, to
ensure that the results make sense and
are applicable to real world scenarios.
This condition, that values must satisfy in
order to be worthwhile, is called the
“stability criterion.”
Example
As per the book, take, for instance, the
diffusion problem:
𝑢𝑡 = 𝑢𝑥𝑥 for 0<x<π, t>0
𝑢=0 at x=0, π, that is
𝑢ሺ0, 𝑡ሻ = 𝑢ሺ𝜋, 𝑡ሻ = 0
𝜋
𝑥 in ቀ0, ቁ
2
𝑢ሺ𝑥, 0ሻ = 𝜙ሺ𝑥 ሻ = ቐ
𝜋 − 𝑥 in ቀ𝜋 , 𝜋ቁ
2
Example, continued
As can be easily shown, the graph of φ(x)
looks like this.
Example, continued
In attempting to use the method of finite
differences, we are using a forward difference
for ut and a centered difference for uxx.
This means that
u nj 1 s u nj 1 2u nj u nj 1 u nj
u nj 1 s u nj 1 2s u nj u nj s u nj 1
It would be nice if we could justn plugn in values and
get a valid result… u n 1
j s u j 1 u j 1 1 2 s u j
n
Example, continued
However, putting in different values can lead to the
results being close to, or far from, that actual answer.
For instance, letting ∆x=π/20, and letting s=5/11, we get
a relatively nice result. Letting s=5/9 does not get such a
nice result.
Daniel Rave
Summary
Breif Review of Methods
Wide Applicability
Importance of Stability