# Solving a nonhomogeneous 2nd order ode

1. Jun 14, 2013

### Iacha

Hi, everyone! This is my first post here, I need an hand with this equation!

1. The problem statement, all variables and given/known data
Solve the initial value problem:

\begin{cases}
u''(x)+4u(x)=\cos(2x)
\\u(0)=u'(0)=1
\end{cases}

3. The attempt at a solution
I started by solving the associated homogeneous linear equation $$u''(x)+4u(x)=0$$ by the usual method of substituting the trial solution $$u(x)=e^{\lambda x}$$.
One obtains \begin{aligned} &\lambda^2+4=0 \\ &\lambda = \pm 2i \\ &u(x)=C_1\cos(2x)+C_2\sin(2x)\end{aligned}

To find the particular solution I use the method of undetermined coefficients with $$u(x)_p=x(A\cos(2x)+B\sin(2x)).$$
Differentiating and substituting back in the ODE I get $$u(x)_p=\frac{1}{4}\cos(2x)$$ which is not good. I don't think I made some mistakes in the differentiation process since I checked my calculations with Maple.

2. Jun 14, 2013

### ehild

Welcome to PF!
Your particular solution is not correct. First, it should contain the factor x. Show please, how you arrived to the result A=1/4 B=0.

ehild

Last edited: Jun 14, 2013
3. Jun 15, 2013

### Iacha

I did again the calculation and this time I think I got it right,
Starting from the test solution:
$$u(x)=x(A\cos(2x)+B\sin(2x))$$
by applying the usual rules of differentiation one obtains:
$$u(x)''= 0(A\cos(2x)+B\sin(2x)) + 2(-2Asin(2x)+2B\cos(2x))+x( -4A\cos(2x)-4B\sin(2x))$$
which is
$$u(x)''=-4A\sin(2x)+4B\cos(2x)+x(-4A\cos(2x)-4B\sin(2x))$$

Now, putting this back into the original equation $$u(x)''+4u(x)=cos(2x)$$ yelds
$$-4A\sin(2x)+4B\cos(2x)-4x(A\cos(2x)+B\sin(2x))+4x(A\cos(2x)+B\sin(2x))= cos(2x)$$
Simplifying:
$$-4A\sin(2x)+4B\cos(2x)=cos(2x)$$
I obtained $$A=0 B=1/4$$

So what I get from the calculation is $$u(x)=x(\frac{1}{4}\sin(2x))$$ which is a particular solution for the ODE, now one can write the general solution in the form:
$$u(x)=C_1\cos(2x)+C_2\sin(2x)+x(\frac{1}{4}\sin(2x))$$

Appereantly yesterday I substituted back the parameters in the wrong expression.

4. Jun 15, 2013

### ehild

Or you incorrectly substituted back the parameters in the expression

ehild