Find particular solution to nonhomogeneous DE $y'+y=x^2+\sin{x}+\cos{x}$

I'm new to nonhomogeneous DE's and I have come across this DE: $$y'+y=x^2+\sin{x}+\cos{x}$$ which I'm supposed to provide a general solution to. However, I get stuck with the particular solution. The part for solving the homogeneous part I managed easily: $$y'+y=0$$ which gave me $$y=ke^{-x}$$

From what I have understood, when making an approach to a particular solution, you should make sure that no part of the particular solution is part of the homogeneous one. So I made an approach with $$y_p=Ax^2+Bx+C+D\sin{x}+E\cos{x}$$ After inserting in the original equation that returned $$y_p=x^2+\sin{x}+\cos{x}$$Put differently, I received $A=1, B=0, C=0, D=1$ and $E=1$, which doesn't satisfy the equation.

So my questions are:

1. How would you approach the particular solution to this DE?
2. How are you supposed to make qualified guesses for DE's like this one where the right hand side is a mix of many kinds of functions?

Perhaps you could show your working?

When I substitute $y_p=Ax^2+Bx+C+D\sin{x}+E\cos{x}$ into $y'+y=x^2+\sin{x}+\cos{x}$, I get

$$y'+y=Ax^2+Bx+C+D\sin{x}+E\cos{x}+2Ax+B+D\cos{x}-E\sin{x}$$

whence

$$y'+y=Ax^2+(2A+B)x+B+C+(D-E)\sin{x}+(D+E)\cos{x}$$

which gives $A=1$, $B=-2$, $C=2$, $D=1$, $E=0$.

That gives

$$y_p=x^2-2x+2+\sin{x}$$

If you had shown your working, we could have seen what was different between your working and mine.

And the answer to your second question is: you were doing it exactly right, apart from whatever went wrong in the parts of your working you didn't tell us about.

• Thank you! I found the error in my working now. I derived $Ax^2$ as $Ax$ instead of $2Ax$. I continued from there and got the same answer as you did! Thank you! – El Aprendiz May 25 '16 at 18:54
• Also, are there any other general "rules" or helpful things to how to make guesses? Or at least good things to know? Just list as many as pop to your head! – El Aprendiz May 25 '16 at 18:56
• The rough rule for the method of undetermined coefficients is "the particular solution will be the same type of function as the forcing function." – Alex Pavellas May 26 '16 at 1:58
• I should add that this only works if your forcing functions are polynomials, exponentials, sinusoids or sums and products of them. – Alex Pavellas May 26 '16 at 2:00
• It is all a bit of a dark art, but fortunately the kinds of problems that are set as exercises are usually chosen to be tractable. Moreover, if you stick anything in that shouldn't be in, its coefficient ends up as 0 anyway. – Martin Kochanski May 26 '16 at 13:47

Use Laplace transform:

$$y'(x)+y(x)=x^2+\sin(x)+\cos(x)\Longleftrightarrow$$ $$\mathcal{L}_t\left[y'(x)+y(x)\right]_{(s)}=\mathcal{L}_t\left[x^2+\sin(x)+\cos(x)\right]_{(s)}\Longleftrightarrow$$ $$\mathcal{L}_t\left[y'(x)\right]_{(s)}+\mathcal{L}_t\left[y(x)\right]_{(s)}=\mathcal{L}_t\left[x^2\right]_{(s)}+\mathcal{L}_t\left[\sin(x)\right]_{(s)}+\mathcal{L}_t\left[\cos(x)\right]_{(s)}\Longleftrightarrow$$ $$sy(s)-y(0)+y(s)=\frac{2}{s^3}+\frac{1}{1+s^2}+\frac{s}{1+s^2}\Longleftrightarrow$$ $$y(s)\left[s+1\right]=\frac{2}{s^3}+\frac{1}{1+s^2}+\frac{s}{1+s^2}+y(0)\Longleftrightarrow$$ $$y(s)=\frac{\frac{2}{s^3}+\frac{1}{1+s^2}+\frac{s}{1+s^2}+y(0)}{1+s}\Longleftrightarrow$$ $$\mathcal{L}_s^{-1}\left[y(s)\right]_{(t)}=\mathcal{L}_s^{-1}\left[\frac{\frac{2}{s^3}+\frac{1}{1+s^2}+\frac{s}{1+s^2}+y(0)}{1+s}\right]_{(t)}\Longleftrightarrow$$ $$y(t)=2+e^{-x}(y(0)-2)+x(x-2)+\sin(x)$$

• I like this method very much. I was wondering if this differential equation could be solved with the Fourier Transform ? Have you tried doing that ? – Vivek Kaushik Oct 19 '16 at 5:31

Here is the integrating factor method. To briefly explain, if you are solving the (inseparable) differential equation in the form $$y'+p(x)y=q(x),$$ then you multiply both sides by $\mu(x)$ and the role of this $\mu(x)$ is to make the left hand side into the form $(y\mu(x))'$ (i.e. the reverse of the derivative product rule). It turns out $\mu(x)=e^{\int p(x)dx}$. Look up the details of this derivation. Then you take $$y(x)=\frac{\int q(x)\mu(x)dx+C}{\mu(x)},$$ where $C$ is your constant of integration.

Now in your differential equation, $\mu(x)=e^{\int 1 dx}=e^x$. Technically, it is supposed to be $e^{x+D}$, but it doesn't matter because the constant $D$ goes away once you simplify the solution in the end.

Now $$y(x)=\frac{\int x^2e^x+\sin(x)e^x+\cos(x)e^xdx +C}{e^x}$$ You can use integration by parts on each term inside the integral to see:

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

$y_p=Ax^2+Bx+C+D\sin x+E\cos x\\ y_p'=2Ax+B-E\sin x + Dcos x\\ y_p' + y_p = x^2 + \sin x + \cos x\\ A x^2 + (2A+B)x +(B+C) + (D-E)\sin x + (D+E)\cos x = x^2 + \sin x + \cos x\\ A = 1\\ 2A+B = 0\\ B+C = 0\\D-E = 1\\D+E = 1\\ A= 1, B = -2, C = 2, D = 1, E = 0$