You are on page 1of 3

Computational Methods for Mechatronics (EMEng 6441)

Chapter 2 Notes: System of ODEs

Although some applications of differential equations involve only a single first-order equation,
most applications involve a system of several such equations or higher-order equations. In this
chapter, we consider systems of first-order equations, showing how Euler’s method applies to
such systems. Numerical treatment of higher-order equations can be carried out by first
converting them to equivalent systems of first-order equations.
To begin with a simple case, the general form of a system of two first-order differential
equations is

where except for the independent variable x, all other quantities are vectors. And as such, Euler,s
or Runge-Kutta methods used to solve a single first-order IVP, can be extended and applied to a
system of first-order IVPs.

Transformation of Higher-Order ODEs into a System of First-Order ODEs


The first task is to show how a single higher-order IVP or a system of various-order IVPs may be
transformed into a system of first-order IVPs. The most important tools that facilitate this
process are the state variables.

State Variables
State variables form the smallest set of linearly independent variables that completely describe
the state of a system. Given the mathematical model of a system, the state variables are
determined as follows:
• How many state variables are there?
The number of state variables is the same as the number of initial conditions required to
completely solve the model.
• What are selected as state variables?
The state variables are selected to be exactly those variables for which initial conditions are
required.

Notation
State variables are represented by ui; for example, if there are three state variables, they will be
denoted u1, u2, and u3.

State-Variable Equations
If a system has m state variables u1, u2, . . . , um, then there are exactly m state-variable equations.
Each of these equations is a first-order differential equation in the form
Therefore, the left side is the first derivative (with respect to time in most applications) of the
state variable ui, and the right side is an algebraic function of the state variables, and possibly
time t explicitly. Note that only state variables and functions of time that are part of the system
model are allowed to appear on the right side of Equation. The system of first-order differential
equations can be conveniently expressed in vector form as

Activity 5

Consider the third-order IVP described by

Since three initial conditions are required, there are three state variables: u1, u2, and u3. The
state variables are those variables for which initial conditions are required. Therefore:

There are three state-variable equations:

In vector form:
5.1. We will first apply Euler’s method given by:

to solve the above system of ODE. Write a user defined function called
EulerODE_Sys.m that solves a system of first-order ODEs given in the form u' = f(x,u) subject
to initial condition vector u0. EulerODE_Sys.m should have three inputs f, x and u0, and one
output u, where:

 f is an m-dimensional vector function representing f(x,u),


 x is an (n+1)-dimensional vector representing the mesh points,
 u0 is an m-dim. vector representing the initial condition of u,
 u is an m-by-(n+1) matrix, each column being the vector of solution estimates at a mesh
point.
5.2. Write a script in Matlab that uses EulerODE_Sys.m to calculate the vector of estimates u.
5.3. Write a Matlab function called RK4_Sys.m for RK4 method, given as follows for system of
ODE

5.4. Use built-in Matlab function ode45 to calculate the vector estimates and use them to
compare the performance of Euler’s and RK4’ methods.

You might also like