# How to solve $\frac{dy}{dx}=5xy + \sin x$?

How do I solve $\frac{dy}{dx}=5xy + \sin x$ explicitly? With $y(0) = 1$. I am asked to use an integrating factor. What I did:

$\frac{dy}{dx}-5xy = \sin x \\ \text{Integrating factor:} \ e^{\int{-5x\ dx}} = e^{-\frac{5}{2}x^2} \\ \frac{d}{dx}\left[e^{-\frac{5}{2}x^2}y\right] = e^{-\frac{5}{2}x^2}\sin x \\ e^{-\frac{5}{2}x^2}y = \int e^{-\frac{5}{2}x^2}\sin x \ dx$

How would I proceed from there? Edit: $y(0) = 1$.

Also, when does the scalar ODE (above) have a unique solution?

-
Whether you can integrate it in closed form or not, you've found the solution: just take your last equation and multiply both sides by $e^{\frac{5}{2} x^2}$ to get $y = e^{\frac{5}{2} x^2} (F(x) + C)$ where $F(x) = \int e^{-\frac{5}{2} x^2} \sin x\ dx$. An ODE never has a unique solution, you always need an initial condition to specify a unique solution. – Robert Israel Apr 25 '12 at 18:30
Robert is right. If the instructions are: "Solve using an integrating factor", then you have done that. It just happens that your solution involves an integral. Maybe divide to get "$y=\dots$". – GEdgar Apr 25 '12 at 18:38
Thanks @ Robert Israel @GEdgar. I forgot to add in the initial condition. It is $y(0) = 1$. How do I proceed from there? From my working above, can I then just substitute $y(0) = 1$? – Richard Apr 25 '12 at 18:50
Yes, like this:$$y = e^{\frac{5}{2}x^2}\big(1+\int_0^x e^{-\frac{5}{2}t^2}\sin t \, dt\big)$$ – GEdgar Apr 25 '12 at 20:25
Thanks @GEdgar ! I get $1 = 1(1+0)$, is that correct? Or Shouldnt the $1$ be a $C$? Constant. – Richard Apr 25 '12 at 21:39

Rewrite ODE into form :

$(5xy+\sin x)dx-1\cdot dy=0$

Next , let's denote :

$M=5xy+\sin x ~\text{and}~ N=1$ , then :

integrating factor $u(x)$ is given by :

$$u(x)=e^{\int\frac{\frac{\partial M}{\partial y}-\frac{\partial N}{\partial x}}{N}\,dx}=e^{\frac{5}{2}x^2}$$

Use this procedure to find solution of ODE .

-
Thanks for your help! Sorry I forgot to add an initial condition, $y(0) = 1$. – Richard Apr 25 '12 at 18:54

This is a linear, non-homogeneous, differential equation. Mathematica suggests the solution $$\left\{\left\{y(x)\to \frac{1}{20} e^{\frac{5 x^2}{2}} \left(20 c_1+\frac{i \sqrt{10 \pi } \left(\text{erf}\left(\frac{5 x+i}{\sqrt{10}}\right)+i \text{erfi}\left(\frac{1+5 i x}{\sqrt{10}}\right)\right)}{\sqrt[10]{e}}\right)\right\}\right\}.$$ Your approach if perfectly correct, since linear equation always have an integrating factor. Yours has $e^{\frac{5}{2}x^2}$. I'm afraid you won't find an elementary solution, since $\int e^{-\frac{5}{2}x^2}\sin x\, \mathrm{d}x$ can't be expressed in terms of elementary functions. Of course, this does not mean that the exercise is impossible.

-
Thanks @siminore, what is the way to find the solution? The method pedja described? – Richard Apr 25 '12 at 18:22
The solution proposed by Mathematica is a big mess, and it has to do with complex numbers. By the way, I believe that nobody wants to work with erf and erfi functions to solve a linear equation. For the general approach to first-order linear equations, see en.wikipedia.org/wiki/Linear_differential_equation : there is a paragraph where the method is explained. – Siminore Apr 26 '12 at 8:06