0% found this document useful (0 votes)
51 views17 pages

Lecture Accuracy Stability

The document compares the accuracy and stability of forward and backward numerical schemes for solving differential equations. While both schemes are first-order accurate, meaning the error decreases proportionally with the time step, only the backward scheme is unconditionally stable. The forward scheme is conditionally stable and will become unstable if the time step exceeds a certain threshold. For the heat equation, the backward Euler scheme is unconditionally stable, while the forward Euler scheme has a stability limit on the size of the time step due to its conditional stability.

Uploaded by

Betou Ouedraogo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
51 views17 pages

Lecture Accuracy Stability

The document compares the accuracy and stability of forward and backward numerical schemes for solving differential equations. While both schemes are first-order accurate, meaning the error decreases proportionally with the time step, only the backward scheme is unconditionally stable. The forward scheme is conditionally stable and will become unstable if the time step exceeds a certain threshold. For the heat equation, the backward Euler scheme is unconditionally stable, while the forward Euler scheme has a stability limit on the size of the time step due to its conditional stability.

Uploaded by

Betou Ouedraogo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

Accuracy and stability of numerical schemes

Introduction to Numerical Methods for Engineering - MATH711

Monika Woloszyn, Mathilde Wirtz,


Christian Ruyer-Quil, Nirina Marx Chhay

MASTER 1 ESB - Polytech Annecy Chambéry 2020, semester 7

1 / 17
Lecture 2

Recall from Lecture 1


Thanks to Taylor expansion formula :

∆x 2 00 ∆x k (k )
f (x + ∆x) = f (x) + ∆xf 0 (x) + f (x) + . . . + f (x) + O(∆x k +1 )
2! k!

we know how to discretize differential operators occuring into a mathematical


∂u ∂2 u
model (for example − α 2 = 0) for getting a numerical model.
∂t ∂x
However :
I There are many ways to compute an approximation. For example, the
fluxes can be approximated as
∂u uj+1 − uj ∂u uj+1 − uj−1
(xj ) ' or (xj ) '
∂x dx ∂x 2 dx
What is the difference between each approximation ?
I Thus, different apprxoimations yield different numerical schemes.
How can we compare the different numerical schemes one against an
other ?
2 / 17
Lecture 2

An illustrative example : y 0 = −λy

Let’s consider the simplest (non-trivial) differential equation :

y 0 (t) = −λ y(t) with λ > 0

I Set an initial value y(t 0 = 0) = y 0


I Exact solution yex (t) = y 0 e −λt
For example : if y0 = 1, λ = 50 and we compute the exact solution every
instant t n = t 0 + n × dt with dt = 10−2 :

t0 = 0 t 1 = 0.01 t 2 = 0.02 t 3 = 0.03 t 4 = 0.04


yex (t 0 ) = 1 yex (t 1 ) = 0.61 yex (t 2 ) = 0.37 yex (t 3 ) = 0.22 yex (t 4 ) = 0.14

Let’s compute 2 numerical schemes for y 0 = −λy and compare their


numerical solution

3 / 17
Lecture 2

Forward numerical scheme for y 0 = −λy

Thanks to the Taylor expansion formula :

y(t n + dt) − y(t n )


y 0 (t n ) = + O(dt 1 )
dt
Note by y n the approximation of y(t n ).
y n+1 − y n
Thus, a forward approximation of the derivative is : y 0 (t n ) '
dt
I this approximation is of order 1
I the resulting numerical scheme reads :

Forward Euler scheme : yfen+1 = (1 − λdt) yfen ∀n > 0

time 0 0.01 0.02 0.03 0.04


yex 1 0.61 0.37 0.22 0.14
yfe 1 0.5 0.25 0.13 0.07

4 / 17
Lecture 2

Backward numerical scheme for y 0 = −λy


Thanks to the Taylor expansion formula :
y(t n ) − y(t n − dt)
y 0 (t n ) = + O(dt 1 )
dt
Still noting by y n the approximation of y(t n ), we get a backward approximation
y n − y n−1
of the derivative : y 0 (t n ) ' , for n > 1.
dt
I this approximation is of order 1
−1 n−1
I the resulting numerical scheme reads :y n = (1 + λdt) y , for n > 1,
or equivalently :

Backward Euler scheme : n+1


ybe = (1 + λdt)−1 ybe
n
∀n > 0

time 0 0.01 0.02 0.03 0.04


yex 1 0.61 0.37 0.22 0.14
yfe 1 0.5 0.25 0.13 0.07
ybe 1 0.66 0.44 0.3 0.2

5 / 17
Lecture 2

Accuracy

Which of the 2 numerical scheme is the mode accurate ?


I From the table of numerical values, the discrepancy of each numerical
scheme with the exact solution is of same order of magnitude :

|yex − yfe | = O(dt 1 ) and |yex − ybe | = O(dt 1 )

I The error with the exact solution is given exactly by the remaining terms
in the Taylor expansion : these terms where neglected for the
approximation of the differential operator.
I The order of accuracy of a numerical scheme is given by the order of
truncation of the Taylor expansion.
I Both the Forward and Backward Euler schemes are accurate to the 1rst
order.
Does it mean that the 2 schemes behave the same ? NO !

6 / 17
Lecture 2

Stability of the Forward Euler scheme


As the time step decreases dt → 0 :
I The error diminishes too : quite normal because the error is function of dt.

As time step increases :


time ×10−2 0 1 2 3 4 5 6 7 8
dt = 10−2 1 0.5 0.25 0.13 0.07 0.03 0.02 0.01 0.01
dt = 2 × 10−2 1 0 0 0 0
dt = 4 × 10−2 1 -1 1
u

ujn for dt < 0.01

ujn for dt = 0.02 xj

ujn for dt = 0.04

I Above a threshold value for dt, the numerical solution blows up !


7 / 17
Lecture 2

Stability of the Backward Euler scheme


As the time step decreases dt → 0 :
I The error diminishes too : quite normal because the error is function of dt.

As time step increases :


time ×10−2 0 1 2 3 4 5 6 7 8
dt = ×10−2 1 0.66 0.44 0.3 0.2 0.13 0.09 0.06 0.04
dt = 2 × 10−2 1 0.5 0.25 0.13 0.07
dt = 4 × 10−2 1 0.33 0.11
u

ujn for dt = 0.04


ujn for dt = 0.02

ujn for dt < 0.01 xj

I There is no threshold value above which the numerical solution blows up.
8 / 17
Lecture 2

A posteriori analysis

With an information on the qualitative behaviour of the exact solution, we can


compute the threshold time step for which the numerical solution blows up :
I Starting with a positive initial condition y 0 > 0, all the other terms must
stay positive : y n > 0.
I That is to say : for any n, if y n > 0, then y n+1 > 0
I But for the Forward Euler scheme, y n+1 = (1 − λdt) y n .
Thus y n+1 > 0 only if dt < λ−1
I For the Backward Euler scheme, as y n+1 = (1 + λdt)−1 y n , one has y n+1
always positive, whatever the value for the time step dt.
This result can be generalized :
I Forward schemes cannot support a time step dt too big, otherwise their
numerical solution blows up : they have a stability condition.
I Backward schemes have no limitation on the time step : they are
unconditionnaly stable

9 / 17
Lecture 2

Back to the heat equation

Consider the unsteady heat equation in one spatial dimension :

∂u ∂2 u
=α 2 for x ∈]a; b[, and t > 0
∂t ∂x
With an initial condition : u(x, t 0 ) = U 0 (x), and fixed (Dirichlet) boundary
conditions : u(x0 , t n ) = Ua , and u(xNx , t n ) = Ub .
Notation, as usual :
I Time discretization : t n = t 0 + ndt
I Space discretization : xj = x0 + jdx
I Numerical approximation of the temperature : ujn ' u(xj , t n ).
Thus ujn+1 ' u(xj , t n + dt) and uj±1
n
' u(xj ± dx, t n ).

10 / 17
Lecture 2

Forward Euler scheme for the Heat equation

The Forward Euler scheme reads :


I Initial condition : uj0 = U 0 (xj ), for j = 0, . . . , Nx
I Boudary conditions :
I at left : u0n = Ua
I at right : uNn x = Ub
I For all interior nodes, j = 1, . . . , Nx − 1, we assume to know all un , and we
need to compute the values un+1 :

αdt n
ujn+1 = ujn + u − 2ujn + uj−1
n

dx 2 j+1

11 / 17
Lecture 2

Accuracy, Stability of the Forward Euler scheme

I Thanks to Taylor expansion, the Forward Euler scheme is computed by


approximating the differential operators as :

∂u ujn+1 − ujn ∂2 u
n
uj+1 − 2ujn + uj−1
n
(xj , t n ) ' and (xj , t n
) '
∂t dt ∂x 2 dx 2
The truncated terms are of order O(dt + dx 2 ) :
The Forward Euler scheme is accurate of order 1 in time and 2 in space
I Injecting a particular solution (monochromatic wave) : ujn = ρn e iβx , and
knowing that the heat equation is energy-dissipating : |un+1 | 6 |un |, we
get after some computation :
dx 2
The stability condition for the Forward Euler scheme : dt 6
α2

12 / 17
Lecture 2

Solving the Forward Euler scheme


One of the great advantage with the Forward Euler scheme is its low
computational cost :
I Starting from the initial condition uj0 = U 0 (xj ), for j = 0, . . . , Nx ,
I Use the numerical scheme for each node to compute the approximation
of the temperature u1 at time t 1 = t 0 + dt :

αdt 0
uj1 = uj0 + uj+1 − 2uj0 + uj−1
0

2
for j = 1, . . . , Nx − 1
dx
The Forward Euler scheme is said to be explicit because the unknown
un+1 has an explicite formulation involving known terms un . The
computational cost is low !
I The boundary conditions are then solved : in case of Dirichlet boundary
conditions, one has straightforwardly u00 = Ua and uN1 x = Ub
I At this stage, the full numerical solution has been computed for the time
layer t 1 : we have to apply the same process in order to compute the next
time layer t 2 , and so on...

13 / 17
Lecture 2

Backward Euler scheme for the Heat equation

The Backward Euler scheme reads :


I Initial condition : uj0 = U 0 (xj ), for j = 0, . . . , Nx
I Boudary conditions :
I at left : u0n = Ua
I at right : uNn x = Ub
I For all interior nodes, j = 1, . . . , Nx − 1, we assume to know all un , and we
need to compute the values un+1 :
 
αdt αdt  n+1 
1 + 2 2 ujn+1 − 2
n+1
uj+1 + uj−1 = ujn
dx dx

It is obtained by considering the approximations :

∂u ujn − ujn−1 ∂2 u
n
uj+1 − 2ujn + uj−1
n
(xj , t n ) ' and (xj , t n
) '
∂t dt ∂x 2 dx 2
and shifting the time labels n := n + 1 in order to start with n > 0

14 / 17
Lecture 2

Accuracy, Stability of the Backward Euler scheme

I The truncated terms in the approximations

∂u ujn − ujn−1 ∂2 u
n
uj+1 − 2ujn + uj−1
n
(xj , t n ) ' and (xj , t n
) '
∂t dt ∂x 2 dx 2
are of order O(dt + dx 2 ) : The Backward Euler scheme is accurate of
order 1 in time and 2 in space, as the Forward Euler scheme.
I Injecting a particular solution (monochromatic wave) : ujn = ρn e iβx , and
knowing that the heat equation is energy-dissipating : |un+1 | 6 |un |, we
get after some computation :
The Backward Euler scheme has no stability condition : dt may be as big
as wanted, the solution will not blow up !

15 / 17
Lecture 2

Solving the Backward Euler scheme


One of the great disdvantage with the Backward Euler scheme is its low
computational cost :
I Starting from the initial condition u0 = U 0 (xj ), for j = 0, . . . , Nx ,
j
I The numerical scheme indicates that each unkown ujn+1 cannot be
n+1
computed separatly from its neighbourgh uj±1 . One has to consider the
whole time layer.
The numerical scheme can be recast into a matrix form :

MUn+1 = Un

The Backward Euler scheme is said to be implicit because the unknown


U n+1 has to be computed by inverting the matrix M : U n+1 = M−1 Un . The
computational cost is high !
I The boundary conditions are solved at the same time as all interior
nodes.
I At this stage, the full numerical solution has been computed for the time
layer t 1 : we have to apply the same process in order to compute the next
time layer t 2 , and so on...
16 / 17
Lecture 2

Summarize

For the heat equation :


I Forward Euler (explicit) scheme :
I Easy to construct, fast in computation
I but it is conditionally stable : the time step cannot be too big, otherwise the
numerical solution blows up !
dx 2
Stability condition : dt 6
α2
I Backward Euler (implicit) scheme :
I unconditionally stable : dt independent of dx
I need a matrix inversion (computational cost)
I these two schemes are as accurate one as the other : O(dt + dx 2 )

17 / 17

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy