Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
29 January 2014
Matylda Jaboska-Sabuka
Matylda Jaboska-Sabuka
(1)
3 1
1 3
Matylda Jaboska-Sabuka
y+
6
2
e 2t
Matylda Jaboska-Sabuka
Example 2
Solve by variation of parameters
3 1
6
0
y = Ay + g =
y+
e 2t
1 3
2
Matylda Jaboska-Sabuka
y10 = f1 (y1 , y2 )
y20 = f2 (y1 , y2 )
Matylda Jaboska-Sabuka
X
f (n) (a)
n=0
12
n!
(x a)n
function y=exp(x)
1degree Taylor
10
3degree Taylor
5degree Taylor
7degree Taylor
6
4
2
0
2.5
1.5
0.5
Matylda Jaboska-Sabuka
0.5
1.5
2.5
Linearization
For nonlinear systems of first-order ODEs, express y0 as
y0 = f(y) = Ay + h(y) and drop h(y).
For nonlinear higher order equations, transform is into a system of
first-order ODEs and proceed as above.
Matylda Jaboska-Sabuka
Example 3
y10 = y2
y20 = k sin y1
Matylda Jaboska-Sabuka
Consequence of linearization
y1 original
y1 linearized
y2 original
y2 linearized
0.8
0.6
0.4
0.2
0
0.2
0.4
0.6
0.8
1
Matylda Jaboska-Sabuka
10
12
14
16
18
20
Matylda Jaboska-Sabuka
Step-by-step methods
For initial value problem
y 0 = f (x, y ), y (x0 ) = y0
Method of computing approximate numeric values of the solution y (x) at
the equidistant points on the x-axis
x1 = x0 + h, x2 = x0 + 2h, x3 = x0 + 3h, . . .
where the step size h is a fixed number, for instance, 0.2 or 0.1 or 0.01.
Such formulas are suggested by the Taylor series
y (x + h) = y (x) + hy 0 (x) +
Matylda Jaboska-Sabuka
h2 00
y (x) + . . .
2
For a small h the higher powers h2 , h3 , . . . are very small. This suggests
the crude approximation
y (x + h) y (x) + hy 0 (x) = y (x) + hf (x, y ).
Euler (or Euler-Cauchy) method
In an iterative way we get the approximation
y1
y0 + hf (x0 , y0 )
...
yn+1
yn + hf (xn , yn )
Example 4
Apply the Euler method to the following initial value problem, choosing
h = 0.2 and computing y1 , . . . , y5 :
y 0 = y + x, y (0) = 0.
Compare the results with functions real values:
y (x) = e x x 1
Matylda Jaboska-Sabuka
Euler method
yn+1 = yn + hf (xn , yn )
n
0
1
2
3
4
5
xn
0
0.2
0.4
0.6
0.8
1.0
yn
0
0
0.04
0.128
0.274
0.489
hf (xn + yn )
0
0.2(0.2+0)
0.2(0.4+0.04)
0.2(0.6+0.128)
0.2(0.8+0.274)
Matylda Jaboska-Sabuka
ex x 1
0
0.0214
0.0918
0.2221
0.4255
0.7183
Matylda Jaboska-Sabuka
yn+1
= yn + hf (xn , yn )
and then the new value
1
Matylda Jaboska-Sabuka
Matylda Jaboska-Sabuka
Stiff problems
A stiff equation is a differential equation for which certain numerical
methods for solving the equation are numerically unstable, unless the step
size is taken to be extremely small. It has proved difficult to formulate a
precise definition of stiffness, but the main idea is that the equation
includes some terms that can lead to rapid variation in the solution.
Solving stiff equations can be a very long and hard process.
Backward (Implicit) Euler Method
The backward Euler formula for stiff problems
yn+1 = yn + hf (xn+1 , yn+1 )
Matylda Jaboska-Sabuka
Multistep Methods
y 0 = f (x, y ), y (x0 ) = y0
Adams-Bashforth Methods
yn+1 = yn +
h
(55fn 59fn1 + 37fn2 9fn3 )
24
= f (xn+1 , yn+1
)
h
= yn + (9fn+1
+ 19fn 5fn1 + fn2 )
24
yn+1
= yn +
fn+1
yn+1
Matylda Jaboska-Sabuka
Matylda Jaboska-Sabuka
ODE45 results
Difference between constant and variable step size when solving
y 0 = x + y , y (0) = 0.
h = 0.1
hn variable
CPU time
0.0312
0.1872
MSE
9.8416e-018
2.6404e-018
CPU time
0.0312
0.1872
Matylda Jaboska-Sabuka
MSE
3.5430e-016
9.5056e-017
Matylda Jaboska-Sabuka
Problem Type
Nonstiff
Nonstiff
Nonstiff
Stiff
Stiff
Matylda Jaboska-Sabuka
Order of Accuracy
Medium
Low
Low to high
Low to medium
Low
y1 (0) = 0
y20
y30
y2 (0) = 1
= y1 y3 ;
= 0.51y1 y2 ; y3 (0) = 1
t = [0, 12]
With ode45 the solution takes about 0.38sec.
With ode15s the solution takes about 0.59sec.
The stiff solver can treat a nonstiff problem efficiently with minor solution
difference.
Matylda Jaboska-Sabuka
= 1000(1
y1 (0) = 0
y12 )y2
y1 ; y2 (0) = 1
t = [0, 3000]
With ode15s the solution takes about 1sec.
The nonstiff solver (ode45) cannot handle the problem in reasonable
time, and significantly influences the solution.
Matylda Jaboska-Sabuka