# particular solution to nonhomogenous equation

I want to solve the ODE $y''+4y=x^2+3e^x$

I already found the complemenetary homogenous solutions: $y_1=\cos (2x)$ and $y_2=\sin (2x)$ and also found the wronskian: $|W|=2$

Now, according to http://tutorial.math.lamar.edu/Classes/DE/VariationofParameters.aspx the variation of parameters method states that the particular solution is:

$$y_p = -\cos (2x)\int \frac{ \sin (2x)(x^2+3e^x)}{2}dx+\sin (2x)\int \frac{ \cos (2x)(x^2+3e^x)}{2}dx$$

This isn't the most pleasant integral I've seen. Far from it, it doesn't seem feasible to calculate it. Is there another method to find the particular solution?

• Those integrals can be computed by parts, with multiple rounds. – user170231 Feb 4 '15 at 21:40

Yes there is another method which is known as the undetermined coefficients. According to it we assume the particular solution to have the form

$$y_p = A+Bx+cx^2 + De^x \longrightarrow (1)$$

where constants $A,B,C,D$ need to be determined by substituting $y_p, y'_p, y''_p$ in the ode.

The method of undetermined coefficients makes things much simpler.

It is not difficult to check that: $$f(x) = \frac{x^2}{4}-\frac{1}{8}+\frac{3}{5}e^x$$ is a solution, so by setting $y(x) = g(x)+f(x)$ we have that $g$ satisfies the homogeneous ODE: $$g''+4g = 0,$$ for which you already know the solutions.

I am a fan of the Laplace transform technique: $$\mathcal{L}\left\{y''+4y=x^2+3e^x \right\} \\ \implies s^2Y(s)-y'(0)-sy(0)+4Y(s)=\frac{2}{s^3}+\frac{3}{s-1} \\ \implies Y(s)(s^2+4) = \frac{2}{s^3}+\frac{3}{s-1}+y'(0)+sy(0) \\ \implies Y(s) = \frac{2}{s^3(s^2+4)}+\frac{3}{(s-1)(s^2+4)}+\frac{y'(0)}{s^2+4}+\frac{sy(0)}{s^2+4}$$ Then use partial fraction decomposition on $\frac{2}{s^3(s^2+4)}$ and $\frac{3}{(s-1)(s^2+4)}$ to get $$\frac{2}{s^3(s^2+4)}=\frac{1}{2s^3}+\frac{s}{8(s^2+4)}-\frac{1}{8s} \\ \frac{3}{(s-1)(s^2+4)}= \frac{3}{5(s-1)}-\frac{3s}{5(s^2+4)}-\frac{3}{5(s^2+4)}$$ Hence $$Y(s) = \frac{1}{2s^3}+\frac{s}{8(s^2+4)}-\frac{1}{8s}+\frac{3}{5(s-1)}-\frac{3s}{5(s^2+4)}-\frac{3}{5(s^2+4)}+\frac{y'(0)}{s^2+4}+\frac{sy(0)}{s^2+4}$$ and undoing the transform should reveal $$y(x) = \frac{x^2}{4}+\frac{1}{8}\cos(2x)-\frac{1}{8}+\frac{3}{5}e^x-\frac{3}{5}\cos(2x)-\frac{3}{10}\sin(2x)+\frac{y'(0)}{2}\sin(2x)+y(0)\cos(2x) \\ = \frac{x^2}{4}-\frac{1}{8}+\cos(2x)\left(y(0)-\frac{19}{40}\right)+\sin(2x)\left(y'(0)-\frac{3}{10} \right)+\frac{3}{5}e^x$$ This is the solution for whatever initial conditions $y(0), \space y'(0)$ you want. While the method is algebra intensive, you don't have to integrate anything.

\begin{align*}\int\frac{\sin2x(x^2+3e^x)}{2}\,dx&=\frac{1}{2}\left(\int x^2\sin2x\,dx+3\int e^x\sin2x\right)\end{align*} Integrating by parts, you can find that \begin{align*}\int x^2\sin2x\,dx&=-\frac{1}{2}x^2\cos2x+\int x\cos2x\,dx\\ &=-\frac{1}{2}x^2\cos2x+\frac{1}{2}x\sin2x-\frac{1}{2}\int\sin2x\,dx\\ &=-\frac{1}{2}x^2\cos2x+\frac{1}{2}x\sin2x+\frac{1}{4}\cos2x+C_1\end{align*} Similarly, \begin{align*} \int e^x\sin2x&=-\frac{1}{2}e^x\cos2x+\frac{1}{2}\int e^x\cos2x\,dx\\ &=-\frac{1}{2}e^x\cos2x+\frac{1}{2}\left(\frac{1}{2}e^x\sin2x-\frac{1}{2}\int e^x\sin2x\,dx\right)\\ &=-\frac{1}{2}e^x\cos2x+\frac{1}{4}e^x\sin2x-\frac{1}{4}\int e^x\sin2x\,dx\\ \frac{5}{4}\int e^x\sin2x\,dx&=-\frac{1}{2}e^x\cos2x+\frac{1}{4}e^x\sin2x\\ \int e^x\sin2x\,dx&=-\frac{2}{5}e^x\cos2x+\frac{1}{5}e^x\sin2x+C_2\end{align*}