# Math Help - Find the solution of the given differential equation: dy/dx+(cosx)y=2xy where y(0)=-2

1. ## Find the solution of the given differential equation: dy/dx+(cosx)y=2xy where y(0)=-2

Find a solution to the given differential equation: y'+(cosx)y=2xy where y(0)=-2

Let p(x)=cosx
Let g(x)=2xy
Let mu(x)=e^(integral of cosx)=e^sinx
e^sinx(y')+e^sinx(cosx)y=e^sinx(2xy)
Integral of (e^sin(x)y)' dx= Integral of e^(sinx)2xy dx
But then I realized I couldn't further simplify the integral on the right hand side. So how do I find C?

2. If you rewrite this as

y' = [2x - cos(x)]y

y'/y = 2x - cos(x)

the equation is separable.

Alternatively you can write it as

y' + [cos(x) - 2x]y = 0

and use the Integrating Factor method since it's also first-order linear.

3. never mind. I got it using separation of variables.

4. You're welcome ><

5. So if I use separation of variables:
dy/dx+(cosx)y=2xy
dy/dx=2xy-(cosx)y
dy/dx=y(2x-cosx)
(1/y)dy=(2x-cosx)dx
ln (absolute y)+K=x^2-sinx+C
e^(x^2-sinx+C)= absolute y

2=e^(0+sin(0)+c) (-2 becomes 2 since it's absolute value)
2=e^(c)
c=ln(absolute value 2)
So plugging it back in: ln(absolute y)=x^2-sinx+ln(absolute 2)
e^(x^2-sinx+ln(absolute 2))=y. FINAL ANSWER. IS IT RIGHT?

6. It's correct, but you can clean it up a lot more... ln|2| = ln(2) for example...

Also remember that e^(a + b) = (e^a)(e^b), which means you should be able to simplify the e^ln(2) part...

7. wait. I've a question. If I plug in 0 for x. Then I would get e^(ln2), which is positive 2. But the given value of y is -2. What did I do wrong?

8. It's because you're getting back |y|, not y...

9. gotcha.