numerical methods for differential equations course...
TRANSCRIPT
![Page 1: Numerical Methods for Differential Equations Course ...ctr.maths.lu.se/na/courses/FMNN10/course_media/material/Chapter… · Numerical Methods for Di erential Equations Course objectives](https://reader034.vdocument.in/reader034/viewer/2022042211/5eb444646b93aa0b997d452a/html5/thumbnails/1.jpg)
Numerical Methods for Differential EquationsCourse objectives and preliminaries
Gustaf SoderlindNumerical Analysis, Lund University
![Page 2: Numerical Methods for Differential Equations Course ...ctr.maths.lu.se/na/courses/FMNN10/course_media/material/Chapter… · Numerical Methods for Di erential Equations Course objectives](https://reader034.vdocument.in/reader034/viewer/2022042211/5eb444646b93aa0b997d452a/html5/thumbnails/2.jpg)
Contents V4.16
1. Course structure and objectives
2. What is Numerical Analysis?
3. The four principles of Numerical Analysis
2 / 31
![Page 3: Numerical Methods for Differential Equations Course ...ctr.maths.lu.se/na/courses/FMNN10/course_media/material/Chapter… · Numerical Methods for Di erential Equations Course objectives](https://reader034.vdocument.in/reader034/viewer/2022042211/5eb444646b93aa0b997d452a/html5/thumbnails/3.jpg)
1. Course structure and objectives Learning by doing
Main objectives
• Learn basic scientific computing for solving differentialequations
• Understand mathematics–numerics interaction, and how tomatch numerical method to mathematical properties
• Understand correspondence between principles in physics andmathematical equations
• Construct and use elementary Matlab programs fordifferential equations
3 / 31
![Page 4: Numerical Methods for Differential Equations Course ...ctr.maths.lu.se/na/courses/FMNN10/course_media/material/Chapter… · Numerical Methods for Di erential Equations Course objectives](https://reader034.vdocument.in/reader034/viewer/2022042211/5eb444646b93aa0b997d452a/html5/thumbnails/4.jpg)
A motto
The computer is to mathematics what the telescopeis to astronomy, and the microscope is to biology
– Peter D Lax
4 / 31
![Page 5: Numerical Methods for Differential Equations Course ...ctr.maths.lu.se/na/courses/FMNN10/course_media/material/Chapter… · Numerical Methods for Di erential Equations Course objectives](https://reader034.vdocument.in/reader034/viewer/2022042211/5eb444646b93aa0b997d452a/html5/thumbnails/5.jpg)
The operators we will deal with
Initial value problems
d
dt
5 / 31
![Page 6: Numerical Methods for Differential Equations Course ...ctr.maths.lu.se/na/courses/FMNN10/course_media/material/Chapter… · Numerical Methods for Di erential Equations Course objectives](https://reader034.vdocument.in/reader034/viewer/2022042211/5eb444646b93aa0b997d452a/html5/thumbnails/6.jpg)
The operators we will deal with
Boundary value problems
d2
dx2d
dx
6 / 31
![Page 7: Numerical Methods for Differential Equations Course ...ctr.maths.lu.se/na/courses/FMNN10/course_media/material/Chapter… · Numerical Methods for Di erential Equations Course objectives](https://reader034.vdocument.in/reader034/viewer/2022042211/5eb444646b93aa0b997d452a/html5/thumbnails/7.jpg)
The operators we will deal with
Partial differential operators
Parabolic Hyperbolic
∂
∂t− ∂2
∂x2∂
∂t− ∂
∂x
7 / 31
![Page 8: Numerical Methods for Differential Equations Course ...ctr.maths.lu.se/na/courses/FMNN10/course_media/material/Chapter… · Numerical Methods for Di erential Equations Course objectives](https://reader034.vdocument.in/reader034/viewer/2022042211/5eb444646b93aa0b997d452a/html5/thumbnails/8.jpg)
Course topics
• IVP Initial value problems first-order equations;higher-order equations; systems of differential equations
• BVP Boundary value problems two-point boundary valueproblems; Sturm–Liouville eigenvalue problems
• PDE Partial differential equations diffusion equation;advection equation; convection–diffusion; wave equation
• Applications in all three areas
8 / 31
![Page 9: Numerical Methods for Differential Equations Course ...ctr.maths.lu.se/na/courses/FMNN10/course_media/material/Chapter… · Numerical Methods for Di erential Equations Course objectives](https://reader034.vdocument.in/reader034/viewer/2022042211/5eb444646b93aa0b997d452a/html5/thumbnails/9.jpg)
Initial value problems Examples
A first-order equation without elementary analytical solution
dy
dt= y − e−t
2, y(0) = y0
A second-order equation Motion of a pendulum
θ +g
Lsin θ = 0, θ(0) = θ0, θ(0) = θ0
A system of equations Predator–prey model
y1 = k1 y1 − k2 y1 y2
y2 = k3 y1 y2 − k4 y2
where y1 is the prey population and y2 is the predator species
9 / 31
![Page 10: Numerical Methods for Differential Equations Course ...ctr.maths.lu.se/na/courses/FMNN10/course_media/material/Chapter… · Numerical Methods for Di erential Equations Course objectives](https://reader034.vdocument.in/reader034/viewer/2022042211/5eb444646b93aa0b997d452a/html5/thumbnails/10.jpg)
Boundary value problems Examples
Second-order two-point BVP Electrostatic potential u betweenconcentric metal spheres
d2u
dr2+
2
r
du
dr= 0, u(R1) = V1, u(R2) = 0
at distance r from the center
A Sturm–Liouville eigenvalue problem Euler buckling of a slendercolumn
y ′′ = λy , y ′(0) = 0, y(1) = 0
Find eigenvalues λ and eigenfunctions y
10 / 31
![Page 11: Numerical Methods for Differential Equations Course ...ctr.maths.lu.se/na/courses/FMNN10/course_media/material/Chapter… · Numerical Methods for Di erential Equations Course objectives](https://reader034.vdocument.in/reader034/viewer/2022042211/5eb444646b93aa0b997d452a/html5/thumbnails/11.jpg)
Some application areas in ODEs
Initial value problems
• mechanics Mq = F (q)• electrical circuits Cv = −I (v)• chemical reactions c = f (c)
Boundary value problems
• materials u′′ = M/EI
• microphysics − ~2mψ
′′ = Eψ• eigenmodes −u′′ = λu
11 / 31
![Page 12: Numerical Methods for Differential Equations Course ...ctr.maths.lu.se/na/courses/FMNN10/course_media/material/Chapter… · Numerical Methods for Di erential Equations Course objectives](https://reader034.vdocument.in/reader034/viewer/2022042211/5eb444646b93aa0b997d452a/html5/thumbnails/12.jpg)
Partial differential equations Elliptic
The Poisson Equation
uxx + uyy = f (x , y)
subject tou(x , y) = g(x , y)
on the boundary x = 0 ∨ x = 1, and y = 0 ∨ y = 1 is anelliptic PDE modelling e.g. the displacement u of an elasticmembrane under load f
12 / 31
![Page 13: Numerical Methods for Differential Equations Course ...ctr.maths.lu.se/na/courses/FMNN10/course_media/material/Chapter… · Numerical Methods for Di erential Equations Course objectives](https://reader034.vdocument.in/reader034/viewer/2022042211/5eb444646b93aa0b997d452a/html5/thumbnails/13.jpg)
Partial differential equations Parabolic
The Diffusion Equation
ut = uxx + f (x)
subject to
u(x , 0) = g(x), x ∈ [0, L]
u(0, t) = c1, u(L, t) = c2, t ∈ [0,T ]
is a parabolic PDE modelling e.g. temperature u as a funtion oftime, in a rod with temperature c1 and c2 at its ends, with initialtemperature distribution g(x) and source term f (x)
13 / 31
![Page 14: Numerical Methods for Differential Equations Course ...ctr.maths.lu.se/na/courses/FMNN10/course_media/material/Chapter… · Numerical Methods for Di erential Equations Course objectives](https://reader034.vdocument.in/reader034/viewer/2022042211/5eb444646b93aa0b997d452a/html5/thumbnails/14.jpg)
Partial differential equations Hyperbolic
The Wave Equationutt = uxx
subject to
u(x , 0) = g(x), x ∈ [0, L]
u(0, t) = 0, u(L, t) = 0, t ∈ [0,T ]
is a hyperbolic PDE modelling e.g. the displacement u of avibrating elastic string fixed at x = 0 and x = a
14 / 31
![Page 15: Numerical Methods for Differential Equations Course ...ctr.maths.lu.se/na/courses/FMNN10/course_media/material/Chapter… · Numerical Methods for Di erential Equations Course objectives](https://reader034.vdocument.in/reader034/viewer/2022042211/5eb444646b93aa0b997d452a/html5/thumbnails/15.jpg)
2. What is Numerical Analysis?
Categories of mathematical problems
Category Algebra Analysis
linear computable not computable
nonlinear not computable not computable
Algebra Only finite constructs
Analysis Limits, derivatives, integrals etc. (transfinite)
Computable Exact solution obtained with finite computation
15 / 31
![Page 16: Numerical Methods for Differential Equations Course ...ctr.maths.lu.se/na/courses/FMNN10/course_media/material/Chapter… · Numerical Methods for Di erential Equations Course objectives](https://reader034.vdocument.in/reader034/viewer/2022042211/5eb444646b93aa0b997d452a/html5/thumbnails/16.jpg)
What is Numerical Analysis?
Categories of mathematical problems
Category Algebra Analysis
linear computable not computable
nonlinear not computable not computable
Problems from all four categories can be solved numerically:
Numerical analysis aims to construct and analyze quantitativemethods for the automatic computation of approximate solutionsto mathematical problems
Goal Construction of mathematical software
16 / 31
![Page 17: Numerical Methods for Differential Equations Course ...ctr.maths.lu.se/na/courses/FMNN10/course_media/material/Chapter… · Numerical Methods for Di erential Equations Course objectives](https://reader034.vdocument.in/reader034/viewer/2022042211/5eb444646b93aa0b997d452a/html5/thumbnails/17.jpg)
3. The four principles of numerical analysis
There are four basic principles in numerical analysis. Everycomputational method is constructed from these principles
• DiscretizationTo replace a continuous problem by a discrete one
• Linear algebra tools, including polynomialsAll techniques that are computable
• LinearizationTo approximate a nonlinear problem by a linear one
• IterationTo apply a computation repeatedly (until convergence)
17 / 31
![Page 18: Numerical Methods for Differential Equations Course ...ctr.maths.lu.se/na/courses/FMNN10/course_media/material/Chapter… · Numerical Methods for Di erential Equations Course objectives](https://reader034.vdocument.in/reader034/viewer/2022042211/5eb444646b93aa0b997d452a/html5/thumbnails/18.jpg)
Discretization From function to vector
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 10
0.5
1
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 10
0.5
1
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 10
0.5
1
A continuous function is sampled at discrete points
18 / 31
![Page 19: Numerical Methods for Differential Equations Course ...ctr.maths.lu.se/na/courses/FMNN10/course_media/material/Chapter… · Numerical Methods for Di erential Equations Course objectives](https://reader034.vdocument.in/reader034/viewer/2022042211/5eb444646b93aa0b997d452a/html5/thumbnails/19.jpg)
Discretization . . .
Reduces the amount of information to a finite set
Select a subset ΩN = x0, x1, . . . , xN of distinct points from theinterval Ω = [0, 1]
Continuous function f (x) is replaced by vector F = f (xk)N0
The subset ΩN is called the grid
The vector F is called a grid function or discrete function
Discretization yields a computable problem. Approximations arecomputed only at a finite set of grid points
19 / 31
![Page 20: Numerical Methods for Differential Equations Course ...ctr.maths.lu.se/na/courses/FMNN10/course_media/material/Chapter… · Numerical Methods for Di erential Equations Course objectives](https://reader034.vdocument.in/reader034/viewer/2022042211/5eb444646b93aa0b997d452a/html5/thumbnails/20.jpg)
Discretization Approximation of derivatives
Definition of derivative
f ′(x) = lim∆x→0
f (x + ∆x)− f (x)
∆x
Take ∆x = xk+1 − xk finite and approximate
f ′(xk) ≈ f (xk + ∆x)− f (xk)
∆x=
Fk+1 − Fkxk+1 − xk
How accurate is this approximation?
20 / 31
![Page 21: Numerical Methods for Differential Equations Course ...ctr.maths.lu.se/na/courses/FMNN10/course_media/material/Chapter… · Numerical Methods for Di erential Equations Course objectives](https://reader034.vdocument.in/reader034/viewer/2022042211/5eb444646b93aa0b997d452a/html5/thumbnails/21.jpg)
Error and accuracy
Expand in Taylor series
f (xk + ∆x)− f (xk)
∆x≈ f (xk) + ∆x f ′(xk) + O(∆x2)− f (xk)
∆x
= f ′(xk) + O(∆x)
The error is proportional to ∆x
Try this formula for f (x) = ex at xk = 1 for various ∆x
21 / 31
![Page 22: Numerical Methods for Differential Equations Course ...ctr.maths.lu.se/na/courses/FMNN10/course_media/material/Chapter… · Numerical Methods for Di erential Equations Course objectives](https://reader034.vdocument.in/reader034/viewer/2022042211/5eb444646b93aa0b997d452a/html5/thumbnails/22.jpg)
Numerical differentiation
Error in numerically calculated derivative of ex at x = 1
10−15
10−10
10−5
100
10−12
10−10
10−8
10−6
10−4
10−2
100
Error in numerical differentiation
log step size
log e
rror
Loglog plot of error vs. step size ∆x
22 / 31
![Page 23: Numerical Methods for Differential Equations Course ...ctr.maths.lu.se/na/courses/FMNN10/course_media/material/Chapter… · Numerical Methods for Di erential Equations Course objectives](https://reader034.vdocument.in/reader034/viewer/2022042211/5eb444646b93aa0b997d452a/html5/thumbnails/23.jpg)
Numerical differentiation Good news, bad news
Error in numerically calculated derivative of ex at x = 1
10−15
10−10
10−5
100
10−12
10−10
10−8
10−6
10−4
10−2
100
Error in numerical differentiation
log step size
log e
rror
Loglog plot of error vs. step size ∆x
23 / 31
![Page 24: Numerical Methods for Differential Equations Course ...ctr.maths.lu.se/na/courses/FMNN10/course_media/material/Chapter… · Numerical Methods for Di erential Equations Course objectives](https://reader034.vdocument.in/reader034/viewer/2022042211/5eb444646b93aa0b997d452a/html5/thumbnails/24.jpg)
Better alternative Symmetric approximation
f (xk + ∆x)− f (xk −∆x)
2∆x=
Fk+1 − Fk−1
xk+1 − xk−1= f ′(xk) + O(∆x2)
The approximation is 2nd order accurate because error is ∆x2
Whenever you have a power law, plot in log-log diagram
r ≈ C ·∆xp ⇒ log r ≈ logC + p log ∆x
This is a straight line of slope p, easy to identify
24 / 31
![Page 25: Numerical Methods for Differential Equations Course ...ctr.maths.lu.se/na/courses/FMNN10/course_media/material/Chapter… · Numerical Methods for Di erential Equations Course objectives](https://reader034.vdocument.in/reader034/viewer/2022042211/5eb444646b93aa0b997d452a/html5/thumbnails/25.jpg)
Numerical 2nd order differentiation
Error in numerically calculated derivative of ex at x = 1
10−15
10−10
10−5
100
10−12
10−10
10−8
10−6
10−4
10−2
100
Error in numerical differentiation
log step size
log e
rror
Loglog plot of error vs. step size ∆x
25 / 31
![Page 26: Numerical Methods for Differential Equations Course ...ctr.maths.lu.se/na/courses/FMNN10/course_media/material/Chapter… · Numerical Methods for Di erential Equations Course objectives](https://reader034.vdocument.in/reader034/viewer/2022042211/5eb444646b93aa0b997d452a/html5/thumbnails/26.jpg)
Second order approximation Good news, bad news
Error in numerically calculated derivative of ex at x = 1
10−15
10−10
10−5
100
10−12
10−10
10−8
10−6
10−4
10−2
100
Error in numerical differentiation
log step size
log e
rror
Loglog plot of error vs. step size ∆x
26 / 31
![Page 27: Numerical Methods for Differential Equations Course ...ctr.maths.lu.se/na/courses/FMNN10/course_media/material/Chapter… · Numerical Methods for Di erential Equations Course objectives](https://reader034.vdocument.in/reader034/viewer/2022042211/5eb444646b93aa0b997d452a/html5/thumbnails/27.jpg)
1st and 2nd order comparison
Error in numerically calculated derivative of ex at x = 1
10−15
10−10
10−5
100
10−12
10−10
10−8
10−6
10−4
10−2
100
Error in numerical differentiation
log step size
log e
rror
2nd order approximation has much higher accuracy!
27 / 31
![Page 28: Numerical Methods for Differential Equations Course ...ctr.maths.lu.se/na/courses/FMNN10/course_media/material/Chapter… · Numerical Methods for Di erential Equations Course objectives](https://reader034.vdocument.in/reader034/viewer/2022042211/5eb444646b93aa0b997d452a/html5/thumbnails/28.jpg)
Discretization of a differential equation
Problem Solve y = qy numerically on [0,T ], with y(0) = y0
The analytical solution is a function y(t) = y0eqt
The numerical solution is a vector y = ykNk=0 with yk ≈ y(tk),where tk = kT/N
Method Approximate derivative by difference quotient, using stepsize
∆t = tk+1 − tk = T/N
28 / 31
![Page 29: Numerical Methods for Differential Equations Course ...ctr.maths.lu.se/na/courses/FMNN10/course_media/material/Chapter… · Numerical Methods for Di erential Equations Course objectives](https://reader034.vdocument.in/reader034/viewer/2022042211/5eb444646b93aa0b997d452a/html5/thumbnails/29.jpg)
Discretization of a differential equation . . .
Discretization method Approximate derivative by finitedifference quotient
yk+1 − yktk+1 − tk
≈ y(tk)
to get the linear algebraic equation system (k = 0, 1, . . . ,N)
yk+1 − yktk+1 − tk
= qyk
or
yk+1 =
(1 +
qT
N
)yk ⇒ yN =
(1 +
qT
N
)N
y0
29 / 31
![Page 30: Numerical Methods for Differential Equations Course ...ctr.maths.lu.se/na/courses/FMNN10/course_media/material/Chapter… · Numerical Methods for Di erential Equations Course objectives](https://reader034.vdocument.in/reader034/viewer/2022042211/5eb444646b93aa0b997d452a/html5/thumbnails/30.jpg)
Discretization of a differential equation . . .
Note The numerical approximation at time T is
yN =
(1 +
qT
N
)N
y0
But
limN→∞
(1 +
qT
N
)N
= eqT
The numerical approximation converges to the exact solution asN →∞
30 / 31
![Page 31: Numerical Methods for Differential Equations Course ...ctr.maths.lu.se/na/courses/FMNN10/course_media/material/Chapter… · Numerical Methods for Di erential Equations Course objectives](https://reader034.vdocument.in/reader034/viewer/2022042211/5eb444646b93aa0b997d452a/html5/thumbnails/31.jpg)
Main course objective
The course centers on discretization methods for differentialequations of all types
We will also encounter the other three principles of numericalanalysis as we go
• linear algebra methods and polynomial techniques
• linearization
• and iterative methods
31 / 31