So I am supposed to solve this differential equation in maple:
$\displaystyle 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?
hmmm so the equation is
$\displaystyle \displaystyle y'+\frac{x}{2}y=1$ so the integrating factor is
$\displaystyle \displaystyle I(x)=e^{\int \frac{x}{2}dx}=e^{\frac{x^2}{4}}$
Multiplying the ODE by this gives
$\displaystyle 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 \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$
$\displaystyle 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 \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.
So I just learned something new.
$\displaystyle \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 \displaystyle u=\frac{2t}{i} \implies du=\frac{2}{i}dt$
This gives
$\displaystyle \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 \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.