Systems of ODEs

Mixing problem revisited

two tanks.

  • fresh water enters tank 1 at \( 200\text{ L/hr} \)
  • well-mixed solution leaves tank 1 and enters tank 2 at \( 200\text{ L/hr} \)
  • well-mixed solution leaves tank 2 and enters tank 1 at \( 100\text{ L/hr} \)
  • each tank also drains \( 100\text{ L/hr} \)
  • tank 1 starts with \( 3\text{ kg} \) of salt
  • tank 2 starts with none.

goal: amount of salt in each tank.

fresh water, 200 L/hr 1 2 200 L/hr 100 L/hr 100 L/hr 100 L/hr
Figure: Two-tank coupled mixing system
Detailed description
Schematic diagram of two cylindrical tanks labeled \( 1 \) and \( 2 \). Fresh water enters the top of tank \( 1 \) at \( 200\text{ L/hr} \). An upper pipe carries solution from tank \( 1 \) to tank \( 2 \) at \( 200\text{ L/hr} \), and a lower pipe returns solution from tank \( 2 \) to tank \( 1 \) at \( 100\text{ L/hr} \). Bottom drain pipes exit both tank \( 1 \) and tank \( 2 \), each removing solution at \( 100\text{ L/hr} \).

each tank starts w/ \( 100\text{ L} \)

Physical Intuition and ODE Setup

let's try to guess \( x_1(t) \) and \( x_2(t) \) (salt in each tank)

x₁ t
Figure: Expected behavior of \( x_1(t) \)
Detailed description
A qualitative plot of \( x_1 \) versus \( t \). The curve starts at a positive point on the vertical \( x_1 \)-axis (representing \( 3\text{ kg} \) of salt at \( t = 0 \)) and decreases monotonically, curving asymptotically toward the horizontal \( t \)-axis as \( t \) increases.
x₂ t
Figure: Expected behavior of \( x_2(t) \)
Detailed description
A qualitative plot of \( x_2 \) versus \( t \). The curve starts at the origin \( (0, 0) \), rises smoothly to a single positive maximum, and then decreases asymptotically toward the horizontal \( t \)-axis.

what's not clear from the physical intuition is when \( x_2 \) reaches max, for example

let's set up the ODEs for each tank: \( \frac{dx}{dt} = (\text{rate in}) - (\text{rate out}) \)

\[ \frac{dx_1}{dt} = \left( \frac{x_2}{100} \right) \left( 100\text{ L/hr} \right) - \left( \frac{x_1}{100} \right) \left( 300\text{ L/hr} \right) \]

where:

  • \( \frac{x_2}{100} \): concentration in tank 2
  • \( 100\text{ L/hr} \): flow rate entering tank 1 from tank 2
  • \( 300\text{ L/hr} \): total outflow rate from tank 1 (\( 200 \) to tank 2, \( 100 \) drain)
\[ \frac{dx_2}{dt} = \left( \frac{x_1}{100} \right)(200) - \left( \frac{x_2}{100} \right)(200) \]

where:

  • \( 200 \) (outflow from tank 2): \( 100 \) to tank 1, \( 100 \) drain

Matrix Form of First-Order Systems

\[ \begin{aligned} x_1' &= -3x_1 + x_2 \\ x_2' &= 2x_1 - 2x_2 \end{aligned} \]

this is a system of two 1st-order ODEs

they are coupled \( \to \) each depends on the other (solving \( x_1 \) needs \( x_2 \) and vice versa)

in the matrix form:

\[ \begin{bmatrix} x_1' \\ x_2' \end{bmatrix} = \begin{bmatrix} -3 & 1 \\ 2 & -2 \end{bmatrix} \begin{bmatrix} x_1 \\ x_2 \end{bmatrix} \]

or

\[ \vec{x}' = A\vec{x} \]

in general we may have nonhomogeneous terms

so we can have \( \vec{x}' = A\vec{x} + \vec{g}(t) \)

notice its similarity to \( y' = ay + g(t) \)

Converting Higher-Order ODEs to First-Order Systems

every higher-order eq. is actually a system of 1st-order eqs.

for example, \( mu'' + cu' + ku = f(t) \)

k c m f(t)
Figure: Forced mass-spring-damper system
Detailed description
Diagram of a mass \( m \) suspended from a fixed horizontal support by a spring with constant \( k \) on the left and a damper with damping coefficient \( c \) on the right. An upward arrow below the mass indicates the external forcing function \( f(t) \).

define:

  • \( x_1 = u \) (position)
  • \( x_2 = u' \) (velocity)

these are called state variables

then \( x_1' = x_2 \) (by definition)

\[ \begin{aligned} x_2' = u'' &= -\frac{k}{m} u - \frac{c}{m} u' + \frac{f(t)}{m} \\ &= -\frac{k}{m} x_1 - \frac{c}{m} x_2 + \frac{f(t)}{m} \end{aligned} \]

or

\[ \begin{bmatrix} x_1' \\ x_2' \end{bmatrix} = \begin{bmatrix} 0 & 1 \\ -k/m & -c/m \end{bmatrix} \begin{bmatrix} x_1 \\ x_2 \end{bmatrix} + \begin{bmatrix} 0 \\ f(t)/m \end{bmatrix} \] \[ \vec{x}' = A\vec{x} + \vec{g}(t) \]

Third-Order ODE Example

let's try \( y''' - 2y'' + y' - 4y = \sin(t) \)

define:

  • \( x_1 = y \)
  • \( x_2 = y' \)
  • \( x_3 = y'' \)

3rd-order \( \to \) 3 state variables

\[ \begin{aligned} x_1' &= x_2 \\ x_2' &= x_3 \\ x_3' &= y''' = 4y - y' + 2y'' + \sin(t) \\ &= 4x_1 - x_2 + 2x_3 + \sin(t) \end{aligned} \] \[ \vec{x}' = \begin{bmatrix} 0 & 1 & 0 \\ 0 & 0 & 1 \\ 4 & -1 & 2 \end{bmatrix} \vec{x} + \begin{bmatrix} 0 \\ 0 \\ \sin(t) \end{bmatrix} \]

Qualitative Analysis and Phase Plane

before solving \( \vec{x}' = A\vec{x} \), let's try to qualitatively understand the solution w/o solving it.

tank example: \( \vec{x}' = \begin{bmatrix} -3 & 1 \\ 2 & -2 \end{bmatrix} \vec{x} \)

graph the direction of \( \vec{x}' \) for each given \( \vec{x} \) on the phase plane (\( x_1 \) vs \( x_2 \))

x₁ x₂ 1 -1 1 -1
Figure: Hand-sketched phase plane directions
Detailed description
A coordinate plane with horizontal axis \( x_1 \) and vertical axis \( x_2 \), marked at \( -1 \) and \( 1 \) on each axis. Direction arrows are drawn at \( (1,0) \) pointing up-left, at \( (0,1) \) pointing down-right, at \( (-1,0) \) pointing down-right, and at \( (0,-1) \) pointing up-left. Additional sample arrows appear at \( (1,1) \) pointing left, \( (-1,1) \) pointing down-right, \( (-1,-1) \) pointing right, and \( (1,-1) \) pointing up-left.

at \( \vec{x} = \begin{bmatrix} 1 \\ 0 \end{bmatrix} \), \( \vec{x}' = \begin{bmatrix} -3 & 1 \\ 2 & -2 \end{bmatrix} \begin{bmatrix} 1 \\ 0 \end{bmatrix} = \begin{bmatrix} -3 \\ 2 \end{bmatrix} \)

at \( \vec{x} = \begin{bmatrix} 0 \\ 1 \end{bmatrix} \), \( \vec{x}' = \begin{bmatrix} 1 \\ -2 \end{bmatrix} \)

\( \vdots \)

Phase Plane Direction Field and Solution Curve

\[ x_1' = -3x_1 + x_2, \quad x_2' = 2x_1 - 2x_2 \]
-4 -3 -2 -1 0 1 2 3 4 x₁ 4 3 2 1 0 -1 -2 -3 -4 x₂
Figure: Phase portrait and solution trajectory
Detailed description
A direction field on the \( x_1 x_2 \)-plane over \( [-4, 4] \times [-4, 4] \) for \( x_1' = -3x_1 + x_2 \) and \( x_2' = 2x_1 - 2x_2 \). Two straight-line trajectories pass through the origin: a red line along \( x_2 = -x_1 \) and a green line along \( x_2 = 2x_1 \), both with field arrows pointing toward the origin \( (0,0) \). A solid black solution curve starts at the initial condition \( (3, 0) \), moves upward and to the left to a peak near \( (0.95, 0.95) \), and curves smoothly into the origin tangent to the green line \( x_2 = 2x_1 \).

black curve is the solution curve for our tank example

  • \( x_1(0) = 3 \)
  • \( x_2(0) = 0 \)

\( x_1 \) decays as we expected

\( x_2 \) increases then decays

Solving by Elimination

\[ \begin{aligned} x_1' &= -3x_1 + x_2 \\ x_2' &= 2x_1 - 2x_2 \end{aligned} \]

this is also a 2nd-order eq.

let's try solving it as one

eq 1 \( \to x_2 = x_1' + 3x_1 \) so \( x_2' = x_1'' + 3x_1' \) sub into eq. 2

\[ \begin{aligned} x_1'' + 3x_1' &= 2x_1 - 2(x_1' + 3x_1) \\ x_1'' + 5x_1' + 4x_1 &= 0 \end{aligned} \]

\( r^2 + 5r + 4 = 0 \to r = -1, \; r = -4 \)

\[ \begin{aligned} x_1 &= c_1 e^{-t} + c_2 e^{-4t} \\ x_2 &= x_1' + 3x_1 \\ x_2 &= 2c_1 e^{-t} - c_2 e^{-4t} \end{aligned} \]

Back into Matrix Form

back into matrix form

\[ \vec{x} = c_1 \begin{bmatrix} 1 \\ 2 \end{bmatrix} e^{-t} + c_2 \begin{bmatrix} 1 \\ -1 \end{bmatrix} e^{-4t} \]

where:

  • \( \begin{bmatrix} 1 \\ 2 \end{bmatrix} \): green line on the phase direction field
  • \( \begin{bmatrix} 1 \\ -1 \end{bmatrix} \): red line

exponents of exponentials: \( -1, \; -4 \) from \( r^2 + 5r + 4 = 0 \)

guess how \( \begin{bmatrix} 1 \\ 2 \end{bmatrix}, \; \begin{bmatrix} 1 \\ -1 \end{bmatrix}, \; -1, \; -4 \) are related to coefficient matrix \( \begin{bmatrix} -3 & 1 \\ 2 & -2 \end{bmatrix} \)?

eigenvalues and eigenvectors?

YES!

why? continue next time