Outline: Motivation Behind ODE: Methods To Solve ODE Syntax For ODE To Program Using Scilab/Matlab Practice Questions
Outline: Motivation Behind ODE: Methods To Solve ODE Syntax For ODE To Program Using Scilab/Matlab Practice Questions
Practice Questions
Big Idea: ODE has been used by engineers and scientists to
Introduction of ODEs capture various physical processes.
10/10/2020 2
Introduction of ODEs
(Physical law->ODE)
We know that,
F dv F
F = ma; a= ; = ;
m dt m
F = FD + FU
FD = mg; FU = - cd v 2
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
Radioactive Decay:
Simple Harmonic
10/10/2020 Motion: 4
Order of ODE
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
• 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.
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
Syntax
y = ode( y0 , t0 , t , f )
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.