Ordinary Differential Equations in Matlab: Day-2: Evening

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 8

Ordinary Differential Equations

Ordinary Differential Equations in


MATLAB

Day-2: Evening

Dr. Prasiddh Trivedi


Ordinary Differential Equations

First-order ODE

The simplest
dy(t)
= ay(t), y(0) = y0
dt

Solution
y(t) = y0 eat

Study of ODEs
Existence and uniqueness.
Continuous dependence on initial conditions.
Equilibria.
Stability.

2/8 Ordinary Differential Equations: Numerical Solutions Dr. Prasiddh Trivedi


Ordinary Differential Equations

MATLAB functions for solving IVP ODEs

Solvers
1. Non-stiff
ode23
ode45
ode113
2. Stiff
ode15s
ode23s, ode23t, ode23tb
3. Implicit
ode15i e.g. tẏ 2 + y = y 3

Options
odeset / odeget

3/8 Ordinary Differential Equations: Numerical Solutions Dr. Prasiddh Trivedi


Ordinary Differential Equations

The simplest
dy(t)
= ay(t), y(0) = y0
dt

Solution
y(t) = y0 eat

4/8 Ordinary Differential Equations: Numerical Solutions Dr. Prasiddh Trivedi


Ordinary Differential Equations

Lotka-Volterra (Predator-Prey) Equation

Predator : p
Prey(Harvested) : h

intrinsic growth rate of prey : alpha


population carrying capacity of environment : K
intrinsic decay rate of predator : β

Predator and Prey(harvested) do not interact


ḣ = αh(1 − h/K)
ṗ = −βp

5/8 Ordinary Differential Equations: Numerical Solutions Dr. Prasiddh Trivedi


Ordinary Differential Equations

Lotka-Volterra (Predator-Prey) Equation

Predator : p
Prey(Harvested) : h

intrinsic growth rate of prey : α


population carrying capacity of environment : K
intrinsic decay rate of predator : β

Predator feeds on Prey(harvested) do not interact


ḣ = αh(1 − h/K) − γhp
ṗ = −βp + δhp

6/8 Ordinary Differential Equations: Numerical Solutions Dr. Prasiddh Trivedi


Ordinary Differential Equations

Visualizing the vector field

Differential equations as vector field


Let’s define a 2-dimensional vectorwhose
 coordinates
  are h and p, respectively.
x1 h
x= =
x2 p

ODE in state-space
 
αx1 (1 − x1 /K) − γx1 x2
ẋ =
−βx2 + δx1 x2

7/8 Ordinary Differential Equations: Numerical Solutions Dr. Prasiddh Trivedi


Ordinary Differential Equations

Homework

Pendulum
d2 θ g
+ sin θ = 0
dt l

1. Represent the equation in state-space form.


2. Plot the solution various initial conditions.
3. Make phase portrait.
4. Plot the vector field.

8/8 Ordinary Differential Equations: Numerical Solutions Dr. Prasiddh Trivedi

You might also like