You are on page 1of 11

Outline

Motivation Behind ODE:

Methods to solve ODE

Syntax for ODE to program using Scilab/Matlab

Practice Questions
Big Idea: ODE has been used by engineers and scientists to
Introduction of ODEs capture various physical processes.

Suppose, a bungee-jumping company hires you.

You are given the task of predicting the velocity of a


jumper as a function of time during the free-fall part of the
jump.

This information will be used as part of a larger


analysis to determine the length and required strength
of the bungee cord for jumpers of different mass.

10/10/2020 2
Introduction of ODEs
(Physical law->ODE)

We know that,
F dv F
F = ma; a= ; = ;
m dt m

Applying Newton’s second law,

F = FD + FU
FD = mg; FU = - cd v 2

From above two equations we


can write,
dv cd v 2
= g-
dt m
Above equation is a ODE of first order.

10/10/2020 3
Introduction of ODEs
 ODEs involve one or more functions of a single variable, with all derivatives ordinary
ones relative to that variable.

For Example

Here x is an unknown function of t and m, k are constants. That's a second-order, linear,


ordinary differential equation

Law of Law of Motion:


Cooling:

Kirchhoff’s Law of an Electric


Circuit:

Radioactive Decay:

Simple Harmonic
10/10/2020 Motion: 4
Order of ODE

• Higher order DEs can be reduced to a system of first-order DEs. Hence,


focus on 1st order DEs

10/10/2020 5
Methods
One-step Methods
 New Value = old value + slope x step size

Euler’s Method yi 1  yi  hf  ti , yi 

• Easy to understand and simple to program

• The solution has low accuracy but widely used due to its simplicity to know
approximate value.
• Taking small step size helps to reduce error but very small step sizes also give
large errors due to accumulated round-off effect. That’s why we should look for
other methods.

h
Heun’s Method yi 1  yi   f  ti , yi   f  ti 1 , yi 1  
2

10/10/2020 6
Methods
Runge-Kutta Methods

• Although Heun’s method is little better than Euler’s method, it is still not accurate
enough for most real world problems.
• The RK4 method having truncation error of 0(h4) is one of the most widely used
method for solving differential equation.
h
yi 1  yi   f k1  2 f k 2  2 f k 3  f k 4 
6

f k 1  f  ti , yi   h h
f k 2  f  ti  , yi  f k 1 
 2 2

 h h f k 4  f  ti  h, yi  f k 3 h 
f k 3  f  ti  , yi  f k 2 
 2 2

10/10/2020 7
Syntax
 

y = ode(y0,t0,t,f) where y0 is the vector of initial conditions, t0 is the initial time, t is the vector of times
at which the solution y is computed and y is matrix of solution vectors y=[y(t(1)),y(t(2)),...].

By default, ODE solver will be between non-stiff predictor-corrector Adams method and stiff Backward
Differentiation Formula (BDF) method.

dy/dt=y2-y.sin(t)+cos(t) with the initial condition y(0)=0.

function ydot=f(t, y)
ydot=y^2-y*sin(t)+cos(t)
endfunction
y0=0;
t0=0;
t=0:0.1:%pi;
y = ode(y0,t0,t,f);
plot(t,y)
Syntax
Initial Conditions
Declared ODE
function name

Syntax

Solver-type:
ode45,ode23,ode113,o
de15s,ode23s Time span for which the
sol. Is needed

10/10/2020 9
Syntax Solvers in Sci-Lab

a real vector or matrix:


initial state, at t0 a real vector, the times
at which the solution is
computed.

Syntax
y = ode( y0 , t0 , t , f )

Solver-command a function, external,


string or list, the right
hand side of the
a real scalar, the initial
differential equation.
time

10/10/2020 10
Practice Questions
Consider a ball is thrown at an angle θ wrt X-axis, it undergoes a
projectile motion. Find the angle for which the range traversed by
the ball is maximum? Assume that the initial velocity is 50m/s.
Please assume the value of any other quantity if missing in this
problem.

Aerodynamic force on a Ball

You might also like