# MST210/Unit 1/Book A/Inhomogeneous Second-Order Differential Equations

This section is concerned with finding solutions to inhomogeneous second-order differential equations. These are equations of the form

$a \frac{d^2y}{dx^2} + b \frac{dy}{dx} + cy = f(x)$

where $$a \neq 0$$, and $$f(x)$$ is a given continuous real-valued function.

# General Method of Solution

Let

$a \frac{d^2y}{dx^2} + b \frac{dy}{dx} + cy = f(x)$

be an inhomogeneous linear constast-coefficient second-order differential equation.

Its associated homogeneous equation is

$a \frac{d^2y}{dx^2} + b \frac{dy}{dx} + cy = 0$

The general solution $$y_c$$ of the associated homogeneous equation is known as the complementary function for the original equation.

Any particular solution $$y_p$$ of the original inhomogeneous equation is referred to as a particular integral for that equation.

Exercise 23

The Principle of Superposition states that if we have two particular solutions $$y_{p1}$$, $$y_{p2}$$, then $$y = k_1 y_{p1} + k_2 y_{p2}$$ is also a solution. Hence $$y = y_{p1} - y_{p2}$$ is a solution, where $$k_1 = 1$$, $$k_2 = -1$$.

Exercise 24
1. The associated homogeneous equation is $\frac{d^2 y}{dx^2} + 4y = 0$

The auxiliary equation for this homogeneous equation is $\lambda^2 + 4 = 0$

As seen in Exercise 21, the solutions are a pair of complex conjugate roots, $$\lambda_{1,2} = \pm 2i$$. Following Procedure 5, the general solution is

$y_c = C \cos 2 x + D \sin 2 x$ where $$C$$ and $$D$$ are arbitrary constants.

A particular solution to this equation is $$y_p = 2$$. This can be verified by seeing that $$y_p = 2$$, $$y_p' = 0$$, $$y_p'' = 0$$. Substituting into the original differential equation, we have

$\frac{d^2 y_p}{dx^2} + 4y_p = 0 + 4 \cdot 2 = 8$

Therefore, the general solution of the inhomogeneous differential equation is

$y = C \cos 2x + D \sin 2x + 2$ where $$C$$ and $$D$$ are arbitrary constants.

2. The associated homogeneous equation is $\frac{d^2y}{dx^2} - 3 \frac{dy}{dx} + 2y = 0$

We solved this homogeneous differential equation in Example 8, and found $y_c = Ce^{x} + De^{2x}$

A particular solution to the inhomogeneous differential equation is $y_p = 3$

This can be verified, as $$y_p = 3$$, $$y_p' = 0$$, $$y_p'' = 0$$, and thus

$\begin{array}{lcl} \frac{d^2 y}{dx^2} - 3 \frac{dy}{dx} + 2 y &=& 0 - 3 \cdot 0 + 2 \cdot 3 \\ &=& 6 \end{array}$

Therefore, the general solution to the inhomogeneous differential equation is $y = Ce^x + De^{2x} + 3$ where $$C$$ and $$D$$ are arbitrary constants.

# Finding a Particular Integral by the Method of Undetermined Coefficients

We have seen that we can find the general solution of a second-order inhomogeneous different equation of the form

$a \frac{d^2y}{dx^2} + b \frac{dy}{dx} + cy = f(x)$

by first finding the general solution of the associated homogeneous differential equation ($$y_c$$), and a particular solution to the inhomogeneous differential equation. In this section, we will look at ways to find the particular solution, when $$f(x)$$ is a polynomial, exponential or sinusoidal function - or a sum of such functions.

In general, we try a function of the form as $$f(x)$$ as our trial solution, and then solve to find values for variables in this function.

## Polynomial Functions

Consider a trial solution of the form $f(x) = m_n x^n + m_{n-1} x^{n-1} + \dotsb + m_1 x + m_0$

This is a polynomial function of degree $$m$$, and $$m$$ should be chosen to have the same degree as the original function in the inhomogeneous equation.

Next, find the first- and second-derivatives $$f'$$ and $$f''$$, and substitute in to the inhomogeneous differential equation. Compare coefficients to find suitable values of $$m_n, m_{n-1}, \dotsb, m_0$$.

Exercise 25
1. Consider the trial solution $y = p_1 x + p_0$

We have $$y' = p_1$$ and $$y'' = 0$$. Substituting into the original inhomogeneous differential equation we have

$-2 p_1 + 2 (p_1 x + p_0) = 2p_1 x + (2p_0 - 2p_1) = 2x + 3$

Comparing coefficients of $$x$$, we have $$2p_1 = 2$$, $$2p_0 - 2p_1 = 3$$. Thus $$p_1 = -1$$ and $$p_0 = \frac{5}{2}$$.

Therefore, we have the particular integral

$y_p = x + \frac{5}{2}$

Checking, we have $$y_p' = 1$$, $$y_p'' = 0$$, and so

$-2 \cdot 1 + 2(x + \frac{5}{2}) = -2 + 2x + 5 = 2x + 3$

2. Consider the trial solution $y = p_1 x + p_0$

We have $$y'' = p_1$$ and $$y'' = 0$$. Substituting into the original inhomogeneous differential equation we have

$2 p_1 + p_1x + p_0 = p_1 x + (p_0 + 2p_1) = 2x$

Comparing coefficients of $$x$$, we have $$p_1 = 2$$ and $$p_0 + 2p_1 = 0$$. Therefore, $$p_1 = 2$$, $$p_0 = -4$$.

Therefore, we have the particular integral

$y_p = 2x-4$

Checking, we have $$y_p' = 2$$, $$y_p'' = 0$$, and so

$2 \cdot 2 + 2x - 4 = 2 + 2x - 4 = 2x$

Exercise 26

Consider the trial solution $y = p_2 t^2 + p_1 t + p_0$

We have $$y' = 2 p_2 t + p_1$$ and $$y'' = 2 p_2$$. Substituting into the original inhomogeneous differential equation we have

$2 p_2 - (p_2 t^2 + p_1 t + p_0) = -p_2 t^2 - p_1 t + (2 p_2 - p_0) = t^2$

Comparing coefficients of $$x$$, we have $$-p_2 = 1$$, $$p_1 = 0$$ and $$2 p_2 - p_0 = 0$$. Therefore, $$p_2 = -1$$, $$p_0 = - 2$$.

Therefore, the particular integral is

$y = -t^2 - 2$

Checking, we have $$y' = - 2 t$$, $$y'' = -2$$. Thus

$-2 + t^2 + 2 = t^2$

## Exponential Functions

For exponential functions, consider a trial solution of the form $y(x) = me^{kx}$ matching $$k$$ to the coefficient of $$x$$ in the original differential equation.

Exercise 27

Consider the trial solution $y = pe^{-x}$

We have $$y' = -pe^{-x}$$ and $$y'' = pe^{-x}$$. Substituting into the original inhomogeneous differential equation, we have

$2pe^{-x} - 2 (-pe^{-x}) + pe^{-x} = 2e^{-x}$

That is

$5pe^{-x} = 2e^{-x}$ and so $$p = \frac{2}{5}$$. Therefore, the particular integral is $y = \frac{2}{5}e^{-x}$

## Sinusoidal Functions

For sinusoidal functions, consider a trial solution of the form $f(x) = m \cos \Omega x + n \sin \Omega x$ where $$\Omega$$ is chosen to match the multiple of $$x$$ in the original differential equation.

Exercise 28

Consider the trial solution

$y = m \cos 3t + n \sin 3t$

We have $$y' = 3n \cos 3t - 3m \sin 3t$$ and $$y'' = -9 m \cos 3t - 9n \sin 3t$$.

Substituting into the original inhomogeneous differential equation, we have

$(-9m \cos 3t - 9n \sin 3t) - (3n \cos3t - 3m\sin 3t) = \cos 3t + \sin 3t$

That is

$-(9m + 3n) \cos 3t + (3m -9n) \sin3t = \cos 3t + \sin 3t$

Equating coefficients of $$\cos 3t$$ and $$\sin 3t$$\$, we have the pair of simultaneous equations

$\begin{cases} -9m - 3n = 1 \\ 3m - 9n = 1 \end{cases}$

We can eliminate $$m$$ as

$\begin{cases} -30n = 4 \\ 3m - 9n = 1 \end{cases}$

Therefore $$n = \frac{-2}{15}$$ and $$m = \frac{1 - 9 \frac{2}{15}}{3} = \frac{-1}{15}$$. Thus the particular integral is

$y = -\frac{1}{15} \cos 3 t - \frac{2}{15} \sin 3 t$

## Method of Undetermined Coefficients

(See handbook)

Exercise 29
1. $f(x) = pe^{2x}$
2. $f(x) = p\cos4x + q\sin 4x$
Exercise 30
1. Following the hint, we know the roots of the auxiliary equation are a pair of complex conjugate roots, so the complementary function is

$y_c = e^{-x}(C \cos x + D \sin x)$ where $$C$$ and $$D$$ are arbitrary constants.

As the right-hand side of the inhomogeneous differential equation is a constant, the trial solution is $f(x) = p$

Therefore

$2p = 4$

Thus $$p = 2$$. The particular integral is $y_p = 2$

and so the general solution is

$y = e^{-x}(C \cos x + D \sin x) + 2$

2. Following the hint, we know the roots of the auxiliary equation are distinct real roots, so the complementary function is

$\theta_c = C + De^{-3t}$ where $$C$$ and $$D$$ are arbitrary constants.

To find the particular integral, we consider as a trial solution $f(t) = p \cos 2t + q \sin 2t$

The first- and second-derivatives are $f'(t) = 2q \cos 2t - 2p \sin 2t$ $f''(t) = -4p \cos 2t - 4q \sin 2t$

Substituting into the inhomogeneous differential equation, we have

$(-4p \cos 2t - 4q \sin 2t) + 3 (2q \cos 2t - 2p \sin 2t) = 13 \cos 2t$

That is

$\begin{array}{ll} 13 \cos 2t &= -4p \cos 2t - 4q \sin 2t + 6q \cos 2t - 6p \sin 2t = 13 \cos 2t \\ &= (6q - 4p) \cos 2t - (4q + 6p) \sin 2t \end{array}$

Comparing coefficients, we have the pair of simultaneous equations

$\begin{cases} -4p + 6q = 13 \\ -6p - 4q = 0 \end{cases}$

Substituting $$p = -\frac{2q}{3}$$, we have

$\begin{cases} \frac{8q}{3} + 6q = 13 \\ p = -\frac{2q}{3} \end{cases}$

Thus $$q = \frac{3}{2}$$ and $$p = -1$$

Therefore the general solution is

$\theta = C + De^{-3t} - \cos 2t + \frac{3}{2} \sin 2t$ where $$C$$ and $$D$$ are arbitrary constants.

Exercise 31

Setting $$R = S = Q = 1$$ yields the differential equation

$y'' - y + \frac{1}{2}(l - x) x = 0$

Rearranging this, we have the inhomogeneous differential equation

$y'' - y = \frac{1}{2}x^2 - \frac{l}{2}x$

The associated homogeneous equation is $y'' - y = 0$ The auxiliary equation for this is $\lambda^2 - 1 = 0$ which has solutions $\lambda_{1,2} = \pm 1$

As we have two distinct real roots, following Procedure 5 we have the complementary function

$y_c = Ce^{-x} + De^{x}$ where $$C$$ and $$D$$ are arbitrary constants.

The right-hand side of the inhomogeneous equation is a polynomial function of degree 2 in $$x$$, so we consider the trial function

$f(x) = p_2 x^2 + p_1 x + p_0$

The first- and second-derivatives are

$f'(x) = 2p_2 x + p_1$

$f''(x) = 2p_2$

Substituting in to the inhomogeneous equation, we have

$2p_2 - (p_2 x^2 + p_1 x + p_0) = \frac{1}{2}x^2 - \frac{l}{2}x$

That is

$- p_2 x^2 - p_1 x + (2p_2 - p_0) = \frac{1}{2}x^2 - \frac{l}{2}x$

On comparing coefficients of $$x$$, we have

$\begin{cases} -p_2 = \frac{1}{2} \\ -p_1 = -\frac{l}{2} \\ 2p_2 - p_0 = 0 \end{cases}$

Therefore $$p_2 = -\frac{1}{2}$$, $$p_1 = \frac{l}{2}$$, and $$p_0 = -1$$.

Thus the particular integral is

$y_p = -\frac{1}{2} x ^ 2 + \frac{l}{2} x - 1$

Therefore the general solution is

$y = Ce^{-x} + De^{x} -\frac{1}{2} x ^ 2 + \frac{l}{2} x - 1$ where $$C$$ and $$D$$ are arbitrary constants.

## Exceptional Cases

It is important to check if all or sub-expressions of the trial solution is also a solution of the associated homogeneous differential equation. In this scenario, therefore trial solution will not help find a particular integral. However, multiplying the trial solution by $$x$$ often solves this problem. It may be required to perform this multiplication more than once.

Exercise 32
1. The complementary function is $y_c = Ce^{x} + De^{2x}$ Thus it can be seen that the traditional choice of trial functions, $$y = pe^x$$ is a particular solution to the homogeneous differential equation, where $$C = p$$, $$D = 0$$.

Instead, we try the trial function $$y = pxe^x$$

We have $y' = pe^x + pxe^x = p(1 + x)e^x$ and $y'' = pe^x + p(1+x)e^x = p(2+x)e^x$

Substituting into the inhomogeneous differential equation, we have

$p(2+x)e^x - 3(p(1 + x)e^x) + 2 pxe^x = 4e^x$

Expanding out and collecting terms, we have

$\begin{array}{ll} 4e^x &= p(2+x)e^x - 3(p(1 + x)e^x) + 2 pxe^x \\ &= 2pe^x + pxe^x - 3(pe^x + pxe^x) + 2pxe^x \\ &= 2pe^x + pxe^x - 3pe^x - 3pxe^x + 2pxe^x \\ &= -pe^x \\ \end{array}$

Comparing coefficients, we have $$p = -4$$. Therefore the particular integral is

$y_p = -4xe^x$

2. In Exercise 18b, we saw the complementary function was $y_c = C + De^{-\frac{3x}{2}}$

However, the trial function $$f(x) = p$$ is a particular solution to the associated homogeneous equation, with $$C = p$$, $$D = 0$$. Therefore, we try the trial solution $f(x) = px$

We have $f'(x) = p$ $f''(x) = 0$

Substituting in to the original inhomogeneous equation, we have

$3p = 1$

So $$p = \frac{1}{3}$$, and therefore the particular integral is

$y_p = \frac{1}{3}x$

Exercise 33

We can rewrite in the form of homogeneous differential equation as $m\ddot{x} + r\dot{x} = mg$

The associated homogeneous equation has the auxiliary equation $m \lambda^2 + r\lambda = 0$

That is, $$\lambda(m\lambda + r) = 0$$, so the auxiliary equation has two distinct real solutions: $$\lambda_1 = 0$$ and $$\lambda_2 = -\frac{r}{m}$$.

Following Procedure 5, the complementary function is thus

$x_c = C + De^{-\frac{rt}{m}}$ where $$C$$ and $$D$$ are arbitrary constants.

We now find the particular integral. The trial solution $$f(t) = p$$ will not help, as this is also a particular solution to the homogeneous differential equation, with $$C = p$$, $$D = 0$$. Instead, we consider the trial solution $f(t) = pt$

We have $f'(t) = p$ $f''(t) = 0$

Substituting into the inhomogeneous differential equation, we have

$rp = mg$

So $$p = \frac{mg}{r}$$, and therefore the particular integral is

$x_p = \frac{mg}{r} t$

Thus the general solution is

$x = C + De^{-\frac{rt}{m}} + \frac{mgt}{r}$ where $$C$$ and $$D$$ are arbitrary constants.

Exercise 34

In Exercise 21d, we saw that the complementary function was $y_c = (C + Dx)e^x$

If we consider the trial solution $f(x) = pe^x$ this can be seen as a particular solution to the associated homogeneous equation, where $$C = p$$, $$D = 0$$.

Multipling by the independent variable, we try another trial solution $f(x) = pxe^x$

However, this is also a solution to the associated homogeneous equation, where $$C = 0$$, $$D = p$$. We follow Procedure 8 again, and consider another trial function:

$f(x) = px^2e^x$

Differentiating, we have

$f'(x) = 2pxe^x + px^2e^x = p(x^2 + 2x)e^x$

$f''(x) = p(x^2 + 4x + 2)e^x$

Substituting into the inhomogeneous differential equation, we have

$p(x^2 + 4x + 2)e^x - 2(p(x^2 + 2x)e^x) + px^2e^x = e^x$

Expanding out and collecting terms, we have

$\begin{array}{ll} e^x &= p(x^2 + 4x + 2)e^x - 2(p(x^2 + 2x)e^x) + px^2e^x \\ &= pe^x((x^2 + 4x + 2) - 2(x^2 + 2x) + x^2) \\ &= pe^x(x^2 + 4x + 2 - 2x^2 - 4x + x^2) \\ &= pe^x(2) \\ \end{array}$

Comparing coefficients of $$e^x$$, we have $$p = \frac{1}{2}$$. Thus the particular integral is $y_p = \frac{x^2}{2}e^x$

Therefore, the general solution is

$y = (C + Dx)e^x + \frac{x^2}{2}e^x$ where $$C$$ and $$D$$ are arbitrary constants.

# Combining Cases

In this section, we will see how to find the particular integral when $$f(x)$$ is a combination of polynomial, exponential or sinusoidal functions. We will use the Principle of Superposition to combine functions. We find the particular integrals involving each part of $$f(x)$$ separately, and then combine the solutions using the Principle of Superposition.

Exercise 35
1. In Exercise 24, we saw that $$\frac{x^2}{2}e^x$$ is a particular integral for $\frac{d^2y}{dx^2} - 2\frac{dy}{dx} + y = e^x$

Next, we find a particular integral for $\frac{d^2y}{dx^2} - 2\frac{dy}{dx} + y = e^{2x}$

As a trial solution, we take $f(x) = pe^{2x}$

Differentiating, we have

$f'(x) = 2pe^{2x}$ $f''(x) = 4pe^{2x}$

Substituting in to the original inhomogeneous equation, we have

$4pe^{2x} - 4pe^2x + pe^{2x} = e^{2x}$

Thus $$p = 1$$. Therefore the particular integral is $y_p = e^{2x}$

Therefore, by the Principle of Superposition, the particular integral of $\frac{d^2y}{dx^2} - 2\frac{dy}{dx} + y = 4e^x - 3e^{2x}$ is

$y_p = 2x^2e^x - 3e^{2x}$

2. We first consider $2 \frac{d^2x}{dt^2} + 3 \frac{dx}{dt} + 2x = 12 \cos3t t$

We take $f(t) = p \cos 2t + q \sin 2t$ as our trial solution. Differentiating, we have

$f'(t) = 2q \cos 2t - 2p \sin 2t$ $f'(t) = - 4p \cos 2t - 4q \sin 2t$

Substituting in to the inhomogeneous differential equation, we have

$2 (-4p \cos 2t - 4q \sin 2t) + 3 (2q \cos 2t - 2p \sin 2t) + 2 (p \cos 2t + q \sin 2t) = 12 \cos 2t$

Collecting terms, we have

$\begin{array}{ll} 12 \cos 2t &= -8p \cos 2t -8 q \sin 2t + 6q \cos 2t - 6p \sin 2t + 2p \cos 2t + 2q \sin 2t &= (-8p + 6q + 2p) \cos 2t + (-8q - 6p + 2q) \sin 2t &= (-6p + 6q) \cos 2t + (-6q - 6p) \sin 2t &= (-6p + 6q) \cos 2t - (6q + 6p) \sin 2t &= 6(q - p) \cos 2t - 6(p + q) \sin 2t \end{array}$

Comparing coefficients, we have the simultaneous equations

$\begin{cases} q - p = 2 \\ p + q = 0 \end{cases}$

Hence $$p = -1$$, $$q = 1$$

Therefore, the particular integral is $x_p = \sin 2t - \cos 2t$

Next, we consider $2 \frac{d^2x}{dt^2} + 3 \frac{dx}{dt} + 2x = 10$

Now take $f(t) = p$ Differentiating, $$f'(t) = 0$$, $$f''(t) = 0$$. Substituting, we have

$2p = 10$

Thus $$p = 5$$. So the particular integral is $$x_p = 5$$

Therefore, by the Principle of Superposition, the particular integral for $2 \frac{d^2x}{dt^2} + 3 \frac{dx}{dt} + 2x = 12 \cos3t t$

We take $f(t) = p \cos 2t + q \sin 2t$ as our trial solution. Differentiating, we have

$f'(t) = 2q \cos 2t - 2p \sin 2t$ $f'(t) = - 4p \cos 2t - 4q \sin 2t$

Substituting in to the inhomogeneous differential equation, we have

$2 (-4p \cos 2t - 4q \sin 2t) + 3 (2q \cos 2t - 2p \sin 2t) + 2 (p \cos 2t + q \sin 2t) = 12 \cos 2t$

Collecting terms, we have

$\begin{array}{ll} 12 \cos 2t &= -8p \cos 2t -8 q \sin 2t + 6q \cos 2t - 6p \sin 2t + 2p \cos 2t + 2q \sin 2t &= (-8p + 6q + 2p) \cos 2t + (-8q - 6p + 2q) \sin 2t &= (-6p + 6q) \cos 2t + (-6q - 6p) \sin 2t &= (-6p + 6q) \cos 2t - (6q + 6p) \sin 2t &= 6(q - p) \cos 2t - 6(p + q) \sin 2t \end{array}$

Comparing coefficients, we have the simultaneous equations

$\begin{cases} q - p = 2 \\ p + q = 0 \end{cases}$

Hence $$p = -1$$, $$q = 1$$

Therefore, the particular integral is $x_p = \sin 2t - \cos 2t$

Next, we consider $2 \frac{d^2x}{dt^2} + 3 \frac{dx}{dt} + 2x = 10$

Now take $f(t) = p$ Differentiating, $$f'(t) = 0$$, $$f''(t) = 0$$. Substituting, we have

$2p = 10$

Thus $$p = 5$$. So the particular integral is $$x_p = 5$$

Therefore, by the Principle of Superposition, the particular integral for $2 \frac{d^2x}{dt^2} + 3 \frac{dx}{dt} + 2x = 12 \cos3t t + 10$ is $y_p = \sin 2t - \cos 2t + 5$