So far, we have solved only homogeneous equations.
And we have seen that there are plenty of applications!
However, there are many more situations which call for solving non-homogeneous equations.
In particular, mass spring systems with variable external forces, or circuits for which voltage varies with time.
Today, we begin learning how to deal with the non-homogeneous case.
General Background
Let $ Ly=y^{(n)}+p_{n-1}(x)y^{(n-1)}+\cdots+p_2(x)y''+p_1(x)y'+p_0(x)y=f(x) $ be a linear, non-homogeneous linear equation.
We seek a particular solution, $y_p,$ such that $ Ly_p=f(x). $
Then, if $y_h=y=C_1y_1+C_2y_2+\cdots+C_ny_n$ is the general solution to the corresponding homogeneous equation, the general solution to the non-homogeneous equation is $$y=y_h+y_p=C_1y_1+C_2y_2+\cdots+C_ny_n+y_p$$ since $$ \begin{array}{lll} \displaystyle Ly&\displaystyle=L(y_h+y_p) &\mbox{}\\ \displaystyle &\displaystyle=Ly_h+Ly_p &\mbox{}\\ \displaystyle &\displaystyle=0+f(x) &\mbox{}\\ \displaystyle &\displaystyle=f(x) &\mbox{}\\ \end{array} $$
Method of Undetermined Coefficients: The Big Idea
The method of undetermined coefficients is used to find a particular solution $y_p$ to a non-homogeneous equation with constant coefficients.
Let's consider a non-homogeneous example, $$ y''-7y'+12y=12x^2-2x+7 $$ We shall guess that a particular solution must have the form $y_p=Ax^2+Bx+C.$
The reasoning behind this guess is that derivatives of $y_p$ involve lower degree polynomials, so, combining these in the right way should enable us to reconstruct $f(x)=12x^2-2x+7.$
Method of Undetermined Coefficients: The Big Idea
For $y_p=Ax^2+Bx+C,$ it must be that $$ y_p''-7y_p'+12y_p=12x^2-2x+7 $$ Then $$ \begin{array}{lll} &\displaystyle (Ax^2+Bx+C)''-7(Ax^2+Bx+C)'+12(Ax^2+Bx+C)=12x^2-2x+7&\mbox{}\\ \implies &\displaystyle 2A-7(2Ax+B)+12Ax^2+12Bx+12C=12x^2-2x+7&\mbox{}\\ \implies &\displaystyle 2A-14Ax-7B+12Ax^2+12Bx+12C=12x^2-2x+7&\mbox{}\\ \implies &\displaystyle 12Ax^2+(-14A+12B)x+(2A-7B+12C)=12x^2-2x+7&\mbox{}\\ \end{array} $$ Thus, the (undetermined) coefficients must satisfy the system $$ \begin{cases} 12A& & &=&12\\ -14A& +12B& &=&-2\\ 2A& -7B& +12C&=&7\\ \end{cases} $$ Solving this system...
Method of Undetermined Coefficients: The Big Idea
We see that $A=1,$ $B=1,$ and $C=1.$
So the particular solution, $y_p,$ is $$ y_p=x^2+x+1 $$ Since the general solution to the corresponding homogeneous equation is $y_h=C_1e^{3x}+C_2e^{4x},$ the general solution to the non-homogeneous equation is $$ y=\underbrace{C_1e^{3x}+C_2e^{4x}}_{y_h}+\underbrace{x^2+x+1}_{y_p} $$
Method of Undetermined Coefficients: The Big Idea
The big idea of the method of undetermined coefficients is that a particular solution $y_p$ might look something like $f(x).$
For example, $y_p=x^2+x+1$ solves the equation $$ y''-7y'+12y=12x^2-2x+7 $$ That is, $y_p=x^2+x+1$ has the same form as $f(x)=12x^2-2x+7.$
Example
Find a particular solution $y_p$ and a general solution to the equation $$ y''-7y'+12y=4e^{2x} $$
We shall choose a particular solution of the form $y_p=Ae^{2x}.$
Then $$ \begin{array}{lll} &\displaystyle y_p''-7y_p'+12y=4e^{2x}&\mbox{}\\ \implies &\displaystyle (Ae^{2x})''-7(Ae^{2x})'+12(Ae^{2x})=4e^{2x}&\mbox{}\\ \implies &\displaystyle 4Ae^{2x}-7A(2e^{2x})+12Ae^{2x}=4e^{2x}&\mbox{}\\ \implies &\displaystyle 4Ae^{2x}-14Ae^{2x}+12Ae^{2x}=4e^{2x}&\mbox{}\\ \implies &\displaystyle 2Ae^{2x}=4e^{2x}&\mbox{}\\ \implies &\displaystyle 2A=4&\mbox{}\\ \implies &\displaystyle A=2&\mbox{}\\ \end{array} $$ Thus, the particular solution to the equation is $$ y_p=2e^{2x} $$ Since the general solution to the corresponding homogeneous equation is $y_h=C_1e^{3x}+C_2e^{4x},$ the general solution to the non-homogeneous equation is $$ y=\underbrace{C_1e^{3x}+C_2e^{4x}}_{y_h}+\underbrace{2e^{2x}}_{y_p} $$
Then $$ \begin{array}{lll} &\displaystyle y_p''-7y_p'+12y=4e^{2x}&\mbox{}\\ \implies &\displaystyle (Ae^{2x})''-7(Ae^{2x})'+12(Ae^{2x})=4e^{2x}&\mbox{}\\ \implies &\displaystyle 4Ae^{2x}-7A(2e^{2x})+12Ae^{2x}=4e^{2x}&\mbox{}\\ \implies &\displaystyle 4Ae^{2x}-14Ae^{2x}+12Ae^{2x}=4e^{2x}&\mbox{}\\ \implies &\displaystyle 2Ae^{2x}=4e^{2x}&\mbox{}\\ \implies &\displaystyle 2A=4&\mbox{}\\ \implies &\displaystyle A=2&\mbox{}\\ \end{array} $$ Thus, the particular solution to the equation is $$ y_p=2e^{2x} $$ Since the general solution to the corresponding homogeneous equation is $y_h=C_1e^{3x}+C_2e^{4x},$ the general solution to the non-homogeneous equation is $$ y=\underbrace{C_1e^{3x}+C_2e^{4x}}_{y_h}+\underbrace{2e^{2x}}_{y_p} $$
Example
Find a particular solution $y_p$ and a general solution to the equation $$ y''-7y'+12y=5e^{4x} $$ Given that $y_h=C_1e^{3x}+C_2e^{4x},$ does anyone anticipate any issues?
Naively, we would guess $y_p=Ae^{4x}$ as the form of our particular solution.
However, our choice of $y_p$ solves the homogeneous equation!
What ever shall we do?????
Answer: We amend our guess to $$ y_p=Axe^{4x} $$ It turns out that this amended guess will work as our particular solution. (Notice that these are the same shenanigans we pulled when we needed to find a second linearly independent solution to the homogeneous equation.)
Then $$ \begin{array}{lll} &\displaystyle y_p''-7y_p'+12y=5e^{4x}&\mbox{}\\ \implies &\displaystyle (Axe^{4x})''-7(Axe^{4x})'+12(Axe^{4x})=5e^{4x}&\mbox{}\\ \implies &\displaystyle (Ae^{4x}+4Axe^{2x})'-7(Ae^{4x}+4Axe^{2x})+12Axe^{4x}=5e^{4x}&\mbox{}\\ \implies &\displaystyle 4Ae^{4x}+4(Ae^{4x}+4Axe^{2x})-7Ae^{4x}-28Axe^{2x}+12Axe^{4x}=5e^{4x}&\mbox{}\\ \implies &\displaystyle 4Ae^{4x}+4Ae^{4x}+\color{magenta}{16Axe^{2x}}-7Ae^{4x}\color{magenta}{-28Axe^{2x}}\color{magenta}{+12Axe^{4x}}=5e^{4x}&\mbox{}\\ \implies &\displaystyle Ae^{4x}=5e^{4x}&\mbox{}\\ \implies &\displaystyle A=5&\mbox{}\\ \end{array} $$ Thus, the particular solution to the equation is $$ y_p=5xe^{4x} $$ Since the general solution to the corresponding homogeneous equation is $y_h=C_1e^{3x}+C_2e^{4x},$ the general solution to the non-homogeneous equation is $$ y=\underbrace{C_1e^{3x}+C_2e^{4x}}_{y_h}+\underbrace{5xe^{4x}}_{y_p} $$
However, our choice of $y_p$ solves the homogeneous equation!
What ever shall we do?????
Answer: We amend our guess to $$ y_p=Axe^{4x} $$ It turns out that this amended guess will work as our particular solution. (Notice that these are the same shenanigans we pulled when we needed to find a second linearly independent solution to the homogeneous equation.)
Then $$ \begin{array}{lll} &\displaystyle y_p''-7y_p'+12y=5e^{4x}&\mbox{}\\ \implies &\displaystyle (Axe^{4x})''-7(Axe^{4x})'+12(Axe^{4x})=5e^{4x}&\mbox{}\\ \implies &\displaystyle (Ae^{4x}+4Axe^{2x})'-7(Ae^{4x}+4Axe^{2x})+12Axe^{4x}=5e^{4x}&\mbox{}\\ \implies &\displaystyle 4Ae^{4x}+4(Ae^{4x}+4Axe^{2x})-7Ae^{4x}-28Axe^{2x}+12Axe^{4x}=5e^{4x}&\mbox{}\\ \implies &\displaystyle 4Ae^{4x}+4Ae^{4x}+\color{magenta}{16Axe^{2x}}-7Ae^{4x}\color{magenta}{-28Axe^{2x}}\color{magenta}{+12Axe^{4x}}=5e^{4x}&\mbox{}\\ \implies &\displaystyle Ae^{4x}=5e^{4x}&\mbox{}\\ \implies &\displaystyle A=5&\mbox{}\\ \end{array} $$ Thus, the particular solution to the equation is $$ y_p=5xe^{4x} $$ Since the general solution to the corresponding homogeneous equation is $y_h=C_1e^{3x}+C_2e^{4x},$ the general solution to the non-homogeneous equation is $$ y=\underbrace{C_1e^{3x}+C_2e^{4x}}_{y_h}+\underbrace{5xe^{4x}}_{y_p} $$
Example
Find a particular solution $y_p$ and a general solution to the equation $$ y''-8y'+16y=2e^{4x} $$ Given that $y_h=C_1e^{4x}+C_2xe^{4x},$ does anyone anticipate any issues?
Again, our initial guess for $y_p$ might be
$$
y_p=Ae^{4x}
$$
Of course, since this is a solution to the homogeneous equation, this won't work.
In our previous example, we amended our particular solution to have the form $$ y_p=Axe^{4x} $$ but this is also a solution to the homogeneous equation.
What ever shall we do?????
Well, again, fear not; we just throw in another factor of $x.$
That is, we we guess that $y_p$ has the form $$ y_p=Ax^2e^{4x} $$ It turns out that this amended guess will work as our particular solution. $$ \begin{array}{lll} &\displaystyle y_p''-8y_p'+16y=2e^{4x}&\mbox{}\\ \implies &\displaystyle (Ax^2e^{4x})''-8(Ax^2e^{4x})'+16(Ax^2e^{4x})=2e^{4x}&\mbox{}\\ \implies &\displaystyle (2Axe^{4x}+4Ax^2e^{4x})'-8(2Axe^{4x}+4Ax^2e^{4x})+16Ax^2e^{4x}=2e^{4x}&\mbox{}\\ \implies &\displaystyle 2A(e^{4x}+4xe^{4x})+4A(2xe^{4x}+4x^2e^{4x})-16Axe^{4x}-32Ax^2e^{4x}+16Ax^2e^{4x}=2e^{4x}&\mbox{}\\ \implies &\displaystyle 2Ae^{4x}\color{magenta}{+8xe^{4x}}+\color{magenta}{8Axe^{4x}}\color{blue}{+16Ax^2e^{4x}}\color{magenta}{-16Axe^{4x}}\color{blue}{-32Ax^2e^{4x}}\color{blue}{+16Ax^2e^{4x}}=2e^{4x}&\mbox{}\\ \implies &\displaystyle 2Ae^{4x}=2e^{4x}&\mbox{}\\ \implies &\displaystyle 2A=2&\mbox{}\\ \implies &\displaystyle A=1&\mbox{}\\ \end{array} $$ Thus, the particular solution to the equation is $$ y_p=x^2e^{4x} $$ Since the general solution to the corresponding homogeneous equation is $y_h=C_1e^{4x}+C_2xe^{4x},$ the general solution to the non-homogeneous equation is $$ y=\underbrace{C_1e^{4x}+C_2xe^{4x}}_{y_h}+\underbrace{x^2e^{4x}}_{y_p}=(C_1+C_2 x+x^2)e^{4x} $$
In our previous example, we amended our particular solution to have the form $$ y_p=Axe^{4x} $$ but this is also a solution to the homogeneous equation.
What ever shall we do?????
Well, again, fear not; we just throw in another factor of $x.$
That is, we we guess that $y_p$ has the form $$ y_p=Ax^2e^{4x} $$ It turns out that this amended guess will work as our particular solution. $$ \begin{array}{lll} &\displaystyle y_p''-8y_p'+16y=2e^{4x}&\mbox{}\\ \implies &\displaystyle (Ax^2e^{4x})''-8(Ax^2e^{4x})'+16(Ax^2e^{4x})=2e^{4x}&\mbox{}\\ \implies &\displaystyle (2Axe^{4x}+4Ax^2e^{4x})'-8(2Axe^{4x}+4Ax^2e^{4x})+16Ax^2e^{4x}=2e^{4x}&\mbox{}\\ \implies &\displaystyle 2A(e^{4x}+4xe^{4x})+4A(2xe^{4x}+4x^2e^{4x})-16Axe^{4x}-32Ax^2e^{4x}+16Ax^2e^{4x}=2e^{4x}&\mbox{}\\ \implies &\displaystyle 2Ae^{4x}\color{magenta}{+8xe^{4x}}+\color{magenta}{8Axe^{4x}}\color{blue}{+16Ax^2e^{4x}}\color{magenta}{-16Axe^{4x}}\color{blue}{-32Ax^2e^{4x}}\color{blue}{+16Ax^2e^{4x}}=2e^{4x}&\mbox{}\\ \implies &\displaystyle 2Ae^{4x}=2e^{4x}&\mbox{}\\ \implies &\displaystyle 2A=2&\mbox{}\\ \implies &\displaystyle A=1&\mbox{}\\ \end{array} $$ Thus, the particular solution to the equation is $$ y_p=x^2e^{4x} $$ Since the general solution to the corresponding homogeneous equation is $y_h=C_1e^{4x}+C_2xe^{4x},$ the general solution to the non-homogeneous equation is $$ y=\underbrace{C_1e^{4x}+C_2xe^{4x}}_{y_h}+\underbrace{x^2e^{4x}}_{y_p}=(C_1+C_2 x+x^2)e^{4x} $$
When $f(x)$ has the Same Form as Solutions to the Homogeneous Equation
The above examples show us that when $f(x)$ has the same form as one of our linearly independent solutions to the homogeneous equation, we multiply our guess $y_g$ by suitable a power $\ell$ of $x.$
The power we choose is the smallest non-negative integer $\ell$ such that $x^{\ell} y_g$ does does not appear as a solution to the homogeneous equation.
If our guess $y_g$ has multiple terms, then $x^{\ell} y_g$ cannot contain any terms which solve the homogeneous equation.
Example
Find a particular solution $y_p$ and a general solution to the equation $$ y''-3y'+2y=(x^2+2x-1)e^{3x} $$
The solution to the homogeneous equation is $y_h=C_1e^{x}+Ce^{2x}.$
Since $f(x)=(x^2+2x-1)e^{3x},$ and since none of the terms in this expression are solutions to the homogeneous equation, we choose the form of our particular solution to be $$y_p=(Ax^2+Bx+C)e^{3x}$$ Then, $$ \begin{array}{lll} \displaystyle y_p'&\displaystyle=((Ax^2+Bx+C)e^{3x})' &\mbox{}\\ \displaystyle &\displaystyle=(2Ax+B)e^{3x}+3(Ax^2+Bx+C)e^{3x} &\mbox{}\\ \displaystyle &\displaystyle=[(2Ax+B)+3(Ax^2+Bx+C)]e^{3x} &\mbox{}\\ \displaystyle &\displaystyle=[3Ax^2+(2A+3B)x+B+3C]e^{3x} &\mbox{}\\ \end{array} $$ and $$ \begin{array}{lll} \displaystyle y_p''&\displaystyle=((Ax^2+Bx+C)e^{3x})'' &\mbox{}\\ \displaystyle &\displaystyle=([3Ax^2+(2A+3B)x+B+3C]e^{3x})' &\mbox{}\\ \displaystyle &\displaystyle=[6Ax+2A+3B]e^{3x}+3[3Ax^2+(2A+3B)x+B+3C]e^{3x} &\mbox{}\\ \displaystyle &\displaystyle=\left([6Ax+2A+3B]+3[3Ax^2+(2A+3B)x+B+3C]\right)e^{3x} &\mbox{}\\ \displaystyle &\displaystyle=\left(\color{blue}{6Ax}\color{red}{+2A+3B}\color{magenta}{+9Ax^2}\color{blue}{+(6A+9B)x}\color{red}{+3B+9C}\right)e^{3x} &\mbox{}\\ \displaystyle &\displaystyle=\left(\color{magenta}{9Ax^2}+\color{blue}{(12A+9B)x}+\color{red}{2A+6B+9C}\right)e^{3x} &\mbox{}\\ %\displaystyle &\displaystyle=\left(9Ax^2+(12A+9B)x+2A+6B+9C\right)e^{3x} &\mbox{}\\ \end{array} $$ So, $$ \begin{array}{lll} &\displaystyle y_p''-3y_p'+2y_p=(x^2+2x-1)e^{3x} &\mbox{}\\ \implies &\displaystyle \left(9Ax^2+(12A+9B)x+2A+6B+9C\right)e^{3x}-3[3Ax^2+(2A+3B)x+B+3C]e^{3x}+2((Ax^2+Bx+C)e^{3x})=(x^2+2x-1)e^{3x}&\mbox{}\\ \implies &\displaystyle 9Ax^2+(12A+9B)x+2A+6B+9C-3(3Ax^2+(2A+3B)x+B+3C)+2(Ax^2+Bx+C)=x^2+2x-1&\mbox{}\\ \implies &\displaystyle \color{magenta}{9Ax^2}\color{blue}{+(12A+9B)x}\color{red}{+2A+6B+9C}\color{magenta}{-9Ax^2}\color{blue}{+(-6A-9B)x}\color{red}{-3B-9C}\color{magenta}{+2Ax^2}\color{blue}{+2Bx}\color{red}{+2C}=x^2+2x-1&\mbox{}\\ \implies &\displaystyle \color{magenta}{2Ax^2}\color{blue}{+(6A+2B)x}\color{red}{+2A+3B+2C}=x^2+2x-1&\mbox{}\\ \implies &\displaystyle \begin{cases} 2A & & &=1\\ 6A &+2B& &=2\\ 2A &+3B &+2C &=-1\\ \end{cases}&\mbox{}\\ \end{array} $$ Solving this system gives $\displaystyle A=\frac{1}{2},$ $\displaystyle B=-\frac{1}{2},$ and $\displaystyle C=-\frac{1}{4}.$
Thus, $$ y_p=\left(Ax^2+Bx+C\right)e^{3x}=\left(\frac{1}{2}x^2-\frac{1}{2}x+\frac{1}{4}\right)e^{3x}=\frac{1}{4}e^{3x}(2x^2-2x+1) $$ Since the general solution to the corresponding homogeneous equation is $y_h=C_1e^{4x}+C_2xe^{4x},$ the general solution to the non-homogeneous equation is $$ y=\underbrace{C_1e^{x}+Ce^{2x}}_{y_h}+\underbrace{\frac{1}{4}e^{3x}(2x^2-2x+1)}_{y_p} $$
Since $f(x)=(x^2+2x-1)e^{3x},$ and since none of the terms in this expression are solutions to the homogeneous equation, we choose the form of our particular solution to be $$y_p=(Ax^2+Bx+C)e^{3x}$$ Then, $$ \begin{array}{lll} \displaystyle y_p'&\displaystyle=((Ax^2+Bx+C)e^{3x})' &\mbox{}\\ \displaystyle &\displaystyle=(2Ax+B)e^{3x}+3(Ax^2+Bx+C)e^{3x} &\mbox{}\\ \displaystyle &\displaystyle=[(2Ax+B)+3(Ax^2+Bx+C)]e^{3x} &\mbox{}\\ \displaystyle &\displaystyle=[3Ax^2+(2A+3B)x+B+3C]e^{3x} &\mbox{}\\ \end{array} $$ and $$ \begin{array}{lll} \displaystyle y_p''&\displaystyle=((Ax^2+Bx+C)e^{3x})'' &\mbox{}\\ \displaystyle &\displaystyle=([3Ax^2+(2A+3B)x+B+3C]e^{3x})' &\mbox{}\\ \displaystyle &\displaystyle=[6Ax+2A+3B]e^{3x}+3[3Ax^2+(2A+3B)x+B+3C]e^{3x} &\mbox{}\\ \displaystyle &\displaystyle=\left([6Ax+2A+3B]+3[3Ax^2+(2A+3B)x+B+3C]\right)e^{3x} &\mbox{}\\ \displaystyle &\displaystyle=\left(\color{blue}{6Ax}\color{red}{+2A+3B}\color{magenta}{+9Ax^2}\color{blue}{+(6A+9B)x}\color{red}{+3B+9C}\right)e^{3x} &\mbox{}\\ \displaystyle &\displaystyle=\left(\color{magenta}{9Ax^2}+\color{blue}{(12A+9B)x}+\color{red}{2A+6B+9C}\right)e^{3x} &\mbox{}\\ %\displaystyle &\displaystyle=\left(9Ax^2+(12A+9B)x+2A+6B+9C\right)e^{3x} &\mbox{}\\ \end{array} $$ So, $$ \begin{array}{lll} &\displaystyle y_p''-3y_p'+2y_p=(x^2+2x-1)e^{3x} &\mbox{}\\ \implies &\displaystyle \left(9Ax^2+(12A+9B)x+2A+6B+9C\right)e^{3x}-3[3Ax^2+(2A+3B)x+B+3C]e^{3x}+2((Ax^2+Bx+C)e^{3x})=(x^2+2x-1)e^{3x}&\mbox{}\\ \implies &\displaystyle 9Ax^2+(12A+9B)x+2A+6B+9C-3(3Ax^2+(2A+3B)x+B+3C)+2(Ax^2+Bx+C)=x^2+2x-1&\mbox{}\\ \implies &\displaystyle \color{magenta}{9Ax^2}\color{blue}{+(12A+9B)x}\color{red}{+2A+6B+9C}\color{magenta}{-9Ax^2}\color{blue}{+(-6A-9B)x}\color{red}{-3B-9C}\color{magenta}{+2Ax^2}\color{blue}{+2Bx}\color{red}{+2C}=x^2+2x-1&\mbox{}\\ \implies &\displaystyle \color{magenta}{2Ax^2}\color{blue}{+(6A+2B)x}\color{red}{+2A+3B+2C}=x^2+2x-1&\mbox{}\\ \implies &\displaystyle \begin{cases} 2A & & &=1\\ 6A &+2B& &=2\\ 2A &+3B &+2C &=-1\\ \end{cases}&\mbox{}\\ \end{array} $$ Solving this system gives $\displaystyle A=\frac{1}{2},$ $\displaystyle B=-\frac{1}{2},$ and $\displaystyle C=-\frac{1}{4}.$
Thus, $$ y_p=\left(Ax^2+Bx+C\right)e^{3x}=\left(\frac{1}{2}x^2-\frac{1}{2}x+\frac{1}{4}\right)e^{3x}=\frac{1}{4}e^{3x}(2x^2-2x+1) $$ Since the general solution to the corresponding homogeneous equation is $y_h=C_1e^{4x}+C_2xe^{4x},$ the general solution to the non-homogeneous equation is $$ y=\underbrace{C_1e^{x}+Ce^{2x}}_{y_h}+\underbrace{\frac{1}{4}e^{3x}(2x^2-2x+1)}_{y_p} $$
Example
Determine the form of a particular solution $y_p$ for the equation $$ y''-4y'+3y=(12x^2+8x+6)e^{3x} $$
The solution to the homogeneous equation is $y_h=C_1e^{x}+Ce^{3x}.$
Since $f(x)=(12x^2+8x+6)e^{3x},$ our initial guess for our particular solution is $$y_g=(Ax^2+Bx+C)e^{3x}=Ax^2e^{3x}+Bxe^{3x}+Ce^{3x}$$ However, we notice that the last term solves the homogeneous equation.
Thus, we multiply the above by $x$ (in this case $\ell=1$) so that our amended particular solution is $$ y_p=xy_g=x(Ax^2+Bx+C)e^{3x}=(Ax^3+Bx^2+Cx)e^{3x} $$ We know that $\ell=1$ is the correct choice since no term in $x_p=xy_g$ solves the homogeneous equation.
Since $f(x)=(12x^2+8x+6)e^{3x},$ our initial guess for our particular solution is $$y_g=(Ax^2+Bx+C)e^{3x}=Ax^2e^{3x}+Bxe^{3x}+Ce^{3x}$$ However, we notice that the last term solves the homogeneous equation.
Thus, we multiply the above by $x$ (in this case $\ell=1$) so that our amended particular solution is $$ y_p=xy_g=x(Ax^2+Bx+C)e^{3x}=(Ax^3+Bx^2+Cx)e^{3x} $$ We know that $\ell=1$ is the correct choice since no term in $x_p=xy_g$ solves the homogeneous equation.
The Principle of Superposition
Suppose we want to solve the equation $$ Ly=f_1(x)+f_2(x)=f(x) $$ That is, $f(x)$ has multiple terms.
What do we do?
The Principle of Superposition
Consider the linear equation $$ Ly=f_1(x)+f_2(x)=f(x) $$ If $$Ly_{p_1}=f_1(x)\,\,\,\,\mbox{and}\,\,\,\, Ly_{p_2}=f_2(x)$$ then $$L(y_{p_1}+y_{p_2})=f(x)$$
That is, $y_p=y_{p_1}+y_{p_2}$ solves $Ly=f(x).$
$$
\begin{array}{lll}
\displaystyle L(y_{p})&\displaystyle=L(y_{p_1}+y_{p_2}) &\mbox{}\\
\displaystyle &\displaystyle=Ly_{p_1}+Ly_{p_2} &\mbox{}\\
\displaystyle &\displaystyle=f_1(x)+f_2(x) &\mbox{}\\
\displaystyle &\displaystyle=f(x) &\mbox{}\\
\end{array}
$$
Example
Find a particular solution $y_p$ and a general solution to the equation $$y''-7y'+12y=4e^{2x}+12x^2-2x+7$$
In this example, $f(x)=4e^{2x}+12x^2-2x+7.$
So, we take $f_1(x)=4e^{2x}$ and $f_2(x)=12x^2-2x+7.$
From the previous examples we saw that $$y_{p_1}=2e^{2x} \,\,\,\,\mbox{solves}\,\,\,\, y''-7y'+12y=4e^{2x}$$ and $$y_{p_2}=x^2+x+1 \,\,\,\,\mbox{solves}\,\,\,\, y''-7y'+12y=12x^2-2x+7$$ Thus, our particular solution to the original equation is $$ y_p=\underbrace{2e^{2x}}_{y_{p_1}}+\underbrace{x^2+x+1}_{y_{p_2}} $$ Since the general solution to the corresponding homogeneous equation is $y_h=C_1e^{3x}+C_2e^{4x},$ the general solution to the non-homogeneous equation is $$ y=\underbrace{C_1e^{3x}+C_2e^{4x}}_{y_h}+\underbrace{2e^{2x}+x^2+x+1}_{y_p} $$
So, we take $f_1(x)=4e^{2x}$ and $f_2(x)=12x^2-2x+7.$
From the previous examples we saw that $$y_{p_1}=2e^{2x} \,\,\,\,\mbox{solves}\,\,\,\, y''-7y'+12y=4e^{2x}$$ and $$y_{p_2}=x^2+x+1 \,\,\,\,\mbox{solves}\,\,\,\, y''-7y'+12y=12x^2-2x+7$$ Thus, our particular solution to the original equation is $$ y_p=\underbrace{2e^{2x}}_{y_{p_1}}+\underbrace{x^2+x+1}_{y_{p_2}} $$ Since the general solution to the corresponding homogeneous equation is $y_h=C_1e^{3x}+C_2e^{4x},$ the general solution to the non-homogeneous equation is $$ y=\underbrace{C_1e^{3x}+C_2e^{4x}}_{y_h}+\underbrace{2e^{2x}+x^2+x+1}_{y_p} $$
Reminder
The method of undetermined coefficients only works nicely for linear, constant-coefficient equations.
We will learn more general methods later.
Finding Particular Solutions to $Ly=f(x)$
$$ \begin{array}{ll} f(x) & \mbox{Form of }\,\,y_p\\\hline a_nx^n+\cdots+a_1x+a_0 & \color{magenta}{x^{\ell}}\left(A_nx^n+\cdots+A_1x+A_0\right)\\ ae^{\alpha x} & \color{magenta}{x^{\ell}}Ae^{\alpha x}\\ (a_nx^n+\cdots+a_1x+a_0 )e^{\alpha x} & \color{magenta}{x^{\ell}}\left(A_nx^n+\cdots+A_1x+A_0\right)e^{\alpha x}\\ %a\cos(\beta x)+b\sin(\beta x) & \color{magenta}{x^{\ell}}(A\cos(\beta x)+B\sin(\beta x)) \\ %p(x)\cos(\beta x)+q(x)\sin(\beta x) & \color{magenta}{x^{\ell}}(P(x)\cos(\beta x)+Q(x)\sin(\beta x)) \\ %ae^{\alpha x}\cos(\beta x)+be^{\alpha x}\sin(\beta x) & \color{magenta}{x^{\ell}}(Ae^{\alpha x}\cos(\beta x)+Be^{\alpha x}\sin(\beta x)) \\ %p(x)e^{\alpha x}\cos(\beta x)+q(x)\sin(\beta x) & \color{magenta}{x^{\ell}}(P(x)e^{\alpha x}\cos(\beta x)+Q(x)e^{\alpha x}\sin(\beta x)) \\ \end{array} $$ $\ell$ is the smallest non-negative integer such that $y_p=x^{\ell}y_g$ has no terms which solve the homogeneous equation.