So far we mainly dealt with linear sistem of 2 first order *homogeneous* differential equations or second order *homogeneous* differential equations. Our goal now is to construct **general solutions** of *nonhomogeneous differential equations*.

Consider the second order ordinary differential equation:

$$ y'' + p(t)y' +q(t)y = g(t), $$where the coefficient functions $p(t)$, $q(t)$, and the external force (the nonhomogeneous term) $g(t)$ are all continuous on an interval $I \subset \mathbb{R}$. We express this nonhomogeneous ODE in the operator form. We define the second order linear differential operator $\mathcal{L}$ by

$$ \mathcal{L}[f]=f''+p(t)f' +q(t)f. $$Recall that operators are functions that *operate* on functions: $\mathcal{L}$ takes a function $f$ and maps it to the function $f''+p(t)f' +q(t)f$. With this definition, the nonhomogenous ODE above is expressed as:

**Key Observation**: Suppose we have two particular solutions $y_1(t)$ and $y_2(t)$ of the ODE $\mathcal{L}[y]=g(t)$.
Then their difference $y_2(t)-y_1(t)$ solves the corresponding homogeneous equation $\mathcal{L}[y]=0$ ($\mathcal{L}$ is the same operator.) Indeed:

This true only because $\mathcal{L}$ is a linear operator, of course.

Now suppose that we have two linearly independent solutions (i.e., a fundamental set of solutions) $\bar{y}_1$ and $\bar{y}_2$ of the corresponding homogenous equation $\mathcal{L}[y]=0$. Since the difference $y_1(t)-y_2(t)$ is a solution of $\mathcal{L}[y]=0$ as well, it can be expressed as:

$$ y_2(t)-y_1(t) = c_1 \bar{y}_1(t) + c_2 \bar{y}_2(t), $$where $c_1$ and $c_2$ are some constants. By rearranging this expression as:

$$ y_2(t) = c_1 \bar{y}_1(t) + c_2 \bar{y}_2(t) + + y_1(t). $$This tells us that, if we know just one solution $y_1(t)$ of the nonhomogeneous equation $\mathcal{L}[y]=g(t)$, any solution $y(t)$ of this nonhomogeneous equation can be expressed as

$$ y(t) = c_1 \bar{y}_1(t) + c_2 \bar{y}_2(t) + + y_1(t). $$by choosing the constants $c_1$ and $c_2$ appropriately. We have arrived at the following fact.

**Fact:** The moment we have *a particular solution* $y_p(t)$ of the *nonhomogeneous equation* $\mathcal{L}[y]=g(t)$ and a fundamental set of solutions $\lbrace\bar{y}_1, \bar{y}_2\rbrace$ of the *corresponding homogeneous equation* $\mathcal{L}[y]=0$, the *general solution of the nonhomogeneous equation* $\mathcal{L}[y]=g(t)$ is constructed as:

Note that the general solution of the nonhomogeneous equation is of the form

$$ \text{general solution of the homogeneous equation} + \text{a particular solution of the nonhomogeneous equation} $$and we have already seen in previous lectures that finding the general solution of the homogeneous equation is a rather straightforward procedure. To construct the general solution of the nonhomogeneous equation, we need to be able to find just one particular solution of the nonhomogeneous equation.

**Question:** How do we find $y_p(t)$?

The first method that addresses this problem is called the Method of Undetermined Coefficients.

This method is based on guessing the form of the particular solution of the nonhomogeneous equation $\mathcal{L}[y]=g(t)$ based on the structure of the nonhomogeneous term $g(t)$.

**Example:** Consider the following ODE

The external force term (the term that introduces nonhomogeneity) is $g(t)=3e^{2t}$. The differential operator on the left hand side is

$$ \mathcal{L}[y]=y''-3y'-4y. $$We are looking for a solution $y_p(t)$ so that $\mathcal{l}[y_p]=3e^{2t}$. Since $\mathcal{L}[y]$ consists of the second derivative, the first derivative, and the function $y$ itself with constant coefficients, it is reasonable to assume that $y_p(t)$ is of the form

$$ y_p(t) = A e^{2t} $$where $A$ is a *coefficient to be determined* (hence the name of the method). This *ansatz* makes sense because the derivatives of the exponential function will produce the function itself. We plug this into the nonhomogeneous ODE and determine the constant coefficient $A$. We compute that

and plugging in gives

$$ (4A-6A-4A)e^{2t} = 3e^{2t}, $$and hence $A=\frac{-1}{2}$. Thus a particular solution of the nonhomogeneous equation is found to be:

$$ y_p(t)=-\frac{1}{2}e^{2t}. $$**Example:** Now consider the same ODE with a different nonhomogeneity $g(t)=2\sin t$:

Now, note that the operator $\mathcal{L}$ involves taking the first derivative of a function it acts on. So if we assume $y_p(t)=A\sin t$, $\mathcal{L}$ will produce a term involving $\cos t$, but that term is absent on the right hand side. Therefore we need to ''seed'' a cosine term in the solution as well to offset the cosine produced by the operator. So we consider the following ansatz:

$$ y_p(t)=A\sin t + B\cos t. $$Plugging this in the nonhomogeneous ODE gives:

$$ (-A + 3B -4A)\sin t + (-B-3A-4B)\cos t = 2\sin t. $$Thus we have

$$ -A + 3B -4A = 2\quad\text{and}\quad -B-3A-4B=0. $$solving this *algebraic* system of equations for $A$ and $B$ gives:

and a particular solution of the nonhomogeneous equation is found:

$$ y_p(t)=-\frac{5}{17}\sin t +\frac{3}{17}\cos t. $$What if the right hand side is has a more complicated structure?

**Example:** Now consider the same ODE with the nonhomogeneity $g(t)=-8e^t\cos(2t)$:

The structure of the differential operator dictates us the ansatz

$$ y_p(t)=Ae^t\cos(2t) + Be^t\sin(2t), $$because the product rule for differentiation will produce linear combinations of such terms. Plugging this in the ODE gives:

$$ (-3A+4B -3A+6B-4A)e^t\cos(2t)+(-4A -3B -3B+6A-4B)e^t\sin(2t)=-8e^t\cos(2t), $$which results in the *algebraic system* for $A$ and $B$:

The unique solution to this system is:

$$ A=\frac{10}{3}\quad\text{and}\quad B=\frac{2}{13}, $$and hence a particular solution of the nonhomogeneous ODE is found:

$$ y_p(t)=\frac{10}{3} e^t\cos(2t) + \frac{2}{13}e^t\sin(2t). $$**Question:** What if $g(t)$ is even more complicated, involving several terms?

**Example:** Find a particular solution of $y''-3y'-4y=2\sin t+3e^{2t} + 4t^2$.

We can use a *divide and conquer* approach using the following principle.

**Superposition Principle for Nonhomogeneous Equations.**
Suppose we would like to find a solution of a nonhomogeneous equation of the form $\mathcal{L}[y]=g_1(t)+g_2(t)$. Let $y_1(t)$ be a solution of $\mathcal{L}[y]=g_1(t)$ and $y_2(t)$ be a solution of $\mathcal{L}[y]=g_2(t)$. Then the sum $y_1(t)+y_2(t)$ is a solution of $\mathcal{L}[y]=g_1(t)+g_2(t)$.

Now back to the example. Note that $g(t)=2\sin t+3e^{2t} + 4t^2$, set $\mathcal{L}[y]:=y''-3y'-4y$, and recall that we found a particular solution of

$$ \mathcal{L}[y]=2\sin t $$to be $y_{p,1}(t)=-\frac{5}{17}\sin t +\frac{3}{17}\cos t$. We have also found a particular solution of

$$ \mathcal{L}[y]=3e^{2t} $$to be $y_{p,2}(t)=-\frac{1}{2}e^{2t}$. We will now find a particular solution of

$$ \mathcal{L}[y]=4t^2. $$Since the right hand side is a second degree polynomial, we assume that the solution is of the form

$$ y_{p,3}(t)=At^2 + Bt + C. $$Plugging this into $\mathcal{L}[y]=4t^2$ gives: $A=-1$, $B=\frac{3}{2}$, and $C=-\frac{3}{8}$, hence

$$ y_{p,3}(t)=-t^2 + \frac{3}{2}t + \frac{3}{8}. $$Using the superposition principle, a particular solution of the equation

$$ \mathcal{L}[y]=2\sin t+3e^{2t} + 4t^2 $$is given by

$$ y_p(t)=y_{p,1}(t)+y_{p,2}(t)+y_{p,3}(t) = -\frac{5}{17}\sin t +\frac{3}{17}\cos t -\frac{1}{2}e^{2t}-t^2 + \frac{3}{2}t + \frac{3}{8}. $$Let's now proceed and find the general solution of the nonhomogeneous equation $\mathcal{L}[y]=2\sin t+3e^{2t} + 4t^2$. As we have a particular solution already, all we need to do is to find a general solution of the homogeneous equation $\mathcal{L}[y]=0$.

*Solving the homogeneous equation:* $\mathcal{L}[y]=0$ has the characteristic equation

which has two distinct real roots $\lambda_1 = 4$ and $\lambda_2=-1$. Then

$$ \bar{y}_1(t)=e^{4t}\quad\text{and}\quad \bar{y}_2(t)=e^{-t} $$form a fundamental set of solutions of $\mathcal{L}[y]=0$.

*General solution of the nonhomogeneous equation:* General solution of the nonhomogeneous equation $\mathcal{L}[y]=2\sin t+3e^{2t} + 4t^2$ is therefore given by

where $c_1$ and $c_2$ are to be determined by initial data given in an initial value problem.

The remarkable thing about the Method of Undetermined Coefficients (MOUC) is the fact that finding a solution of a differential equation boils down to solving a *linear system of* **algebraic** *equations*. This is straightforward to solve, especially when the differential equation has constant coefficients.

Therefore, given a nonhomogeneous second order linear differential equation, MOUC seems to be the first thing to try, but it has major shortcomings:

- MOUC only works when the external force term ($g(t)$, the nonhomogeneity) has a special form so that a second order linear differential operator can produce $g(t)$ with an appropriately chosen ansatz for the particular solution. For example, if the right handside is a rational function, the
*simple*approach we tried in this lecture wouldn't work, e.g.,

- But even in the case of 'simple' nonhomogeneity $g(t)$, MOUC might fail. Consider the following example:

**Example:** Find a particular solution of $y''-3y'-4y=2e^{-t}$.

As before, we take the ansatz $y_p(t)=A e^{-t}$ and plug this in the nonhomogeneous ODE. Doing so yields

$$ Ae^{-t}+ 3Ae^{-t}-4Ae^{-t}=2e^{-t} $$which enforces

$$ (A+3A-4A)=2. $$This equation obviously has no solution. Therefore, there is no value of $A$ such that $y_p(t)=A e^{-t}$ solves the nonhomogeneous equation. But why would that be?

This happens because the nonhomogeneity $g(t)=2e^{-t}$ is proportional to a solution of the homogeneous equation we found earlier $y_2(t)=e^{-t}$. Any function $y(t)=Ae^{-t}$ is a solution of the homogeneous equation, therefore it cannot possibly be a solution of the nonhomogeneous equation.

As we have seen today, MOUC applies in certain special cases, and when it applies, it is a very straightforward way to obtain a solution of a second order linear nonhomogenous differential equation. Please see Table 4.5.1 in the book for a summary including the forms of the solutions assumed given the structure of the nonhomogeneity.

We will soon cover the method called *Variation of Parameters*, which works in the cases MOUC fails.

```
In [ ]:
```