4_Intro-to-ODE
4_Intro-to-ODE
ODEAnalisis
Numerik
1
Example – Newton’s Law of Cooling
• This is a model of how the temperature of an object
changes as it loses heat to the surrounding
atmosphere:
For
m dTObj
ODE (TObj T Room )
Solv dt
e
ODE TObj TRoom (Tinit T Room )et
Where Tiinsitthe initial temperature of the
Example – Swinging of a pendulum
Newton’s 2nd law for a rotating object:
Moment of inertia x angular acceleration = Net
external torque
ml mgl sin
d 2
2
dt 2
rearrange and
divide through by
l
ml 2 wher
d 2 e2
sin 0
2
l
dt 2
g
mg
This equation is very difficult to
solve.
Notation and Definitions
• Order
• Linearity
• Homogeneity
• Initial Value/Boundary value
problems
Orde
r • The order of a differential
equation is just the order of
highest derivative used.
d 2 y dy 2nd
.
dt 2
dt 0 order
dx d3
3rd
xdt dt 3
order
x
Linearity
• The important issue is how the unknown y appears in
the equation. A linear equation involves the
dependent variable (y) and its derivatives by
themselves. There must be no "unusual" nonlinear
functions of y or its derivatives.
• A linear equation must have constant coefficients, or
coefficients which depend on the independent
variable (t). If y or its derivatives appear in the
coefficient the equation is non-linear.
Linearity - Examples
dy is
dt y
0 linear
dx
x 2 is non-
dt 0 linear
dy
t 2
is
dt
0 linear
dy
y
dt t2 0 is non-
linear
Linearity –
Summary
Linear Non-linear
2y y2 or
sin( y)
dy dy
y
dt
dt
(2 3sin t) y (2 3y 2 ) y
dy dy
2
t
dt
dt
Linearity – Special Property
If a linear homogeneous ODE has
solutions:
y f (t) an y
d g(t)
then:
y a f (t) b g(t)
where a and b are
constants,
is also a solution.
Linearity – Special Property
Exampl
e:d 2 y
dt 2 y 0 has y sin t and y cos
solutions t
Chec d (sin t) sin t sin t sin t
2
k 2 dt
2
d (cos t) 0
cos t cos
dt 2
t cos
t 0
Therefore y sin t cos t is also a
solution:
Chec d 2 (sin t cos t)
sin t cos
k dt 2
t
sin t cos t sin t cos t
0
Life is mostly linear!!!
Most ODEs that arise in engineering are linear with
constant coefficients.
In many cases they are approximate versions of more
complex
nonlinear models but they are sufficiently accurate for
most
purposes. Often they work OK for small amplitude
disturbances
but for large amplitude behaviour nonlinearities start
to have some effect.
d 2 sin
2
dt 0
2
But for small angles of swing this can be
approximated
by the linear ODE:
d 2
2
0
dt 2
Homogeniety
• Put all the terms of the equation which involve the
dependent variable on the LHS.
• Homogeneous: If there is nothing left on the RHS the
equation is homogeneous (unforced or free)
• Nonhomogeneous: If there are terms involving t
(or constants) - but not y - left on the RHS the
equation is nonhomogeneous (forced)
Initial Value/Boundary value
problems• Problems that involve time are
represented by an ODE together with
initial values.
dx w
2 Nonhomogeneous
Boundary value
M (0) problem
0
and
M (l)
0
Example
• 2nd order
d
2
2
sin 0 • Nonlinear
dt 2
• Homogeneous
θ( 0 ) 0θ , dt (0) 0 • Initial value
d
problem
2nd order
Linear
d 22
dt 2
0 Homogeneous
Initial value
problem
d
θ( 0 ) 0θ , dt (0) 0
Solution Methods - Direct Integration
• This method works for equations
where the RHS does not
depend on the unknown:
• The general form is:
dy
dt f (t)
d 2y
f (t)
dt 2
⁝
d ny
f (t)
dt n
Direct Integration
• y is called the unknown or dependent variable;
• t is called the independent variable;
• “solving” means finding a formula for y as a function of
t;
• Mostly we use t for time as the independent variable
but in some cases we use x for distance.
Direct Integration – Example
Find the velocity of a car
that is accelerating from
rest at 3 ms-2:
dv
dt a
3 v 3t
c
If the car was initially at
rest we have the
condition:
v(0) 0 0 3 0 c c 0
Bending of a beam -
Example A beam under uniform
load
(pinned
M (0) 0 and M ends)
(l) 0
Bending of a beam - Solution
d 2M
w
dx2
Step 1:
Integrate dM
dx wx
A
Step 2:
Integrate again 1
M wx2 Ax
to obtain the B
general 2
solution:
Bending of a beam - Solution
Step 3:
Use the boundary conditions to
obtain the particular solution.
1
M wx Ax
2
2 B
M (0) 0
0 2 w 02 A 0 B B 0
1
M (l)
1
0 0 2 w l 2 A l B A 21 wl
Step 4:
Substitute back the values for A
and B1 2 1
M wx wlx 1
2 M 2 wx(l x)
2
Solution Methods - Separation
The separation method applies
only to 1st order ODEs. It can be
used if the RHS can be factored
into a function of t multiplied by a
function of y:
dy
dt
g(t)h( y)
Separation – General
Idea
First
Separate:
dy
h( y) g(t)dt
y Aecos(t )
Cooling of a cup of
coffee Amount of heat in a cup of
coffee:
heat volume specific
Q
heat
VcT
densit temperatur
y e
)
Cooling acup of
of coffee
dQ
dt hA(T T
Room
Substitute ) dT
in Q
V c hA(T TRoom )
VcT dt
wher
rearrang dT
e (T TRoom ) e hA
Vc
dt
Now we solve the equation together with
the initial condition:
T (0) TInitial
Cooling acup of coffee -
of Solution
dT
(T T Room
dt
)
Step 1: dT
dt
Separat (T TRoom )
e
Step 4:
Substitute T Room (TInitial T Room )et
back to T
obtain final
answer
Solution Methods - Integrating Factor
The integrating factor method is used
for nonhomogeneous linear 1st order
equations
The basic ideas are:
Collect all the terms involving y on the
dy
and hand side of the equation. left dt
Combine them together as the derivative of
a single function of y and t.
Solve by direct integration.
dy y(0)
dt y 2
1
d ( f .y)
f
dy df dt
y
e t dy
dt e y
t
et
Now the LHS of this equation looks like the
RHS of the
Product Rule with:
f et
Integrating Factor – Example
We can rewrite the
equation as:
t dy d t
e t y
(e
dt )e dt
o
r d (et y)
et
dt
Now we can use direct integration
et y et C
y 1 Cet
Now use the initial condition to
calculate C
y(0) 2 1 Ce0 2
1C2
C1
Substitute back to obtain the final
solution
t
How do we calculate the integrating
factor?
• Let us now pretend we do not know what the integrating factor
should be
• Call it Φ and use it to multiply the ODE from the previous
example
dydty
d
dt
How do we calculate the integrating
factor?
• Then the ODE becomes
dy dy
dt
dt
d (y)
dt
How do we calculate the integrating
factor?
• Now we can integrate once we
know Φ
• We can separate to find Φ
d d
dt dt
ln t c et c
Aet
et
Finding the integrating factor in
general • Given the general form of a
nonhomogeneous 1st order
equation:
dy
dt g(t) y f (t)
y(0) y0
g (t )dt
Finding the integrating factor in
general • Step 4: Combine terms on the
LHS:
d[y]
dt f (t)
Step 5: Integrate:
y fdt C
Step 6: Divide
1 by Cto make explicit
y fdt
in y :
Step 7: Use the initial
conditions to evaluate C :
Finding the integrating factor in
general Notes:
• After you have been through the
process a few times then skip
some of the steps. For example you
can remember the formula for
the integrating factor, you do not have
to re- derive it every time.
e
g (t )dt
tdt
g(t) t 1 e
t2
e 2
Solving an example using the
integrating factor method
Step 3: Multiply by the integrating
factor:
2
t
e2
1 dy 1t
ty te
21t
dt e 2
2
2
Step 4: Use the reverse Product
Rule:
d[e 1 t y]
2
2
t2
1
2
dt te
Step 5: Integrate and make
explicit in y:
y te dt C e
1 t2 21 t
2
21
e t2
C
2
12t
y1
2
Ce
Solving an example using the
integrating factor method
Step 6: Use the initial conditions to find the exact solution:
y(0) 0 1 Ce0 0
1C0
C 1
Step 7: Substitute back into the original
equation:
y 1 12 t 2
e
Exponential substitution
• The exponential trial or guessing method
can be used for solving linear
constant coefficient homogeneous
differential equations.
y Ce t
Characteristic Equations
• gives the differentials
y Cet
y
Cet y 2Ce t
(3) Ce
3 t
y
⁝
y
(n) n
Ce t
An algebraic characteristic equation comes from
substituting in for y and its derivatives and
cancelling out
t
Ce
Exponential Trial -
Example y 5 y Try y
Ae
t
0 Ae 5Ae 0
t t
Cancelling
gAiveest the characteristic
out
equation
5 5
0
Substituting this back
gyives
into
y Ae5t Aet
Solving
Guide
General Form Description Solvin
g
Metho
d
1st or higher Direct
d y n
order Integrati
f (t)
dt n RHS does on
not depend
on the
unknown y
1st order only Separation
dy
f (t, y)
g(t)h( y) dt
1st order Integrating
dy
g(t) y f (t) nonhomogeneou Factor
dt s Method
linear equation
Solving
Guide
General Form Description Solvin
g
Metho
d
2nd order or Exponential
n n1
d y
d y
higher trial.
homogeneous
an1
dtn dtn1 linear equation
dy constant
… a a
y 01 coefficients
dt
0