DiffEq Home

## Linear Nonhomogeneous ODEs : Undetermined Coefficients

Consider the linear nonhomogeneous second order ODE $y''+p(x)y'+q(x)y=g(x). \;\;\;\;(38)$
Theorem. The general solution of the nonhomogeneous ODE (38) is $y=c_1y_1+c_2y_2+y_p,$ for arbitrary constants $$c_1$$ and $$c_2$$ where $$y_1$$ and $$y_2$$ are fundamental solutions of the corresponding homogeneous ODE $$y''+p(x)y'+q(x)y=0$$ and $$y_p$$ is a particular solution of (38).

Let $$y=\phi(x)$$ be a solution of (38). Then $\phi''+p \phi'+q\phi=g.$ Since $$y_p$$ is a particular solution of (38), we have $y_p''+p y_p'+qy_p=g.$ Using preceding two equations we get $(\phi-y_p)''+p (\phi-y_p)'+q(\phi-y_p)=g-g=0.$ Thus $$\phi-y_p$$ is solution of the homogeneous ODE $$y''+p(x)y'+q(x)y=0$$. So $$\phi-y_p$$ can be written as a linear combination of fundamental solutions $$y_1$$ and $$y_2$$. Thus \begin{align*} \phi-y_p&=c_1y_1+c_2y_2\\ \phi&=c_1y_1+c_2y_2+y_p.\; \blacksquare\\ \end{align*}

Theorem. The general solution of the nonhomogeneous ODE $y''+p(x)y'+q(x)y=g_1(x)+g_2(x)+\cdots+g_n(x). \;\;\;\;(39)$ is $y=c_1y_1+c_2y_2+y_{p_1}+y_{p_2}+\cdots+y_{p_n},$ for arbitrary constants $$c_1$$ and $$c_2$$ where $$y_1$$ and $$y_2$$ are fundamental solutions of the corresponding homogeneous ODE $$y''+p(x)y'+q(x)y=0$$ and $$y_{p_i}$$ is a particular solutions of $y''+p(x)y'+q(x)y=g_i(x),\; i=1,\ldots,n.$

Since $$y_{p_i}''+p(x)y_{p_i}'+q(x)y_{p_i}=g_i(x),\; i=1,\ldots,n$$, we have $(y_{p_1}+\cdots+y_{p_n})''+p(x)(y_{p_1}+\cdots+y_{p_n})'+q(x)(y_{p_1}+\cdots+y_{p_n})=g_1(x)+\cdots+g_n(x)=g(x).$ Thus $$y_{p_1}+\cdots+y_{p_n}$$ is a particular solution of (39). By the preceding theorem, the general solution of the nonhomogeneous ODE (39) is $y=c_1y_1+c_2y_2+y_{p_1}+y_{p_2}+\cdots+y_{p_n},$ for arbitrary constants $$c_1$$ and $$c_2$$. $$\blacksquare$$

Example. Find the general solution.

1. $$y''-2y'-3y=3e^{2x}$$

2. $$y''-2y'-3y=-65\cos(2x)$$

3. $$y''-2y'-3y=9x^2+1$$

Solution. The characteristic equation is \begin{align*} r^2-2r-3&=0\\ (r+1)(r-3)&=0\\ r&=-1,3. \end{align*} So the homogeneous solution is $y_h=c_1e^{-x}+c_2e^{3x},$ for arbitrary constants $$c_1$$ and $$c_2$$. Now we will find a particular solution of the nonhomogeneous ODE.

1. Let $$y_p=ae^{2x}$$ be a particular solution for some constant $$a$$. Then $$y_p'=2ae^{2x}$$ and $$y_p''=4ae^{2x}$$. Plugging these into $$y_p''-2y_p'-3y_p=3e^{2x}$$, we get \begin{align*} 4ae^{2x}-2\cdot 2ae^{2x}-3\cdot ae^{2x}&=3e^{2x}\\ (4a-4a-3a)e^{2x}&=3e^{2x}\\ -3a&=3\\ a&=-1. \end{align*} So $$y_p=-e^{2x}$$ is a particular solution. Thus the general solution is $y=y_h+y_p=c_1e^{-x}+c_2e^{3x}-e^{2x}.$

2. Let $$y_p=a\cos(2x)+b\sin(2x)$$ be a particular solution for some constants $$a,\; b$$. Then $$y_p'=-2a\sin(2x)+2b\cos(2x)$$ and $$y_p''=-4a\cos(2x)-4b\sin(2x)$$. Plugging these into $$y_p''-2y_p'-3y_p=-65\cos(2x)$$, we get \begin{align*} (-4a\cos(2x)-4b\sin(2x))-2\cdot(-2a\sin(2x)+2b\cos(2x)) -3\cdot(a\cos(2x)+b\sin(2x)) &=-65\cos(2x)\\ (-4a-4b-3a)\cos(2x)+(-4b+4a-3b)\sin(2x)&=-65\cos(2x)\\ (-7a-4b)\cos(2x)+(4a-7b)\sin(2x)&=-65\cos(2x) \end{align*} Comparing the coefficients of $$\cos(2x)$$ and $$\sin(2x)$$ in LHS and RHS, we get \begin{align*} -7a-4b&=-65 & 4a-7b&=0 \end{align*} Solving we get $$a=7,\; b=4$$. So the particular solution is $$y_p=7\cos(2x)+4\sin(2x)$$. Thus the general solution is $y=y_h+y_p=c_1e^{-x}+c_2e^{3x}+7\cos(2x)+4\sin(2x).$

3. Let $$y_p=ax^2+bx+c$$ be a particular solution for some constants $$a,b,c$$. Then $$y_p'=2ax+b$$ and $$y_p''=2a$$. Plugging these into $$y_p''-2y_p'-3y_p=9x^2+1$$, we get \begin{align*} 2a-2\cdot (2ax+b)-3\cdot (ax^2+bx+c)&=9x^2+1\\ -3ax^2+(-4a-3b)x+(2a-2b-3c)&=9x^2+1 \end{align*} Comparing the coefficients of $$x^2,x$$ and the constant term in LHS and RHS, we get \begin{align*} -3a&=9 & -4a-3b&=0 & 2a-2b-3c&=1 \end{align*} Solving we get $$a=-3,\; b=4,\; c=-5$$. So $$y_p=-3x^2+4x-5$$ is a particular solution. Thus the general solution is $y=y_h+y_p=c_1e^{-x}+c_2e^{3x}-3x^2+4x-5.$

To find a particular solution of the ODE $$ay''+by'+cy=g(x)$$ use the following table: $\begin{array}{|c|c|} \hline g(x)&y_p\\ \hline c_0x^n+c_1x^{n-1}+\cdots+c_n & x^s(a_0x^n+a_1x^{n-1}+\cdots+a_n)\\ \hline (c_0x^n+c_1x^{n-1}+\cdots+c_n)e^{rx} & x^s(a_0x^n+a_1x^{n-1}+\cdots+a_n)e^{rx}\\ \hline (c_0x^n+c_1x^{n-1}+\cdots+c_n)\cos(\theta x), & x^s[(a_0x^n+a_1x^{n-1}+\cdots+a_n)\cos(\theta x)+\\ (c_0x^n+c_1x^{n-1}+\cdots+c_n)\sin(\theta x)\; & \;(b_0x^n+b_1x^{n-1}+\cdots+b_n)\sin(\theta x)]\\ \hline (c_0x^n+c_1x^{n-1}+\cdots+c_n)\cos(\theta x)e^{rx}, & x^s[(a_0x^n+a_1x^{n-1}+\cdots+a_n)\cos(\theta x)+\\ (c_0x^n+c_1x^{n-1}+\cdots+c_n)\sin(\theta x)e^{rx}\; & (b_0x^n+b_1x^{n-1}+\cdots+b_n)\sin(\theta x)]e^{rx}\\ \hline \end{array}$ where $$s$$ is the smallest nonnegative integer $$(s = 0, 1, 2)$$ that will ensure that no term in $$y_p$$ is a solution of the corresponding homogeneous equation.

Example. Find the general solution.

1. $$y''+2y'-3y=16xe^{x}$$

2. $$y''+2y'-3y=-10x\sin x$$

3. $$y''+2y'-3y=16xe^{x}-10x\sin x$$

Solution. The characteristic equation is \begin{align*} r^2+2r-3&=0\\ (r-1)(r+3)&=0\\ r&=-3,1. \end{align*} So the homogeneous solution is $y_h=c_1e^{-3x}+c_2e^{x},$ for arbitrary constants $$c_1$$ and $$c_2$$. Now we will find a particular solution of the nonhomogeneous ODE.

1. Let $$y_p=(ax+b)e^{x}$$ be a particular solution for some constants $$a,b$$. Note that $$e^x$$ is already in the homogeneous solution. So let $$y_p=x(ax+b)e^{x}=(ax^2+bx)e^{x}$$ be a particular solution for some constants $$a,b$$. Then $$y_p'=[ax^2+(2a+b)x+b]e^{x}$$ and $$y_p''=[ax^2+(4a+b)x+2a+2b]e^{x}$$. Plugging these into $$y_p''+2y_p'-3y_p=16e^{x}$$, we get \begin{align*} [ax^2+(4a+b)x+2a+2b]e^{x}+2\cdot [ax^2+(2a+b)x+b]e^{x}-3\cdot (ax^2+bx)e^{x}&=16xe^{x}\\ [8ax+2a+4b]e^{x}&=16xe^{x}\\ 8ax+2a+4b&=16x. \end{align*} Comparing the coefficient $$x$$ and the constant term in LHS and RHS, we get \begin{align*} 8a&=16 & 2a+4b&=0 \end{align*} Solving we get $$a=2,\; b=-1$$. So $$y_p=(2x^2-x)e^{x}$$ is a particular solution. Thus the general solution is $y=y_h+y_p=c_1e^{-3x}+c_2e^{x}+(2x^2-x)e^{x}.$

2. Let $$y_p=(ax+b)\cos x+(cx+d)\sin x$$ be a particular solution for some constants $$a,b,c,d$$. Then $y_p'=(cx+a+d)\cos x+(-ax-b+c)\sin x,$ $y_p''=(-ax-b+2c)\cos x+(-cx-2a-d)\sin x.$ Plugging these into $$y_p''+2y_p'-3y_p=-10x\sin x$$, we get \begin{align*} [(-ax-b+2c)\cos x+(-cx-2a-d)\sin x]+2[(cx+a+d)\cos x+(-ax-b+c)\sin x]&\\ -3[(ax+b)\cos x+(cx+d)\sin x]&=-10x\sin x\\ (-2a-4c)x\sin x+(-2a-d-2b+2c-3d)\sin x+(-ax-b+2c+2cx+2a+2d-3ax-3b)\cos x&=-10x\sin x\\ (-2a-4c)x\sin x+(-2a-2b+2c-4d)\sin x+(-4a+2c)x\cos x+(2a-4b+2c+2d)\cos x&=-10x\sin x \end{align*} Comparing the coefficients of $$x\sin x$$, $$\sin x$$, $$x\cos x$$, and $$\cos x$$ in LHS and RHS, we get \begin{align*} -2a-4c&=-10, & -2a-2b+2c-4d&=0, & -4a+2c&=0,& 2a-4b+2c+2d&=0 \end{align*} Solving we get $$a=1,\; b=7/5,\; c=2,\; d=-1/5$$. So $y_p=(x+7/5)\cos x+(2x-1/5)\sin x$ is a particular solution. Thus the general solution is $y=y_h+y_p=c_1e^{-3x}+c_2e^{x}+(x+7/5)\cos x+(2x-1/5)\sin x.$

3. By preceding two parts and a theorem, $$(2x^2-x)e^{x}+(x+7/5)\cos x+(2x-1/5)\sin x$$ is a particular solution. Thus the general solution is $y=c_1e^{-3x}+c_2e^{x}+(2x^2-x)e^{x}+(x+7/5)\cos x+(2x-1/5)\sin x.$

Last edited