Professional Documents
Culture Documents
Dr. Johnson
School of Mathematics
Semester 1 2012
Topics:
Errors and precision
Flow control - if, else, for, do
Functions - how and where to use them
Pointers - dynamic allocation, pass by reference
Aims - week 2:
Understand precision and errors within a program.
Use functions, loops and if statement to control a program.
Understand the concept of a pointer.
Topics:
Initial value problems for ODEs
Euler’s Method for ODEs
Stability
Using the standard libraries
Aims - week 3:
Be able to solve an initial value ODE problem
Understand where truncation errors come from
Be aware of the concept of stability in a numerical method
Be able to use standard libraries to store your data
dy
= f (x, y ), a≤x ≤b
dx
dy
= f (x, y ), a≤x ≤b
dx
subject to an initial condition
y (a) = α
E XAMPLES
E XAMPLES
x0 x1 x2 ... xi ... xn
1
y (xi+1 ) = y (xi ) + y 0 (xi )h + y 00 (ξ)
2
where xi ≤ ξ ≤ xi+1 .
1
y (xi+1 ) = y (xi ) + f (xi , y (xi ))h + y 00 (ξ)
2
where xi ≤ ξ ≤ xi+1 .
T HE E ULER M ETHOD
T HE E ULER M ETHOD
T RUNCATION E RRORS
T RUNCATION E RRORS
T RUNCATION E RRORS
h 00
τi+1 (h) = y (ξi ),
2
T RUNCATION E RRORS
h 00
τi+1 (h) = y (ξi ),
2
and if y 00 is bounded by the constant M on the interval
[a, b] then
h
|τi+1 (h)| ≤ M.
2
T RUNCATION E RRORS
h 00
τi+1 (h) = y (ξi ),
2
and if y 00 is bounded by the constant M on the interval
[a, b] then
h
|τi+1 (h)| ≤ M.
2
Hence the truncation error is O(h).
A method with truncation error O(hp ) is called an order p
method
Dr. Johnson MATH49111
Review
Initial Value Problems What is stability?
Stability Defining stability
Summary
A N EXAMPLE PROBLEM :
y 0 = −50y , 0 ≤ x ≤ 1, y (0) = 1
yi+1 = yi + hf (xi , yi ).
y (x) = e−50x
T HE E XACT S OLUTION
1
y=e-50x
0.8
0.6
y(x)
0.4
0.2
0
0 0.2 0.4 0.6 0.8 1
x
U NSTABLE S OLUTION
U NSTABLE SOLUTION
S TABLE SOLUTION
U NSTABLE S OLUTIONS
y=e-50x
4 n=20
n=25
n=30
2
y(x)
-2
-4
S TABLE S OLUTIONS
1
y=e-50x
n=50
n=100
0.8
0.6
y(x)
0.4
0.2
0
0 0.2 0.4 0.6 0.8 1
x
C ONSISTENCY
D EFINITION :
A one-step difference method with truncation error τi (h) at the
ith step is said to be consistent with the difference equation it
approximates if
lim max |τi (h)| = 0.
h→0 i
C ONVERGENCE
D EFINITION :
A one-step difference method is said to be convergent with
respect to the difference equation it approximates if
S TABILITY
D EFINITION :
A stable method is one whose results depend continuously on
the initial data.
Topics:
Initial value problems for ODEs
Euler’s Method for ODEs
Stability
Using the standard libraries
Aims - week 3:
Be able to solve an initial value ODE problem
Understand where truncation errors come from
Be aware of the concept of stability in a numerical method
Be able to use standard libraries to store your data