Skip to main content
Logo image

Introduction to Differential Equations

Section 7.1 Introduction to systems of ODEs

Note: 1 to 1.5 lectures, §4.1 in [EP], §7.1 in [BD]

Subsection 7.1.1 Systems

Often we do not have just one dependent variable and one equation. And as we will see, we may end up with systems of several equations and several dependent variables even if we start with a single equation.
If we have several dependent variables, suppose y1, y2, ..., yn, then we can have a differential equation involving all of them and their derivatives with respect to one independent variable x. For example, y1=f(y1,y2,y1,y2,x). Usually, when we have two dependent variables we have two equations such as
y1=f1(y1,y2,y1,y2,x),y2=f2(y1,y2,y1,y2,x),
for some functions f1 and f2. We call the above a system of differential equations. More precisely, the above is a second order system of ODEs as second order derivatives appear. The system
x1=g1(x1,x2,x3,t),x2=g2(x1,x2,x3,t),x3=g3(x1,x2,x3,t),
is a first order system, where x1,x2,x3 are the dependent variables, and t is the independent variable.
The terminology for systems is essentially the same as for single equations. For the system above, a solution is a set of three functions x1(t), x2(t), x3(t), such that
x1(t)=g1(x1(t),x2(t),x3(t),t),x2(t)=g2(x1(t),x2(t),x3(t),t),x3(t)=g3(x1(t),x2(t),x3(t),t).
We usually also have an initial condition. Just like for single equations we specify x1, x2, and x3 for some fixed t. For example, x1(0)=a1, x2(0)=a2, x3(0)=a3. For some constants a1, a2, and a3. For the second order system we would also specify the first derivatives at a point. And if we find a solution with constants in it, where by solving for the constants we find a solution for any initial condition, we call this solution the general solution. Best to look at a simple example.

Example 7.1.1.

Sometimes a system is easy to solve by solving for one variable and then for the second variable. Take the first order system
y1=y1,y2=y1y2,
with y1, y2 as the dependent variables and x as the independent variable. And consider initial conditions y1(0)=1, y2(0)=2.
We note that y1=C1ex is the general solution of the first equation. We then plug this y1 into the second equation and get the equation y2=C1exy2, which is a linear first order equation that is easily solved for y2. By the method of integrating factor we get
exy2=C12e2x+C2,
or y2=C12ex+C2ex. The general solution to the system is, therefore,
y1=C1ex,y2=C12ex+C2ex.
We solve for C1 and C2 given the initial conditions. We substitute x=0 and find that C1=1 and C2=3/2. Thus the solution is y1=ex, and y2=(1/2)ex+(3/2)ex.
Generally, we will not be so lucky to be able to solve for each variable separately as in the example above, and we will have to solve for all variables at once. While we won’t generally be able to solve for one variable and then the next, we will try to salvage as much as possible from this technique. It will turn out that in a certain sense we will still (try to) solve a bunch of single equations and put their solutions together. Let’s not worry right now about how to solve systems yet.
We will mostly consider the linear systems. The example above is a so-called linear first order system. It is linear as none of the dependent variables or their derivatives appear in nonlinear functions or with powers higher than one (x, y, x and y, constants, and functions of t can appear, but not xy or (y)2 or x3). Another, more complicated, example of a linear system is
y1=ety1+t2y1+5y2+sin(t),y2=ty1y2+2y1+cos(t).

Subsection 7.1.2 Applications

Let us consider some simple applications of systems and how to set up the equations.

Example 7.1.2.

First, we consider salt and brine tanks, but this time water flows from one to the other and back. We again consider that the tanks are evenly mixed.
Figure 7.1. A closed system of two brine tanks.
Suppose we have two tanks, each containing volume V liters of salt brine. The amount of salt in the first tank is x1 grams, and the amount of salt in the second tank is x2 grams. The liquid is perfectly mixed and flows at the rate r liters per second out of each tank into the other. See Figure 7.1.
The rate of change of x1, that is x1, is the rate of salt coming in minus the rate going out. The rate coming in is the density of the salt in tank 2, that is x2V, times the rate r. The rate coming out is the density of the salt in tank 1, that is x1V, times the rate r. In other words it is
x1=x2Vrx1Vr=rVx2rVx1=rV(x2x1).
Similarly we find the rate x2, where the roles of x1 and x2 are reversed. All in all, the system of ODEs for this problem is
x1=rV(x2x1),x2=rV(x1x2).
In this system we cannot solve for x1 or x2 separately. We must solve for both x1 and x2 at once, which is intuitively clear since the amount of salt in one tank affects the amount in the other. We can’t know x1 before we know x2, and vice versa.
We don’t yet know how to find all the solutions, but intuitively we can at least find some solutions. Suppose we know that initially the tanks have the same amount of salt. That is, we have an initial condition such as x1(0)=x2(0)=C. Then clearly the amount of salt coming and out of each tank is the same, so the amounts are not changing. In other words, x1=C and x2=C (the constant functions) is a solution: x1=x2=0, and x2x1=x1x2=0, so the equations are satisfied.
Let us think about the setup a little bit more without solving it. Suppose the initial conditions are x1(0)=A and x2(0)=B, for two different constants A and B. Since no salt is coming in or out of this closed system, the total amount of salt is constant. That is, x1+x2 is constant, and so it equals A+B. Intuitively if A is bigger than B, then more salt will flow out of tank one than into it. Eventually, after a long time we would then expect the amount of salt in each tank to equalize. In other words, the solutions of both x1 and x2 should tend towards A+B2. Once you know how to solve systems you will find out that this really is so.

Example 7.1.3.

Let us look at a second order example. We return to the mass and spring setup, but this time we consider two masses.
Consider one spring with constant k and two masses m1 and m2. Think of the masses as carts that ride along a straight track with no friction. Let x1 be the displacement of the first cart and x2 be the displacement of the second cart. That is, we put the two carts somewhere with no tension on the spring, and we mark the position of the first and second cart and call those the zero positions. Then x1 measures how far the first cart is from its zero position, and x2 measures how far the second cart is from its zero position. The force exerted by the spring on the first cart is k(x2x1), since x2x1 is how far the string is stretched (or compressed) from the rest position. The force exerted on the second cart is the opposite, thus the same thing with a negative sign. Newton’s second law states that force equals mass times acceleration. So the system of equations is
m1x1=k(x2x1),m2x2=k(x2x1).
Again, we cannot solve for the x1 or x2 variable separately. That we must solve for both x1 and x2 at once is intuitively clear, since where the first cart goes depends on exactly where the second cart goes and vice versa.

Subsection 7.1.3 Changing to first order

Before we talk about how to handle systems, let us note that in some sense we need only consider first order systems. Let us take an nth order differential equation
y(n)=F(y(n1),,y,y,x).
We define new variables u1,u2,,un and write the system
u1=u2,u2=u3, un1=un,un=F(un,un1,,u2,u1,x).
We solve this system for u1, u2, ..., un. Once we have solved for the u, we can discard u2 through un and let y=u1. This y solves the original equation.

Example 7.1.4.

Take x=2x+8x+x+t. Letting u1=x, u2=x, u3=x, we find the system:
u1=u2,u2=u3,u3=2u3+8u2+u1+t.
A similar process can be followed for a system of higher order differential equations. For example, a system of k differential equations in k unknowns, all of order n, can be transformed into a first order system of n×k equations and n×k unknowns.

Example 7.1.5.

Consider the system from the carts example,
m1x1=k(x2x1),m2x2=k(x2x1).
Let u1=x1, u2=x1, u3=x2, u4=x2. The second order system becomes the first order system
u1=u2,m1u2=k(u3u1),u3=u4,m2u4=k(u3u1).

Example 7.1.6.

The idea works in reverse as well. Consider the system
x=2yx,y=x,
where the independent variable is t. We wish to solve for the initial conditions x(0)=1, y(0)=0.
If we differentiate the second equation, we get y=x. We know what x is in terms of x and y, and we know that x=y. So,
y=x=2yx=2yy.
We now have the equation y+y2y=0. We know how to solve this equation and we find that y=C1e2t+C2et. Once we have y, we use the equation y=x to get x.
x=y=2C1e2t+C2et.
We solve for the initial conditions 1=x(0)=2C1+C2 and 0=y(0)=C1+C2. Hence, C1=C2 and 1=3C2. So C1=1/3 and C2=1/3. Our solution is
x=2e2t+et3,y=e2t+et3.

Exercise 7.1.1.

Plug in and check that this really is the solution.
It is useful to go back and forth between systems and higher order equations for other reasons. For example, software for solving ODE numerically (approximation) is generally for first order systems. To use it, you take whatever ODE you want to solve and convert it to a first order system. It is not very hard to adapt computer code for the Euler or Runge–Kutta method for first order equations to handle first order systems. We simply treat the dependent variable not as a number but as a vector. In many mathematical computer languages there is almost no distinction in syntax.

Subsection 7.1.4 Autonomous systems and vector fields

A system where the equations do not depend on the independent variable is called an autonomous system. For example the system y=2yx, y=x is autonomous as t is the independent variable but does not appear in the equations.
For autonomous systems we can draw the so-called direction field or vector field, a plot similar to a slope field, but instead of giving a slope at each point, we give a direction (and a magnitude). The previous example, x=2yx, y=x, says that at the point (x,y) the direction in which we should travel to satisfy the equations should be the direction of the vector (2yx,x) with the speed equal to the magnitude of this vector. So we draw the vector (2yx,x) at the point (x,y) and we do this for many points on the xy-plane. For example, at the point (1,2) we draw the vector (2(2)1,1)=(3,1), a vector pointing to the right and a little bit up, while at the point (2,1) we draw the vector (2(1)2,2)=(0,2) a vector that points straight up. When drawing the vectors, we will scale down their size to fit many of them on the same direction field. If we drew the arrows at the actual size, the diagram would be a jumbled mess once you would draw more than a couple of arrows. So we scale them all so that not even the longest one interferes with the others. We are mostly interested in their direction and relative size. See Figure 7.2.
We can draw a path of the solution in the plane. Suppose the solution is given by x=f(t), y=g(t). We pick an interval of t (say 0t2 for our example) and plot all the points (f(t),g(t)) for t in the selected range. The resulting picture is called the phase portrait (or phase plane portrait). The particular curve obtained is called the trajectory or solution curve. See an example plot in Figure 7.3. In the figure the solution starts at (1,0) and travels along the vector field for a distance of 2 units of t. We solved this system precisely, so we compute x(2) and y(2) to find x(2)2.475 and y(2)2.457. This point corresponds to the top right end of the plotted solution curve in the figure.
Figure 7.2. The direction field for x=2yx, y=x.
Figure 7.3. The direction field for x=2yx, y=x with the trajectory of the solution starting at (1,0) for 0t2.
Notice the similarity to the diagrams we drew for autonomous systems in one dimension. But note how much more complicated things become when we allow just one extra dimension.
We can draw phase portraits and trajectories in the xy-plane even if the system is not autonomous. In this case, however, we cannot draw the direction field, since the field changes as t changes. For each t we would get a different direction field.

Subsection 7.1.5 Picard’s theorem

Perhaps before going further, let us mention that Picard’s theorem on existence and uniqueness still holds for systems of ODE. Let us restate this theorem in the setting of systems. A general first order system is of the form
(7.1)x1=F1(x1,x2,,xn,t),x2=F2(x1,x2,,xn,t),xn=Fn(x1,x2,,xn,t).
That is, a unique solution exists for any initial condition given that the system is reasonable (Fj and its partial derivatives in the x variables are continuous). As for single equations we may not have a solution for all time t, but at least for some short period of time.
As we can change any nth order ODE into a first order system, then we notice that this theorem provides also the existence and uniqueness of solutions for higher order equations that we have until now not stated explicitly.

Subsection 7.1.6 Exercises

Exercise 7.1.2.

Find the general solution of x1=x2x1+t, x2=x2.

Exercise 7.1.3.

Find the general solution of x1=3x1x2+et, x2=x1.

Exercise 7.1.4.

Write ay+by+cy=f(x) as a first order system of ODEs.

Exercise 7.1.5.

Write x+y2yx3=sin(t), y+(x+y)2x=0 as a first order system of ODEs.

Exercise 7.1.6.

Suppose two masses on carts on frictionless surface are at displacements x1 and x2 as in Example 7.1.3. Suppose that a rocket applies force F in the positive direction on cart x1. Set up the system of equations.

Exercise 7.1.7.

Suppose the tanks are as in Example 7.1.2, starting both at volume V, but now the rate of flow from tank 1 to tank 2 is r1, and rate of flow from tank 2 to tank one is r2. Notice that the volumes are now not constant. Set up the system of equations.

Exercise 7.1.101.

Find the general solution to y1=3y1, y2=y1+y2, y3=y1+y3.
Answer.
y1=C1e3x, y2=y(x)=C2ex+C12e3x, y3=y(x)=C3ex+C12e3x

Exercise 7.1.102.

Solve y=2x, x=x+y, x(0)=1, y(0)=3.
Answer.
x=53e2t23et, y=53e2t+43et

Exercise 7.1.103.

Write x=x+t as a first order system.
Answer.
x1=x2, x2=x3, x3=x1+t

Exercise 7.1.104.

Write y1+y1+y2=t, y2+y1y2=t2 as a first order system.
Answer.
y3+y1+y2=t, y4+y1y2=t2, y1=y3, y2=y4

Exercise 7.1.105.

Suppose two masses on carts on frictionless surface are at displacements x1 and x2 as in Example 7.1.3. Suppose initial displacement is x1(0)=x2(0)=0, and initial velocity is x1(0)=x2(0)=a for some number a. Use your intuition to solve the system, explain your reasoning.
Answer.
x1=x2=at. Explanation of the intuition is left to reader.

Exercise 7.1.106.

Suppose the tanks are as in Example 7.1.2 except that clean water flows in at the rate s liters per second into tank 1, and brine flows out of tank 2 and into the sewer also at the rate of s liters per second.
  1. Draw the picture.
  2. Set up the system of equations.
  3. Intuitively, what happens as t goes to infinity, explain.
Answer.
a) Left to reader.     b) x1=rV(x2x1), x2=rVx1rsVx2.     c) As t goes to infinity, both x1 and x2 go to zero, explanation is left to reader.
For a higher quality printout use the PDF version: https://www.jirka.org/diffyqs/diffyqs.pdf