## Section2.4Solving Systems Analytically

Mixing problems model how substances flow back and forth between two or more compartments. These problems often arise in applications—for example, we might want to model how greenhouse gases flow back and forth between different layers of the earth's atomosphere, how chemicals move between tanks in a refinery or a brewery, or how pollutants move between a series of lakes or ponds. Systems of differential equations can prove very useful when it comes to modeling such situations.

### Subsection2.4.1Partially Coupled Systems

We will use linear systems of differential equations such as

\begin{align*} \frac{dx}{dt} & = ax + by\\ \frac{dy}{dt} & = cx + dy \end{align*}

to illustrate how we can use systems of differential equations to model how substances flow back and forth between two or more compartments. Suppose that we have two tanks ($$A$$ and $$B$$) between which a mixture of brine flows (Figure 2.4.1). Tank $$A$$ contains 300 liters of water in which 100 kilograms of salt has been dissolved and Tank $$B$$ contains 300 liters of pure water. Fresh water is pumped into Tank $$A$$ at the rate of 500 liters per hour, and brine is pumped into Tank $$B$$ from Tank $$A$$ at the rate of 500 liters per hour. Brine is also drained at a rate 500 liters of brine per hour from Tank $$B\text{.}$$ All brine mixtures are well-stirred. If we let $$x = x(t)$$ be the amount of salt in Tank $$A$$ at time $$t$$ and $$y = y(t)$$ be the amount of salt in Tank $$B$$ at time $$t\text{,}$$ then we know that

\begin{align*} x(0) & = 100\\ y(0) & = 0 \end{align*}

We know that the salt concentrations in the two tanks are $$x/300$$ kilograms per liter and $$y/300$$ kilograms per liter. Thus, we can describe the rate of change in each tank with a differential equation,

\begin{align*} \frac{dx}{dt} & = - 500 \cdot \frac{x}{300} = - \frac{5}{3} x,\\ \frac{dy}{dt} & = 500 \cdot \frac{x}{300} - 500 \cdot \frac{y}{300} = \frac{5}{3} x - \frac{5}{3} y. \end{align*} Figure 2.4.1. Mixing example with two tanks

We can now ask how we might solve the system of equations

\begin{align*} \frac{dx}{dt} & = - \frac{5}{3} x,\\ \frac{dy}{dt} & = \frac{5}{3} x - \frac{5}{3} y. \end{align*}

The task of solving the system

\begin{align*} \frac{dx}{dt} & =f(x,y),\\ \frac{dy}{dt} & = g(x,y), \end{align*}

may be quite difficult or even impossible. However, we can find solutions in certain cases. For example, if we have a system of the form

\begin{align*} \frac{dx}{dt} & =f(x),\\ \frac{dy}{dt} & = g(y), \end{align*}

then each equation is an autonomous first-order equation. To solve our system, we only need to solve two first-order equations. Such a system is said to be decoupled. Generalizing slightly, we say that a partially coupled system is a system of the form

\begin{align*} \frac{dx}{dt} & =f(x),\\ \frac{dy}{dt} & = g(x, y). \end{align*}

Since the first equation is an autonomous first-order equation in $$x\text{,}$$ we can solve this equation separately, and substitute our solution into the second equation.

Consider the system

\begin{align*} \frac{dx}{dt} & = x \\ \frac{dy}{dt} & = x + y. \end{align*}

We can easily solve the first equation, $$dx/dt = x\text{,}$$ to obtain $$x = a e^t\text{.}$$ Using this information in the second equation, we have

\begin{equation*} \frac{dy}{dt} - y = a e^t \end{equation*}

which is a first-order linear equation. This equation has an integrating factor $$\mu(t) = e^{-t}\text{,}$$ and

\begin{equation*} \frac{d}{dt} (e^{-t} y) = \mu(t) \left(\frac{dy}{dt} - y \right)= a e^t \mu(t) = a. \end{equation*}

Therefore, the solution to our second equation is

\begin{equation*} y(t) = at e^t + be^t. \end{equation*}

Revisiting the mixing problem that we posed at the beginning of this section, we have the following initial value problem,

\begin{align*} \frac{dx}{dt} & = - \frac{5}{3} x,\\ \frac{dy}{dt} & = \frac{5}{3} x - \frac{5}{3} y.\\ x(0) & = 100,\\ y(0) & = 0. \end{align*}

Solving $$dx/dt = - (5/3) x$$ is easy. We can quickly determine that $$x(t) = c_1 e^{-5t/3}\text{.}$$ Applying the initial condition $$x(0) = 100\text{,}$$ we can determine that $$c_1 = 100$$ and $$x(t) = 100 e^{-5t/3}\text{.}$$ Our second equation now becomes

\begin{equation*} \frac{dy}{dt} = \frac{5}{3} x - \frac{5}{3} y = \frac{500}{3} e^{-5t/3} - \frac{5}{3} y. \end{equation*}

This last equation is a first-order linear equation

\begin{equation*} \frac{dy}{dt} + \frac{5}{3} y = \frac{500}{3} e^{-5t/3}. \end{equation*}

Multiplying both sides of this last equation by the integrating factor $$\mu(t) = e^{5t/3}$$ yields

\begin{equation*} \frac{d}{dt} (e^{5t/3}y) = e^{5t/3}\frac{dy}{dt} + e^{5t/3}\frac{5}{3} y = \frac{500}{3}. \end{equation*}

Integrating both sides of this last equation gives us

\begin{equation*} e^{5t/3}y = \frac{500}{3} t + c_2. \end{equation*}

Using our initial condition $$y(0) = 0\text{,}$$ we can determine that $$c_2 = 0\text{.}$$ Thus,

\begin{equation*} y = \frac{500}{3} t e^{-5t/3} \end{equation*}

Consider the partially coupled system

\begin{align*} x' & = 2x\\ y' & = x + 3y \end{align*}

Notice that we already have the tools to solve $$x' = 2x\text{.}$$ In fact, the solution is $$x(t) = c_1 e^{2t}\text{.}$$ We can use this information to solve the second equation, $$y' = x + 3y\text{.}$$ That is, if we use the fact that $$x(t) = c_1 e^{2t}\text{,}$$ the second equation becomes

\begin{equation*} y' = c_1 e^{2t} + 3y. \end{equation*}

We can rewrite this equation as

\begin{equation*} y' - 3y = c_1 e^{2t}, \end{equation*}

which is a first-order linear equation. If we multiply both sides of the equation by $$\mu(t) = e^{-3t}\text{,}$$ we have

\begin{equation*} \frac{d}{dt}\left( e^{-3t}y \right) = e^{-3t}y' - 3e^{-3t}y = c_1 e^{-t}. \end{equation*}

Integrating, we have

\begin{equation*} e^{-3t}y = - c_1 e^{-t} + c_2. \end{equation*}

Solving for $$y\text{,}$$ yields $$y = - c_1 e^{2t} + c_2e^{3t}\text{.}$$ Thus the solution to our system is

\begin{align*} x & = c_1 e^{2t}\\ y & = - c_1 e^{2t} + c_2e^{3t}. \end{align*}

#### Activity2.4.1.Solving Partially Coupled Systems.

Solve each of the following systems of differential equations.

##### (a)
\begin{align*} x' & = -x\\ y' & = x - 3y \end{align*}
##### (b)
\begin{align*} x' & = -x - y\\ y' & = - 3y \end{align*}
##### (c)
\begin{align*} x' & = 2x\\ y' & = 3x + 2y \end{align*}
##### (d)
\begin{align*} x' & = 3x + 4y\\ y' & = -2y \end{align*}

### Subsection2.4.2Using Sage to Solve Linear Systems

Solving linear systems such as

\begin{align*} x' & = ax + by\\ y' & = cx + dy \end{align*}

is much more difficult, since we cannot use the same strategies that we used to solve partially-coupled systems. We will devote all of Chapter 3 to finding an answer. However, we can use Sage to solve linear systems for the moment. The following is a Sage interact that will solve the initial value problem

\begin{align*} x' & = 3x - 2y\\ y' & = x + y\\ x(0) \amp = 1\\ y(0) \amp = 1; \end{align*}

however, we can change the coefficients and initial values to be anything that we like.

### Subsection2.4.3Harmonic Oscillators

The equation

\begin{equation*} \frac{d^2 x}{dt^2} + 3 \frac{dx}{dt} + 2 x = 0 \end{equation*}

is a specific case of a damped harmonic oscillator, where $$m = 1\text{,}$$ the spring constant is 2, and the damping constant is 3. We can rewrite this equation as a first-order linear system,

\begin{align*} \frac{dx}{dt} & = v,\\ \frac{dv}{dt} & = - 2x - 3v. \end{align*}

Suppose that $$x(0) = 0$$ is the initial position of the mass and $$v(0) = 1$$ is the initial velocity. We can use Sage to verify that the solution to our system is

\begin{align*} x(t) & = e^{-t} - e^{-2t},\\ v(t) & = - e^{-t} + 2 e^{-2t}. \end{align*}

This is an example of an over-damped harmonic oscillator (Figure 2.4.4). In other words, a spring-mass system that is modeled by this system of equations has so much damping that the mass will not oscillate.

t = var('t')
x = function('x')(t)
v = function('v')(t)
t_start = 0
x_start = 0
v_start =  1
de1 = diff(x,t) == v
de2 = diff(v,t) == -2*x - 3*v
sol = desolve_system([de1, de2], [x,v], ics=[t_start, x_start, v_start])
sol.show()
sol.show() Figure 2.4.4. An over-damped harmonic oscillator

Now let us relax the damping and increase the spring constant on our harmonic oscillator,

\begin{equation*} \frac{d^2 x}{dt^2} + 2 \frac{dx}{dt} + 10 x = 0. \end{equation*}

The corresponding linear system is

\begin{align*} \frac{dx}{dt} & = v,\\ \frac{dv}{dt} & = - 10x - 2v\\ x(0) \amp = 0\\ v(0) \amp = 1. \end{align*}

Notice that our initial conditions have not changed. We again use Sage to solve our system.

t = var('t')
x = function('x')(t)
v = function('v')(t)
t_start = 0
x_start = 0
v_start =  1
de1 = diff(x,t) == v
de2 = diff(v,t) == -10*x - 2*v
sol = desolve_system([de1, de2], [x,v], ics=[t_start, x_start, v_start])
sol.show()
sol.show()


The solution to our system is

\begin{align*} x(t) & = \frac{1}{3} e^{-t} \sin 3t,\\ v(t) & = e^{-t} \cos 3t - \frac{1}{3} e^{-t} \sin 3t. \end{align*}

Notice that the system oscillates due to the sine and cosine terms in the solution. This system is underdamped (Figure 2.4.5). Figure 2.4.5. An under-damped harmonic oscillator

### Subsection2.4.4Important Lessons

• A system of the form

\begin{align*} \frac{dx}{dt} & =f(x)\\ \frac{dy}{dt} & = g(y) \end{align*}

is said to be decoupled. Such a system can be solved by solving each equation independently.

• A system of the form

\begin{align*} \frac{dx}{dt} & =f(x),\\ \frac{dy}{dt} & = g(x, y) \end{align*}

is a partially coupled system. Since the first equation is an autonomous first-order equation in $$x\text{,}$$ we can solve this equation separately, and substitute our solution into the second equation.

• We can use Sage to solve systems of the form

\begin{align*} x' & = ax + by\\ y' & = cx + dy. \end{align*}
• Sage is useful for investigating the behavior of harmonic oscillators.

#### 1.

Explain what a partially coupled system is?

#### 2.

Why would you expect that it is impossible to find explicit solutions for most systems of differential equations?

### Exercises2.4.6Exercises

#### 1.

Solve each of the following partially coupled systems.

1. \begin{align*} x' & = 2x\\ y' & = x + 2y \end{align*}
2. \begin{align*} x' & = -x + 3y\\ y' & = -2y \end{align*}
3. \begin{align*} x' & = -3x\\ y' & = 2x + 3y \end{align*}
4. \begin{align*} x' & = 2x - 3y\\ y' & = 4y \end{align*}

#### 2.

Suppose that we have two tanks ($$A$$ and $$B$$) between which a mixture of brine flows. Tank $$A$$ contains 200 liters of water in which 20 kilograms of salt has been dissolved and Tank $$B$$ contains 200 liters of water in which 10 kilograms of salt has been dissolved. Fresh water is pumped into Tank $$A$$ at the rate of 200 liters per hour, and brine is pumped into Tank $$B$$ from Tank $$A$$ at the rate of 200 liters per hour. Brine is also drained at a rate 200 liters of brine per hour from Tank $$B\text{.}$$ All brine mixtures are well-stirred. Find the amount of salt in each tank at time $$t\text{.}$$

#### 3.

For each of the following harmonic oscillators (1) rewrite the second-order initial value problem as a system of two first-order linear equations, (2) use Sage to solve the system of linear equations, and (3) classify the harmonic oscillator as underdamped, critically damped, or overdamped.

1. \begin{align*} y'' + 7y' + 6y & = 0\\ y(0) & = 1\\ y'(0) & = 0 \end{align*}
2. \begin{align*} y'' + 4y' + 5y & = 0\\ y(0) & = 1\\ y'(0) & = 0 \end{align*}
3. \begin{align*} y'' + 6y' + 9y & = 0\\ y(0) & = 1\\ y'(0) & = 0 \end{align*}
You have attempted of activities on this page.