Linear First-Order ODEs

Inhomogeneous Constant Coefficient Equations

Consider a first-order inhomogeneous constant coefficient differential equation of the form

$$ y' + ay = g(t) $$

where \( g(t) \) is called the forcing function, since it drives the solution away from the purely exponential behaviour of the homogeneous equation.

A key property of linear equations is that they satisfy the superposition principle. To see this, suppose \( y_1(t) \) and \( y_2(t) \) satisfy

$$ y_1' + ay_1 = g_1(t) $$ $$ y_2' + ay_2 = g_2(t) $$

Then for constants \( c_1 \) and \( c_2 \), the function \( c_1 y_1(t) + c_2 y_2(t) \) satisfies

$$ y' + ay = c_1 g_1(t) + c_2 g_2(t) $$

This follows directly from linearity:

$$ y' + ay = c_1(y_1' + ay_1) + c_2(y_2' + ay_2) = c_1 g_1(t) + c_2 g_2(t) $$

The important point is that linear combinations of solutions produce corresponding linear combinations on the right-hand side.

Now suppose we find a particular solution \( y_p(t) \) such that \( y_p' + ay_p = g(t). \)

To understand the general solution, consider the difference between an arbitrary solution \( y(t) \) and \( y_p(t) \):

$$ y' - y_p' + a(y - y_p) = 0 $$

which can be written as

$$ (y - y_p)' + a(y - y_p) = 0 $$

This shows that \( y - y_p \) satisfies the homogeneous equation.

Therefore,

$$ y(t) - y_p(t) = c e^{-at} $$

and so the general solution has the form

$$ y(t) = y_c(t) + y_p(t) $$

where \( y_c(t) = c e^{-at} \) is the complementary (homogeneous) solution, and \( y_p(t) \) is any particular solution.

The key idea is that the homogeneous part captures the natural behaviour of the system, while the particular solution reflects the effect of the forcing.

eg.

$$ \color{#00f0ff} y' + 2y = 2t + 2t^2, \quad y_p(t) = t^2, \quad y(0) = 3$$

The general solution is

$$ y(t) = c e^{-2t} + t^2 $$ $$ y(0) = c = 3 $$ $$ \therefore \, y(t) = 3 e^{-2t} + t^2 $$

Method of Undetermined Coefficients

We now turn to a systematic way of finding particular solutions for equations of the form

$$ y'(t) + a y(t) = g(t) $$

As before, the general solution is \( y(t) = y_c(t) + y_p(t) \), so the main task is to determine \( y_p(t) \).

The idea of this method is to guess a form for \( y_p(t) \) based on the structure of \( g(t) \), and then determine the unknown coefficients by substitution.

Method:

The key requirement is that the guess must remain closed under differentiation, so that substituting back into the equation produces the same types of terms.

eg. \( \quad \color{#00f0ff} y' + y = t \)

\(g(t) = t\), so we guess \(y_p(t) = At + B\)

$$ A + (At + B) = t $$ $$ At + (A + B) = t $$ $$ \Rightarrow \quad A = 1, \quad B = -1 $$

Therefore

$$ y_p(t) = t - 1 $$

The direction field below shows the equation \( y' + y = t \), or equivalently \( \displaystyle \frac{dy}{dt} = t - y \). The straight line \( y_p(t) = t - 1 \) is a particular solution. Other solutions differ from this by a decaying exponential term, so the direction field shows solution curves being drawn toward the line \( y = t - 1 \) as \(t\) increases:


Direction Field See plot code

eg. \( \quad \color{#00f0ff} y' - 5y = e^t \)

$$ y' - 5y = e^t $$

\(g(t) = e^t\), so we guess \(y_p(t) = A e^t\)

$$ A e^t - 5A e^t = e^t $$ $$ (1 - 5)A = 1 \quad \Rightarrow \quad A = -\frac{1}{4}$$ $$ y_p(t) = -\frac{1}{4} \, e^t $$

The following examples illustrate how the choice of guess depends on the form of \( g(t) \):

eg. \( \quad \color{#00f0ff} y' + 2y = g(t) \)

  1. \( g(t) = \pi \)
  2. \( g(t) = 4\cos(3t), \; y(0) = 1 \)
  3. \( g(t) = t^2 - t \)
  4. \( g(t) = 3 \, e^{-2t} \)

In each case, the structure of \( g(t) \) determines the appropriate form of the guess.

1. \(\quad y' + 2y = \pi, \quad\) guess \(y_p(t) = A\)

$$ 0 + 2A = \pi $$ $$ A = \frac{\pi}{2} $$ $$ y_c(t) = c e^{-2t} $$ $$ y(t) = \frac{\pi}{2} + c e^{-2t} $$

2. \(\quad y' + 2y = 4\cos(3t), \quad y(0)=1, \quad\) guess \(y_p(t) = A\cos(3t) + B\sin(3t)\)

$$ y_p'(t) = -3A\sin(3t) + 3B\cos(3t) $$ $$ -3A\sin(3t) + 3B\cos(3t) + 2(A\cos(3t) + B\sin(3t)) = 4\cos(3t) $$ $$ (3B + 2A)\cos(3t) + (-3A + 2B)\sin(3t) = 4\cos(3t) $$ $$ 3B + 2A = 4, \quad -3A + 2B = 0$$ Solving for \( A \) and \( B \), we find that $$A = \frac{8}{13}, \quad B = \frac{12}{13}$$ $$y_p(t) = \frac{8}{13}\cos(3t) + \frac{12}{13}\sin(3t)$$ $$y(0) = 1 = y_p(0) + y_c(0)$$ $$1 = \frac{8}{13} + c \quad \Rightarrow \quad c = \frac{5}{13}$$ $$y(t) = \frac{5}{13} e^{-2t} + \frac{8}{13}\cos(3t) + \frac{12}{13}\sin(3t)$$

The direction field below illustrates the forced equation \( y' + 2y = 4\cos(3t) \), or equivalently \( \displaystyle \frac{dy}{dt} = 4\cos(3t) - 2y \). The dark curve shows the particular solution \( \displaystyle y_p(t)=\frac{8}{13}\cos(3t)+\frac{12}{13}\sin(3t) \), while the other curves show nearby solutions. Since the complementary solution is proportional to \( e^{-2t} \), the transient part decays rapidly, and the solution curves are drawn toward the same long-term oscillatory response:


Direction Field See plot code

3. \(\quad y' + 2y = t^2 - t, \quad\) guess \(y_p(t) = At^2 + Bt + D\)

$$2At + B + 2At^2 + 2Bt + 2D = t^2 - t$$ $$ 2A = 1 \quad \Rightarrow \quad A = \frac{1}{2} $$ $$ 2A + 2B = -1 \quad \Rightarrow \quad B = -1 $$ $$ B + 2D = 0 \quad \Rightarrow \quad D = \frac{1}{2} $$ $$ y_p(t) = \frac{1}{2}t^2 - t + \frac{1}{2} $$

therefore

$$ y(t) = \frac{1}{2}t^2 - t + \frac{1}{2} + c e^{-2t} $$

4. \(\quad y' + 2y = 3 e^{-2t}, \quad\) guess \(y_p(t) = A e^{-2t}\)

$$ -2A e^{-2t} + 2A e^{-2t} = 3 e^{-2t} $$

This does not work because \( g(t) \) already matches the form of the homogeneous solution. This situation is called resonance.

To account for this, we modify the guess by multiplying by \( t \):

$$ y_p(t) = At e^{-2t} $$ $$ y_p'(t) = A e^{-2t} - 2At e^{-2t} $$ $$ A e^{-2t} - 2At e^{-2t} + 2At e^{-2t} = 3 e^{-2t} $$ $$ \Rightarrow \quad A = 3 $$

and so

$$ y(t) = 3t e^{-2t} + c e^{-2t} $$

If \( y(t) \) is the general solution, then \( y(t) - y_p(t) \) solves the homogeneous equation

$$ \, y' + p(t)y = g(t) \quad $$ $$ - \quad y_p' + p(t)y_p = g(t) \quad \quad $$ $$ \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_ $$ $$ (y - y_p)' + p(t)(y - y_p) = 0 $$

More generally, if we find any particular solution \( y_p(t) \) to \( \, y' + p(t)y = g(t) \), then every solution can be written in the form

$$ y(t) = y_c(t) + y_p(t) $$

where \( y_c(t) \) solves the corresponding homogeneous equation.

Integrating Factor Method

We now introduce a general method that works even when the coefficient is not constant, \(\, y' + p(t)y = g(t) \)

The idea is to transform the left-hand side into an exact derivative. To motivate this, consider

$$ \frac{d}{dt}(yq) = y'q + yq' $$

Dividing by \( q \), we obtain

$$ \frac{1}{q} \frac{d}{dt}(yq) = y' + \frac{q'}{q}y $$

This suggests that if we can choose a function \( \mu(t) \) such that

$$ \frac{\mu'}{\mu} = p(t) $$

then multiplying the equation by \( \mu(t) \) will turn the left-hand side into an exact derivative.

Solving for \( \mu \), we obtain

$$ \int \frac{d\mu}{\mu} = \int p \, dt $$ $$ \ln \mu = \int p \, dt $$

and therefore

$$ \mu(t) = e^{\int^{t} p(s)\,ds} $$

This function \( \mu(t) \) is called the integrating factor.

Multiplying the differential equation by \( \mu(t) \), we obtain

$$ \frac{d}{dt} ( \, \mu(t)y(t) \, ) = \mu(t)g(t) $$

Integrating both sides gives

$$ \mu(t)y(t) = \int^{t} \mu(s)g(s)\,ds + c $$

so

$$ y(t) = \frac{\int^{t} \mu(s)g(s)\,ds + c}{\mu(t)} $$

This shows explicitly how the solution splits into a particular part and a complementary part:

$$ y(t) = y_p(t) + y_c(t) $$

where

$$ y_p(t) = \frac{\int^{t} \mu(s)g(s)\,ds}{\mu(t)}, \quad y_c(t) = \frac{c}{\mu(t)} $$

The integrating factor method works quite generally, provided \( p(t) \) and \( g(t) \) are sufficiently well-behaved.

eg. Find the general solution of \( \color{#00f0ff} y' - 3y = 2\sin t \) using the integrating factor method

Here \( p(t) = -3 \), so

$$ \mu(t) = e^{\int^{t} -3\,ds} = e^{-3t} $$

Then

$$ y(t) = \frac{\int^{t} e^{-3s}(2\sin s)\,ds + c}{e^{-3t}} $$

We compute the integral using integration by parts:

$$ \int uv' = uv - \int vu' $$

Here we have

$$ \int 2\sin t \, e^{-3t}\,dt = 2 \int \sin t \, e^{-3t}\,dt $$ $$ u = \sin t, \quad u' = \cos t $$ $$ v = -\frac{1}{3} \, e^{-3t}, \quad v' = e^{-3t} $$ $$ \int \sin t \, e^{-3t}\,dt = -\frac{1}{3} \sin t \, e^{-3t} + \frac{1}{3} \int \cos t \, e^{-3t}\,dt $$

Now let

$$ u = \cos t, \quad u' = -\sin t $$ $$ v = -\frac{1}{3} \, e^{-3t}, \quad v' = e^{-3t} $$ $$ \int \cos t \, e^{-3t}\,dt = -\frac{1}{3}\cos t \, e^{-3t} - \frac{1}{3} \int \sin t \, e^{-3t}\,dt $$

Solving for the integral gives

$$ \int \sin t \, e^{-3t}\,dt = -\frac{1}{3} \sin t \, e^{-3t} + \frac{1}{3} \left( -\frac{1}{3} \cos t \, e^{-3t} - \frac{1}{3} \int \sin t \, e^{-3t}\,dt \right) $$ $$ \frac{10}{9} \int \sin t \, e^{-3t}\,dt = -\frac{1}{3}\sin t \, e^{-3t} - \frac{1}{9} \cos t \, e^{-3t} $$ $$ \int \sin t \, e^{-3t}\,dt = -\frac{3}{10} \, e^{-3t}\sin t - \frac{1}{10} \, e^{-3t}\cos t $$

Therefore

$$ 2 \int \sin t \, e^{-3t}\,dt = -\frac{3}{5} \, e^{-3t}\sin t - \frac{1}{5} \, e^{-3t}\cos t $$

Hence

$$ y(t) = \frac{-\frac{3}{5} \, e^{-3t}\sin t - \frac{1}{5} \, e^{-3t}\cos t + c}{e^{-3t}} $$

Simplifying

$$ y(t) = -\frac{3}{5} \sin t - \frac{1}{5} \cos t + c e^{3t} $$

The first two terms form the particular solution, and the final term is the complementary solution.

eg. Find the general solution of \( \color{#00f0ff} y' + 3t^2 y = 2t^2 \) using the integrating factor method

Here \( p(t) = 3t^2 \), so

$$ \mu(t) = e^{\int^{t} p(s)\,ds} = e^{t^3} $$

Then

$$ y(t) = \frac{\int^{t} e^{s^3}(2s^2)\,ds + c}{e^{t^3}} $$

We compute the integral

$$ \int 2t^2 e^{t^3}\,dt = 2 \int t^2 e^{t^3}\,dt $$

Use u-substitution, let \( u = t^3 \), so \( \displaystyle \frac{du}{dt} = 3t^2 \)

$$ \int t^2 e^{t^3}\,dt = \int e^u \frac{du}{3} = \frac{1}{3} \int e^u\,du $$ $$ = \frac{1}{3} \, e^u = \frac{1}{3} \, e^{t^3} $$

Therefore

$$ 2 \int t^2 e^{t^3}\,dt = \frac{2}{3} \, e^{t^3} $$

Hence

$$ y(t) = \frac{\frac{2}{3} e^{t^3} + c}{e^{t^3}} $$

Simplifying

$$ y(t) = \frac{2}{3} + c \, e^{-t^3} $$

The first term is the particular solution and the second is the complementary solution.

eg. Solve

$$ \color{#00f0ff} \frac{dy}{dx} = e^{2x} - 3y, \quad y(0) = 1$$ $$ \frac{dy}{dx} + 3y = e^{2x} $$ $$ \mu(x) = e^{\int 3\,dx} = e^{3x} $$

Multiply both sides by \( e^{3x} \)

$$ e^{3x} \frac{dy}{dx} + 3 e^{3x}y = e^{5x} $$

The left-hand side becomes

$$ \frac{d}{dx}\left(e^{3x}y\right) = e^{5x} $$

Integrating both sides,

$$ y(x) \, e^{3x} = \int e^{5x}\,dx = \frac{1}{5} \, e^{5x} + c $$

Therefore

$$ y(x) = \frac{1}{5} \, e^{2x} + c e^{-3x} $$ $$ y(0) = 1 = \frac{1}{5} + c \quad \Rightarrow \quad c = \frac{4}{5} $$

Hence the solution is

$$ y(x) = \frac{1}{5} \, e^{2x} + \frac{4}{5} \, e^{-3x} $$

eg. Solve the initial value problem \( \color{#00f0ff} \displaystyle \frac{dy}{dx} + y\cos x = 4\cos x, \quad y(0) = 6 \)

$$ \mu(x) = e^{\int \cos x\,dx} = e^{\sin x} $$ $$ y(x) \, e^{\sin x} = 4\int \cos x\,e^{\sin x}\,dx $$

Let \( u = \sin x \), so \( du = \cos x\,dx \)

$$ \int \cos x\,e^{\sin x}\,dx = \int e^u\,du = e^u + c = e^{\sin x} + c $$

Therefore

$$ y(x) \, e^{\sin x} = 4 e^{\sin x} + c $$ $$ y(x) = 4 + c e^{-\sin x} $$ $$ y(0) = 6 = 4 + c \quad \Rightarrow \quad c = 2 $$

Hence the solution is

$$ y(x) = 4 + 2 e^{-\sin x} $$

eg. Solve the initial value problem \( \color{#00f0ff} \displaystyle \frac{dy}{dt} - y = 6 e^t + 12 e^{7t}, \quad y(0) = 4 \)

$$ \mu(t) = e^{\int -\,dt} = e^{-t} $$ $$ y(t) \, e^{-t} = \int e^{-t} \, (6 e^t + 12 e^{7t})\,dt $$ $$ y(t) e^{-t} = \int 6 + 12 e^{6t} \,dt $$ $$ y(t) e^{-t} = 6t + 2 e^{6t} + c $$ $$ y(t) = 6t e^t + 2 e^{7t} + c e^t $$ $$ y(0) = 4 = 2 + c \quad \Rightarrow \quad c = 2 $$

Hence the solution to the IVP is

$$ y(t) = (6t + 2e^{6t} + 2) \, e^t $$