Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Equations of the form:

y+ay+by=0y'' + ay' + by = 0

come up often in chemical engineering, particularly in steady-state heat and mass diffusion, so it is important to know how to solve them!

Guess a solution y=eλxy=e^{\lambda x}, then substitute into the differential equation:

λ2eλx+a(λeλx)+beλx=0λ2+aλ+b=0\begin{align} \lambda^2 e^{\lambda x} + a (\lambda e^{\lambda x}) + b e^{\lambda x} &= 0\\ \lambda^2 + a \lambda + b &= 0 \end{align}

This characteristic polynomial has two roots λ1\lambda_1 and λ2\lambda_2, and the general solution for y is obtained by superposition of both.

We will consider an example of each case next.

Real distinct roots

To solve

y+y2y=0,y(0)=4,y(0)=5y'' + y' - 2y = 0, \quad y(0)=4, \quad y'(0)=-5

First write and solve the characteristic polynomial,

λ2+λ2=0(λ+2)(λ+1)=0\begin{align} \lambda^2 + \lambda -2 &= 0 \\ (\lambda + 2)(\lambda + 1) &= 0 \end{align}

so λ1=2\lambda_1 = -2 and λ2=1\lambda_2 =1. The general solution and its first derivative are:

y=c1e2x+c2exy=2c1e2x+c2ex\begin{align} y &= c_1 e^{-2x} + c_2 e^{x} \\ y'&= -2c_1 e^{-2x} + c_2 e^{x} \qquad \end{align}

So applying the initial conditions:

y(0)=c1+c2=4y(0)=2c1+c2=5\begin{align} y(0) &= c_1 + c_2 = 4 \\ y'(0) &= -2c_1 + c_2 = -5 \end{align}

These coefficients can be solved by Gauss-Jordan elimination:

[114215]R1+2R1[114033]R1÷3[114011]R2R1[103011]\begin{align} \begin{bmatrix} 1 & 1 & 4 \\ -2 & 1 & -5 \end{bmatrix} \begin{matrix}\vphantom{R_1} \\ +2 R_1 \end{matrix} &\to \begin{bmatrix} 1 & 1 & 4 \\ 0 & 3 & 3 \end{bmatrix} \begin{matrix}\vphantom{R_1} \\ \div 3 \end{matrix} \\ &\to \begin{bmatrix} 1 & 1 & 4 \\ 0 & 1 & 1 \end{bmatrix} \begin{matrix} -R_2 \\ \vphantom{R_1} \end{matrix} \\ &\to \begin{bmatrix} 1 & 0 & 3 \\ 0 & 1 & 1 \end{bmatrix} \end{align}

so c1=3c_1 = 3 and c2=1c_2 = 1. The final solution is:

y=3e2x+exy = 3 e^{-2x} + e^x

Complex roots

To solve:

y+0.4y+9.04y=0,y(0)=0,y(0)=3y'' + 0.4y' + 9.04y = 0, \quad y(0)=0, \quad y'(0)=3

Write and solve the characteristic polynomial,

λ2+0.4λ+9.04=0λ1,2=0.4±0.4249.042=0.2±3i\begin{align} \lambda^{2} &+ 0.4\lambda + 9.04 = 0 \\ \lambda_{1,2} &= \frac{-0.4\pm\sqrt{0.4^2- 4 \cdot 9.04}}{2} = -0.2\pm 3i \end{align}

Once values of λ\lambda are known, write out the general solution and plug in the first initial condition to solve for c1c_1.

y=e0.2x(c1cos3x+c2sin3x)y(0)=c1=0\begin{align} y &= e^{-0.2x}(c_1\cos3x + c_2\sin3x) \\ y(0) &= c_1 = 0 \end{align}

Hence the first term can be dropped from the solution. In order to solve for c2c_2, write out the derivative and plug in the second condition:

y=e0.2x(3c2cos3x)0.2e0.2xc2sin3xy(0)=3c2=3\begin{align} y' &= e^{-0.2x}(3c_2\cos3x) - 0.2e^{-0.2x}c_2\sin 3x \\ y'(0) &= 3c_2 = 3 \end{align}

Since c2=1c_2=1, the final solution is:

y=e0.2xsin3xy = e^{-0.2x}\sin 3x

Real repeated roots

To solve:

y+y+14y=0,y(0)=3,y(0)=72\begin{align} y'' + y' + \frac{1}{4}y=0, \quad y(0)=3, \quad y'(0)= -\frac{7}{2} \end{align}

Write and solve the characteristic polynomial,

λ2+λ+14=0(λ+12)2=0\begin{align} \lambda^2 + \lambda + \frac{1}{4} = 0 \\ \left(\lambda + \frac{1}{2}\right)^2 = 0 \end{align}

So λ=1/2\lambda = -1/2 is a real and repeated root. Write out the general equation and its derivative,

y=(c1+c2x)ex/2y=(c1+c2x)(12ex/2)+c2ex/2\begin{align} y &=(c_1 + c_2x)e^{-x/2} \\ y' &=(c_1 + c_2x)(-\frac{1}{2}e^{-x/2}) + c_2 e^{-x/2} \end{align}

Use the given conditions to solve for c1c_1 and c2c_2:

y(0)=c1=3y(0)=c12+c2=72c2=2\begin{align} y(0) &= c_1 = 3 \\ y'(0) &= -\frac{c_1}{2} + c_2 = -\frac{7}{2} \to c_2 = -2 \end{align}

The final solution is:

y=(32x)ex/2y = (3-2x)e^{-x/2}

Example: Spring and dashpot

We are analyzing how the drag force affects the spring oscilations. This is a mechanics example, but models like this are also used for the rheology of viscoelastic materials.

A mass m is attached to a Hookean spring with spring constant k and experiences a drag force as it moves with drag coefficient γ\gamma.

If x is the displacement of the spring, the governing equation for x is given by Newton’s equations:

mx+γx+kx=0m x'' + \gamma x' + k x = 0

The first term represents the acceleration of the mass, the second term is the drag force, and the third term is the spring force.

For what values of γ\gamma will the mass oscillate after it is stretched?


To answer this, first solve the roots of the characteristic polynomial for this second-order ODE:

mλ2+γλ+k=0λ1,2=γ±γ24mk2m\begin{align} &m \lambda^2 + \gamma \lambda + k = 0 \\ \lambda_{1,2} &= \frac{ -\gamma \pm \sqrt{\gamma^2 - 4mk}}{2m} \end{align}

You will only get oscillations if λ1,2\lambda_{1,2} is complex, which only occurs when γ2<4mk\gamma^2 < 4mk. In this case:

λ1,2=γ2m±i2m4mkγ2\lambda_{1,2} = -\frac{\gamma}{2m} \pm \frac{i}{2m}\sqrt{4mk - \gamma^2}

so the general solution for x is:

x(t)=exp(γ2mt)[c1cos(ωt)+c2sin(ωt)]x(t) = \exp\left(-\frac{\gamma}{2m} t \right) \left [ c_1 \cos(\omega t)+ c_2 \sin(\omega t) \right]

where ω=4mkγ2\omega = \sqrt{4mk - \gamma^2}. What does γ\gamma do to the solution?

Example: Steady-state reaction-diffusion

A first-order reaction is occuring in a liquid film of thickness L. The reactant concentration at x=0x = 0 is fixed to the bulk value c0c_0, while a solid substrate at x=Lx=L prevents any mass flux.

One-dimensional reaction-diffusion

At steady-state, the reactant concentration c can be modeled by:

Dd ⁣2cd ⁣x2kc=0,c(L)=c0,Dc(0)=0\begin{align} D \dd{2}{c}{x} -k c = 0, \quad c(L) = c_0, \quad -D c'(0) = 0 \end{align}

where D is the reactant’s diffusion coefficient and k is the reaction rate constant. Determine c(x)c(x).


First, rewrite in standard form:

ckDc=0c'' - \frac{k}{D} c = 0

The characteristic polynomial is

λ2kD=0λ=±kD\begin{align} \lambda^2 - \frac{k}{D} &= 0 \lambda &= \pm \sqrt{\frac{k}{D}} \end{align}

The general solution and its first derivative are:

c=a1exk/D+a2exk/Dc=a1kDexk/Da2kDexk/D\begin{align} c &= a_1 e^{x \sqrt{k/D}} + a_2 e^{-x\sqrt{k/D}} \\ c' &= a_1 \sqrt{\frac{k}{D}} e^{x \sqrt{k/D}} - a_2 \sqrt{\frac{k}{D}} e^{-x\sqrt{k/D}} \end{align}

Evaluating the boundary conditions:

c(0)=a1+a2=0c(L)=a1kDeLk/Da2kDeLk/D=0\begin{align} c(0) &= a_1 + a_2 = 0 \\ c'(L) &= a_1 \sqrt{\frac{k}{D}} e^{L \sqrt{k/D}} - a_2 \sqrt{\frac{k}{D}} e^{-L \sqrt{k/D}} = 0 \end{align}

This is a linear system of equations. Solving for a1a_1 and a2a_2 simultaneously gives

a1=c01+e2Lk/Da2=c01+e2Lk/Da_1 = \frac{c_0}{1+e^{2L\sqrt{k/D}}} \qquad a_2 = \frac{c_0}{1+e^{-2L\sqrt{k/D}}}

Thus,

c=c0(exk/D1+e2Lk/D+exk/D1+e2Lk/D)\begin{align} c = c_0\Biggl(\frac{e^{x\sqrt{k/D}}}{1+e^{2L\sqrt{k/D}}} +\frac{e^{x\sqrt{k/D}}}{1+e^{-2L\sqrt{k/D}}}\Biggr) \end{align}

Skill builder problems

Solve the following:

Solution to Exercise 1

Write and solve the characteristic polynomial:

λ22λ3=0(λ3)(λ+1)=0\begin{align} \lambda^2 - 2\lambda - 3 &= 0 \\ (\lambda - 3)(\lambda + 1) &= 0 \end{align}

so λ1=3\lambda_1 = 3 and λ2=1\lambda_2 = -1. The general solution and its first derivative are:

y=c1e3t+c2ety=3c1e3tc2et\begin{align} y &= c_1 e^{3t} + c_2 e^{-t} \\ y' &= 3c_1 e^{3t} - c_2 e^{-t} \end{align}

Apply the initial conditions:

y(0)=c1+c2=2y(0)=3c1c2=14\begin{align} y(0) &= c_1 + c_2 = 2\\ y'(0) &= 3c_1 - c_2 = 14 \end{align}

and solve the system for c1c_1 and c2c_2 using Gauss-Jordan elimination:

[1123114]R13R1[112048]R1÷4[112012]R2R2[104012]\begin{align} \begin{bmatrix} 1 & 1 & 2 \\ 3 & -1 & 14 \end{bmatrix} \begin{matrix}\vphantom{R_1} \\ -3 R_1 \end{matrix} &\to \begin{bmatrix} 1 & 1 & 2 \\ 0 & -4 & 8 \end{bmatrix} \begin{matrix}\vphantom{R_1} \\ \div -4 \end{matrix} \\ &\to \begin{bmatrix} 1 & 1 & 2 \\ 0 & 1 & -2 \end{bmatrix} \begin{matrix} -R_2 \\ \vphantom{R_2} \end{matrix} \\ &\to \begin{bmatrix} 1 & 0 & 4 \\ 0 & 1 & -2 \end{bmatrix} \end{align}

Therefore:

y=4e3t2ety = 4e^{3t} - 2e^{-t}
Solution to Exercise 2

Write and solve the characteristic polynomial:

λ2+2λ+1=0(λ+1)2=0\begin{align} \lambda^2 + 2\lambda + 1 &= 0 \\ (\lambda + 1)^2 &= 0 \end{align}

so λ=1\lambda = -1 (repeated root). The general solution and its first derivative are:

y=(c1+c2t)ety=(c1+c2t)(et)+c2et\begin{align} y &= (c_1 + c_2 t) e^{-t} \\ y' &= (c_1 + c_2 t)(-e^{-t}) + c_2 e^{-t} \end{align}

Apply the initial conditions:

y(0)=c1=4y(0)=c1+c2=6c2=2\begin{align} y(0) &= c_1 = 4\\ y'(0) &= -c_1 + c_2 = -6 \to c_2 = -2 \end{align}

Therefore:

y=(42t)et\begin{align} y = (4 - 2t)e^{-t} \end{align}
Solution to Exercise 3

Write and solve the characteristic polynomial:

10λ250λ+65=0λ1,2=50±5024106520=5±i2\begin{align} 10\lambda^2 - 50\lambda + 65 &= 0 \\ \lambda_{1,2} &= \frac{50 \pm \sqrt{50^2 - 4 \cdot 10 \cdot 65}}{20} \\ &= \frac{5 \pm i}{2} \end{align}

Since we have complex roots, the general solution and its first derivative are:

y=e5t2(c1cost2+c2sint2)y=e5t2(c12sint2+c22cost2)+52e5t2(c1cost2+c2sint2)\begin{align} y &= e^{\frac{5t}{2}} \left(c_1 \cos\frac{t}{2} + c_2 \sin\frac{t}{2} \right) \\ y' &= e^{\frac{5t}{2}} \Biggl( -\frac{c_1}{2} \sin\frac{t}{2} + \frac{c_2}{2} \cos\frac{t}{2} \Biggr) + \frac{5}{2}e^{\frac{5t}{2}} \Biggl( c_1 \cos\frac{t}{2} + c_2 \sin\frac{t}{2} \Biggr) \end{align}

Apply the initial conditions:

y(0)=c1=32y(0)=c22+52c1=32c2=92\begin{align} y(0) &= c_1 = \frac{3}{2} \\ y'(0) &= \frac{c_2}{2} + \frac{5}{2}c_1 = \frac{3}{2} \to c_2 = -\frac{9}{2} \end{align}

Therefore:

y=e5t2(32cost292sint2)\begin{align} y = e^{\frac{5t}{2}} \left( \frac{3}{2} \cos\frac{t}{2} - \frac{9}{2} \sin\frac{t}{2} \right) \end{align}
Solution to Exercise 4

Write and solve the characteristic polynomial:

λ2+πλ=0λ(λ+π)=0\begin{align} \lambda^2 + \pi\lambda &= 0 \\ \lambda(\lambda + \pi) &= 0 \end{align}

so λ1=0\lambda_1 = 0 and λ2=π\lambda_2 = -\pi. The general solution and its first derivative are:

y=c1+c2eπty=c2πeπt\begin{align} y &= c_1 + c_2 e^{-\pi t} \\ y' &= -c_2 \pi e^{-\pi t} \end{align}

Apply the initial conditions:

y(0)=c1+c2=3y(0)=c2π=π\begin{align} y(0) &= c_1 + c_2 = 3 \\ y'(0) &= -c_2 \pi = -\pi \end{align}

so c1=2c_1 = 2 and c2=1c_2 = 1. Therefore:

y=2+eπty = 2 + e^{-\pi t}