1. ## Solving a Differential

So I am supposed to solve this differential equation in maple:

$2*y'+x*y=2$

where y(0)=c and c is a real number.

However, I have no idea how to solve this equation in general. What would be the best method for this?

2. Originally Posted by shaunthepanda
So I am supposed to solve this differential equation in maple:

$2*y'+x*y=2$

where y(0)=c and c is a real number.

However, I have no idea how to solve this equation in general. What would be the best method for this?
This is a first order linear equation and can be solved via an integrating factor.

Put it in standard form

$y'+p(x)y=f(x)$ then your integrating factor is

$I(x)=e^{\int p(x)dx}$

Can you finish from here

3. That is actually what I tried intially, but the thing is that I end up with an imaginary number when I put it in maple... Here is what I get:

$
y(x) = (-I*sqrt(Pi)*erf((1/2*I)*x)+1)*exp(-(1/4)*x^2)$

4. hmmm so the equation is

$\displaystyle y'+\frac{x}{2}y=1$ so the integrating factor is

$\displaystyle I(x)=e^{\int \frac{x}{2}dx}=e^{\frac{x^2}{4}}$

Multiplying the ODE by this gives

$e^{\frac{x^2}{4}}y' + \frac{x}{2}e^{\frac{x^2}{4}}y=e^{\frac{x^2}{4}}$

Using the product rule backwards gives

$\displaystyle \frac{d}{dx}\left[ e^{\frac{x^2}{4}}y\right]= e^{\frac{x^2}{4}} \iff e^{\frac{x^2}{4}}y=\int_{0}^{x} e^{\frac{t^2}{4}}dt+C$

$y(x)=Ce^{\frac{-x^2}{4}}+e^{\frac{-x^2}{4}}\int_{0}^{x} e^{\frac{t^2}{4}}dt$

You can check by taking the derivative that this satisfies the ODE.

P.S the error function

$\displaystyle erf(x)=\frac{2}{\sqrt{\pi}}\int_{0}^{x}e^{-t^2}dt$

I don't know what maple is giving you a complex part of the erf function.

5. So I just learned something new.

$\displaystyle erf\left( \frac{i}{2}x\right)=\frac{2}{\sqrt{\pi}} \int_{0}^{\frac{i}{2}x} e^{-t^2}dt$

Now let $\displaystyle u=\frac{2t}{i} \implies du=\frac{2}{i}dt$

This gives

$\displaystyle \frac{2}{\sqrt{\pi}}\int_{0}^{\frac{i}{2}x} e^{-t^2}dt =\frac{i}{\sqrt{\pi}} \int_{0}^{x}e^{\frac{u^2}{4}}du$

So we can use this to rewrite the previous solution.

$\displaystyle y(x)=Ce^{\frac{-x^2}{4}}+e^{\frac{-x^2}{4}}\int_{0}^{x} e^{\frac{t^2}{4}}dt=Ce^{\frac{-x^2}{4}}+e^{\frac{-x^2}{4}} \left( i \sqrt{\pi} erf\left( \frac{i}{2}x\right)\right)= \left [C+ i \sqrt{\pi} erf\left( \frac{i}{2}x\right)\right] e^{\frac{-x^2}{4}}$

This is how maple chose to write the solution.