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.

This section focuses on analytical solutions for initial-value problems, meaning problems where we know the values of y(t)y(t) and dydt\frac{dy}{dt} at t=0t=0 (or y(x)y(x) and dydx\frac{dy}{dx} at x=0x=0): y(0)y(0) and y(0)y^{\prime}(0).

Equations with constant coefficents

A common category of 2nd-order homogeneous ODEs are equations with constant coefficients, of the form:

y+ay+by=0y^{\prime\prime} + a y^{\prime} + by = 0

Note that these are unforced, and the right-hand side is zero.

Solutions to these equations take the form y(x)=eλxy(x) = e^{\lambda x}, and inserting this into the ODE gives us the characteristic equation

λ2+aλ+b=0\lambda^2 + a \lambda + b = 0

which we can solve to find the solution for given coefficients aa and bb and initial conditions. Depending on those coefficients and the solution to the characteristic equation, our solution can fall into one of three cases:

  • Real roots: λ1\lambda_1 and λ2\lambda_2. This is an overdamped system and the full solution takes the form

y(x)=c1eλ1x+c2eλ2xy(x) = c_1 e^{\lambda_1 x} + c_2 e^{\lambda_2 x}
  • Repeated roots: λ1=λ2=λ\lambda_1 = \lambda_2 = \lambda. This is a critically damped system and the full solution is

y(x)=c1eλx+c2xeλxy(x) = c_1 e^{\lambda x} + c_2 x e^{\lambda x}

(Where does that second part come from, you might ask? Well, we know that y1y_1 is eλxe^{\lambda x}, but the second part cannot also be eλxe^{\lambda x} because those are linearly dependent. So, we use reduction of order to find y2y_2, which is xeλxx e^{\lambda x}.

  • Imaginary roots: λ=a2±βi\lambda = \frac{-a}{2} \pm \beta i, where β=124ba2\beta = \frac{1}{2} \sqrt{4b - a^2}. This is an underdamped system and the solution takes the form

y(x)=eax/2(c1sinβx+c2cosβx)y(x) = e^{-ax/2} \left( c_1 \sin \beta x + c_2 \cos \beta x \right)

Some examples:

  1. y+3y+2y=0y^{\prime\prime} + 3 y^{\prime} + 2y = 0

λ2+3λ+2=0(λ+2)(λ+1)=0λ=2,1y(x)=c1ex+c2e2x\begin{align} \rightarrow \lambda^2 + 3\lambda + 2 &= 0 \\ (\lambda + 2)(\lambda + 1) &= 0 \\ \lambda &= -2, -1 \\ y(x) &= c_1 e^{-x} + c_2 e^{-2x} \end{align}

Then, we would use the initial conditions given for y(0)y(0) and y(0)y^{\prime}(0) to find c1c_1 and c2c_2.

  1. y+6y+9y=0y^{\prime\prime} + 6 y^{\prime} + 9y = 0

λ2+6λ+9=0(λ+3)(λ+3)=0λ=3y(x)=c1e3x+c2xe3x\begin{align} \rightarrow \lambda^2 + 6\lambda + 9 &= 0 \\ (\lambda + 3)(\lambda + 3) &= 0 \\ \lambda &= -3 \\ y(x) &= c_1 e^{-3x} + c_2 x e^{-3x} \end{align}
  1. y+6y+25y=0y^{\prime\prime} + 6 y^{\prime} + 25 y = 0

λ2+6λ+25=0λ=3±4iy(x)=e3x(c1sin4x+c2cos4x)\begin{align} \rightarrow \lambda^2 + 6\lambda + 25 &= 0 \\ \lambda &= -3 \pm 4i \\ y(x) &= e^{-3x} \left( c_1 \sin 4x + c_2 \cos 4x \right) \end{align}

Euler-Cauchy equations

Euler-Cauchy equations are of the form

x2y+axy+by=0x^2 y^{\prime\prime} + axy^{\prime} + by = 0

Solutions take the form y=xmy = x^m, which when plugged into the ODE leads to a different characterisic equation to find mm:

y=xmy=mxm1y=m(m1)xm2x2m(m1)xm2+axmxm1+bxm=0m2+(a1)m+b=0\begin{align} y &= x^m \\ y^{\prime} &= m x^{m-1} \\ y^{\prime\prime} &= m (m-1) x^{m-2} \\ \rightarrow x^2 m (m-1) x^{m-2} + axmx^{m-1} + bx^m &= 0 \\ m^2 + (a-1)m + b &= 0 \end{align}

This is our new characteristic formula for these problems, and solving for the roots of this equation gives us mm and thus our general solution.

Like equations with constant coefficients, we have three solution forms depending on the roots of the characteristic equation:

  • Real roots: y(x)=c1xm1+c2xm2y(x) = c_1 x^{m_1} + c_2 x^{m_2}

  • Repeated roots: y(x)=c1xm+c2xmlnxy(x) = c_1 x^m + c_2 x^m \ln x

  • Imaginary roots: m=α±βim = \alpha \pm \beta i, and y(x)=xα[c1cos(βlnx)+c2sin(βlnx)]y(x) = x^{\alpha} \left[c_1 \cos (\beta \ln x) + c_2 \sin (\beta \ln x)\right]

Inhomogeneous 2nd-order ODEs

Inhomogeneous, or forced, 2nd-order ODEs with constant coefficients take the form

y+ay+by=F(t)y^{\prime\prime} + a y^{\prime} + by = F(t)

with initial conditions y(0)=y0y(0) = y_0 and y(0)=y0y^{\prime}(0) = y_0^{\prime}. Depending on the form of the forcing function F(t)F(t), we can solve with techniques such as

  • the method of undetermined coefficients

  • variation of parameters

  • LaPlace transforms

The solution in general to inhomogeneous ODEs includes two parts:

y(t)=yH+yIH=c1y1+c2y2+yIH  ,y(t) = y_{\text{H}} + y_{\text{IH}} = c_1 y_1 + c_2 y_2 + y_{\text{IH}} \;,

where yHy_{\text{H}} is the solution from the equivalent homogeneous ODE y+ay+by=0y^{\prime\prime} + a y^{\prime} + b y = 0.

The forcing function F(t)F(t) may be

  • continuous

  • periodic

  • aperiodic/discontinuous

Continuous F(t)F(t): method of undetermined coefficients

For continuous forcing functions, we have two solution methods: the method of undetermined coefficients, and variation of parameters.

Generally you’ll want to use the method of undetermined coefficients when possible, which depends on if F(t)F(t) matches one of a set of functions. In that case, the form of the inhomogeneous solution yIH(t)y_{\text{IH}}(t) follows that of the forcing function F(t)F(t), with one or more unknown constants:

F(t)F(t)yIH(t)y_{\text{IH}}(t)
constantKK
cosωt\cos \omega tK1cosωt+K2sinωtK_1 \cos \omega t + K_2 \sin \omega t
sinωt\sin \omega tK1cosωt+K2sinωtK_1 \cos \omega t + K_2 \sin \omega t
eate^{-at}KeatK e^{-at}
(A)t(A) tK0+K1tK_0 + K_1 t
tnt^nK0+K1t+K2t2++KntnK_0 + K_1 t + K_2 t^2 + \ldots + K_n t^n

For combinations of these functions, we can combine functions; for example, given

F(t)=eatcosωtoreatsinωtyIH=K1eatcosωt+K2eatsinωt\begin{align} F(t) &= e^{-at} \cos \omega t \quad \text{or} e^{-at} \sin \omega t \\ y_{\text{IH}} &= K_1 e^{-at} \cos \omega t + K_2 e^{-at} \sin \omega t \end{align}

(Note how in all the above cases how the inhomogeneous solution follows the functional form of the forcing function; for example, the exponential decay rate aa or the sinusoidal frequency ω\omega match.

The method of undetermined coefficients works by plugging the candidate inhomogeneous solutionn yIHy_{\text{IH}} into the full ODE, and solving for the constants (e.g., KK)—but not from the initial conditions.

For example, let’s solve

y+2y+y=exy^{\prime\prime} + 2y^{\prime} + y = e^{-x}

with initial conditions y(0)=y(0)=0y(0) = y^{\prime}(0) = 0. First, we should find the solution to the homogeneous equation

y+2y+y=0  .y^{\prime\prime} + 2y^{\prime} + y = 0 \;.

We can do this by using the associated characteristic formula

λ2+2λ+1=0(λ+1)(λ+1)=0yH=c1ex+c2xex\begin{align} \lambda^2 + 2 \lambda + 1 &= 0 \\ (\lambda + 1)(\lambda + 1) &= 0 \\ \rightarrow y_{\text{H}} &= c_1 e^{-x} + c_2 x e^{-x} \end{align}

To find the inhomogeneous solution, we would look at the table above to find what matches the forcing function exe^{-x}. Normally, we’d grab KexK e^{-x}, but that would not be linearly independent from the first part of the homogeneous solution yHy_{\text{H}}. The same is true for KxexK x e^{-x}, which is linearly dependent with the second part of yHy_{\text{H}}, but Kx2exK x^2 e^{-x} works! Then, we just need to find KK by plugging this into the ODE:

yIH=Kx2exy=Kex(2xx2)y=Kex(x24x+2)2K=1K=12yIH=12x2ex\begin{align} y_{\text{IH}} &= K x^2 e^{-x} \\ y^{\prime} &= K e^{-x} (2x - x^2) \\ y^{\prime\prime} &= K e^{-x} (x^2 - 4x + 2) \\ 2 K &= 1 \\ \rightarrow K &= \frac{1}{2} \\ y_{\text{IH}} &= \frac{1}{2} x^2 e^{-x} \end{align}

Thus, the overall general solution is

y(x)=c1ex+c2xex+12x2exy(x) = c_1 e^{-x} + c_2 x e^{-x} + \frac{1}{2} x^2 e^{-x}

and we would solve for the integration constants c1c_1 and c2c_2 using the initial conditions.

Important points to remember:

  • The constants of the inhomogeneous solution yIHy_{\text{IH}} come from the ODE, not the initial conditions.

  • Only solve for the integration constants c1c_1 and c2c_2 (part of the homogeneous solution) once you have the full general solution y=c1y1+c2y2+yIHy = c_1 y_1 + c_2 y_2 + y_{\text{IH}}.

Continuous F(t)F(t): variation of parameters

We have the variation of parameters approach to solve for inhomogeneous 2nd-order ODEs that are more general:

y+p(x)y+q(x)y=r(x)y^{\prime\prime} + p(x) y^{\prime} + q(x) y = r(x)

In this case, we can assume a solution y(x)=y1u1+y2u2y(x) = y_1 u_1 + y_2 u_2.

The solution procedure is:

  1. Obtain y1y_1 and y2y_2 by solving the homogeneous equation: y+p(x)y+q(x)y=0y^{\prime\prime} + p(x) y^{\prime} + q(x) y = 0

  2. Solve for u1u_1 and u2u_2:

u1=y2r(x)Wdx+c1u2=y1r(x)Wdx+c2W=y1y2y1y2=y1y2y2y1  ,\begin{align} u_1 &= - \int \frac{y_2 r(x)}{W} dx + c_1 \\ u_2 &= \int \frac{y_1 r(x)}{W} dx + c_2 \\ W &= \begin{vmatrix} y_1 & y_2\\ y_1^{\prime} & y_2^{\prime}\\ \end{vmatrix} = y_1 y_2^{\prime} - y_2 y_1^{\prime} \;, \end{align}

where WW is the Wronksian.

  1. Then, we have the general solution:

y=u1y1+u2y2=(y2r(x)Wdx+c1)y1+(y1r(x)Wdx+c2)y2  ,\begin{align} y &= u_1 y_1 + u_2 y_2 \\ &= \left( -\int \frac{y_2 r(x)}{W} dx + c_1 \right) y_1 + \left( \int \frac{y_1 r(x)}{W} dx + c_2 \right) y_2 \;, \end{align}

where we solve for c1c_1 and c2c_2 using the two initial conditions.

Example 1: variation of parameters

First, let’s try the same example we used for the method of undetermined coefficients above:

y+2y+y=exy^{\prime\prime} + 2 y^{\prime} + y = e^{-x}

We already found the homogeneous solution, so we know that y1=exy_1 = e^{-x} and y2=xexy_2 = x e^{-x}. Next, let’s get the Wronksian, and then u1u_1 and u2u_2.

W=y1y2y1y2=exex(1x)xex(ex)=e2xu1=xexexe2xdx+c1=xdx+c1=12x2+c1u2=exexe2xdx+c2=dx+c2=x+c2y(x)=(12x2+c1)ex+(x+c2)xex\begin{align} W &= \begin{vmatrix} y_1 & y_2 \\ y_1^{\prime} & y_2^{\prime} \end{vmatrix} = e^{-x} e^{-x}(1-x) - x e^{-x} (-e^{-x}) = e^{-2x} \\ % u_1 &= -\int \frac{x e^{-x} e^{-x}}{e^{-2x}} dx + c_1 = -\int x dx + c_1 = -\frac{1}{2} x^2 + c_1 \\ u_2 &= \int \frac{e^{-x} e^{-x}}{e^{-2x}} dx + c_2 = \int dx + c_2 = x + c_2 \\ y(x) &= \left(-\frac{1}{2} x^2 + c_1\right) e^{-x} + (x + c_2) x e^{-x} \\ \end{align}

After simplifying, we obtain the same solution as via the method of undetermined coefficients (but with a bit more work):

y(x)=x1ex+c2xex+12x2exy(x) = x_1 e^{-x} + c_2 x e^{-x} + \frac{1}{2} x^2 e^{-x}

Example 2: variation of parameters

Now let’s try an example that we could not solve using the method of undetermined coefficients, with a forcing term that involves hyperbolic cosine (cosh); recall that cosh(x)=ex+ex2\cosh(x) = \frac{e^x + e^{-x}}{2}.

y+4y+4y=cosh(x)y^{\prime\prime} + 4 y^{\prime} + 4y = \cosh(x)

First, we need to find the homogeneous solution:

y+4y+4y=0λ2+4λ+4=0λ=2\begin{align} y^{\prime\prime} + 4 y^{\prime} + 4y &= 0 \\ \lambda^2 + 4 \lambda + 4 &= 0 \\ \rightarrow \lambda &= -2 \end{align}

So our homogeneous solution involves repeated roots:

yH=c1e2x+c2xe2xy_H = c_1 e^{-2x} + c_2 x e^{-2x}

where y1=e2xy_1 = e^{-2x} and y2=xe2xy_2 = x e^{-2x}.

Then, we need to find u1u_1 and u2u_2, so let’s get the Wronksian and then solve

W=y1y2y1y2=e2x(e2x)(12x)xe2x(2e2x)=e4xu1=xe2xcoshxe4xdx+c1=x12(ex+ex)e2xdx+c1=12x(e3x+ex)dx+c1=12[19e3x(3x1)+ex(x1)]+c1u1=118e3x(3x1)12ex(x1)+c1u2=e2xcoshxe4xdx+c2=12e2x(ex+ex)dx+c2=12(e3x+ex)dx+c2u2=16e3x+12ex+c2\begin{align} W &= \begin{vmatrix} y_1 & y_2 \\ y_1^{\prime} & y_2^{\prime} \end{vmatrix} = e^{-2x} (e^{-2x}) (1 - 2x) - x e^{-2x}(-2 e^{-2x}) = e^{-4x} \\ % u_1 &= - \int \frac{x e^{-2x} \cosh x}{e^{-4x}} dx + c_1 = -\int \frac{x \frac{1}{2}(e^x + e^{-x})}{e^{-2x}} dx + c_1 \\ &= -\frac{1}{2} \int x (e^{3x} + e^x) dx + c_1 = -\frac{1}{2} \left[ \frac{1}{9} e^{3x}(3x-1) + e^x(x-1) \right] + c_1 \\ u_1 &= -\frac{1}{18} e^{3x}(3x-1) - \frac{1}{2} e^x (x-1) + c_1 \\ % u_2 &= \int \frac{e^{-2x} \cosh x}{e^{-4x}} dx + c_2 = \frac{1}{2} \int e^{2x}(e^x + e^{-x}) dx + c_2 = \frac{1}{2} \int (e^{3x} + e^x) dx + c_2 \\ u_2 &= \frac{1}{6} e^{3x} + \frac{1}{2} e^x + c_2 \end{align}

Then, when we put these all together, we get the full (complicated) solution:

y(x)=[118e3x(3x1)12ex(x1)+c1]e2x+(16e3x+12ex+c2)xe2xy(x) = \left[ -\frac{1}{18} e^{3x} (3x-1) - \frac{1}{2} e^x (x-1) + c_1 \right] e^{-2x} + \left( \frac{1}{6} e^{3x} + \frac{1}{2} e^x + c_2 \right) x e^{-2x}