# Solve differential equation

1. Apr 5, 2014

### skrat

1. The problem statement, all variables and given/known data
Solve $y''+y-sinx=0$.

2. Relevant equations

3. The attempt at a solution

I am actually working on variational problems which brought me to this differential equation. I thought that taking $y=Asinx+Bcosx$ would solve it, yet it does nothing useful.

In other words, I tried everything I could remember. Could somebody help me?

2. Apr 5, 2014

### PeroK

sin(x) and cos(x) as you've discovered are a solutions to the homogeneous equation. So, you need to try a variation of sin(x) and cos(x) to get a particular solution.

Can you remember how to do this?

Last edited: Apr 5, 2014
3. Apr 5, 2014

### Staff: Mentor

To elaborate on what PeroK said, the homogeneous DE is y'' + y = 0. The nonhomogeneous DE is y'' + y = sin(x).

The general solution of the homogeneous equation is yc = Asin(x) + Bcos(x).

4. Apr 5, 2014

### skrat

Agree, BUT

$y^{'}=A^{'}sin(x)+Acos(x)+B^{'}cos(x)-Bsin(x)$ and

$y^{''}=A^{''}sin(x)+A^{'}cos(x)+A^{'}cos(x)-Asin(x)+B^{''}cos(x)-B^{'}sin(x)-B^{'}sin(x)-Bcos(x)$.

The sum $y^{''}+y^{'}=A^{''}sin(x)+A^{'}cos(x)+A^{'}cos(x)+B^{''}cos(x)-B^{'}sin(x)-B^{'}sin(x)$.

Don't even dare to say that is is what I have to solve now. -.-

5. Apr 5, 2014

### Staff: Mentor

A and B are just constants, so it makes no sense to write them with A' (= 0) and A'' (= 0).

If y is any linear combination of sin(x) and cos(x), then y'' + y will be identically zero.

To get you thinking the right way, here is a related example.
Homogeneous DE: y' - y = 0
Solution basis : {et}
(Meaning that the general solution is all linear combinations of et.)
Nonhomogeneous DE: y' - y = 3et
No constant multiple of et could possibly be a solution of the nonhomogeneous equation, because d/dt(Aet) - Aet = 0 identically.

The trick is to try a particular solution of the form Btet.

Let yp = Btet. Then yp' = Bet + Btet.

So yp' - yp = 3et
$\Rightarrow$ Bet + Btet - Btet = 3et
$\Rightarrow$ Bet = 3et
$\Rightarrow$ B = 3
So our particular solution is yp = 3tet

Hopefully, this is similar to other examples you have seen.

6. Apr 5, 2014

### skrat

No?

For example take a look at: http://www.math.vt.edu/people/renardym/class_home/firstorder/node1.html

So in general $A=A(x)$ and $B=B(x)$ unless you somehow saw that in this case they are actual constants.

That is in fact something I remember very well, unless I've mixed up things big time!?

7. Apr 5, 2014

### LCKurtz

Variation of parameters is overkill for this problem. Look up "undetermined coefficients".

8. Apr 5, 2014

### Staff: Mentor

The method I used is called the method of undetermined coefficients, which is simpler to use when you have a DE with constant coefficients, as you have.

There's another method that uses annihilators to convert an nonhomogeneous constant coefficient DE into a higher order homogeneous DE. Not all textbooks present this method, so it might not be in your book or if it is, you might not have seen it yet.

Using operator notation, where D means d/dx and D2 means $\frac{d^2}{dx^2}$, the equation of my example can be represented as (D - 1)y = 3ex.

The operator that annihilates ex is the D - 1 operator, meaning that (D - 1)ex = d/dx(ex) - ex = 0.

To convert the nonhomogeneous first order equation of my example to a homogeneous equation, we apply the operator that will annihilate the right side, to both sides, like so:
(D + 1)[(D + 1)y] = (D + 1)(3ex) = 0

In the process, the first order nonhomogeneous equation has become second order.

(D + 1)2y = 0

The general solution of the above is y = Aex + Bxex. The first function is the general solution of the original homogeneous problem. The second function is the particular solution of the original nonhomogeneous problem. If you substitute this general solution into the original problem, you'll find (again) that B = 3.

Edit: Apologies if the above seems like drinking from a fire hose. There is a lot I left out, as I needed to take my dogs for their morning walk.

Last edited: Apr 5, 2014
9. Apr 5, 2014

### Staff: Mentor

You didn't give any indication that A and B were actually functions, so I assumed that they were constants.

10. Apr 5, 2014

### skrat

Method of undetermined coefficients ... Yup, I know this one and also should have remembered it.

Thanks to all and apologize for standing up and saying that $A=A(x)$... :)

The solution is $y=-\frac{xcos(x)}{2}$

11. Apr 5, 2014

### Ray Vickson

Set the coefficient of cos(x) identically equal to 0 and the coefficient of sin(x) identically equal to 1. This gives you two simple coupled constant-coefficient first-order linear DEs for $A_1 = dA/dx$ and $B_1 = dB/dx$. Remember that $A(x) = \int_0^x A_1(t) \, dt + \text{const.}$, etc.