# Solving a Differential

• Feb 6th 2011, 11:33 AM
shaunthepanda
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?
• Feb 6th 2011, 11:40 AM
TheEmptySet
Quote:

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
• Feb 6th 2011, 11:49 AM
shaunthepanda
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)$
• Feb 6th 2011, 12:16 PM
TheEmptySet
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.
• Feb 6th 2011, 12:33 PM
TheEmptySet
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.