2.27   ODE No. 27

\[ a y(x) (y(x)-x)+y'(x)-1=0 \] Mathematica : cpu = 0.247046 (sec), leaf count = 120


\[\left \{\left \{y(x)\to \frac {a x e^{\frac {a x^2}{2}}+c_1 \left (\sqrt {\frac {\pi }{2}} \sqrt {a} x e^{\frac {a x^2}{2}} \text {erf}\left (\frac {\sqrt {a} x}{\sqrt {2}}\right )+1\right )}{a \left (e^{\frac {a x^2}{2}}+\frac {\sqrt {\frac {\pi }{2}} c_1 e^{\frac {a x^2}{2}} \text {erf}\left (\frac {\sqrt {a} x}{\sqrt {2}}\right )}{\sqrt {a}}\right )}\right \}\right \}\] Maple : cpu = 0.216 (sec), leaf count = 72


\[y \relax (x ) = \frac {2 \sqrt {a}\, {\mathrm e}^{-\frac {a \,x^{2}}{2}}+x \left (\sqrt {\pi }\, \erf \left (\frac {\sqrt {2}\, \sqrt {a}\, x}{2}\right ) \sqrt {2}\, a +2 a^{\frac {3}{2}} c_{1}\right )}{\sqrt {\pi }\, \erf \left (\frac {\sqrt {2}\, \sqrt {a}\, x}{2}\right ) \sqrt {2}\, a +2 a^{\frac {3}{2}} c_{1}}\]

Hand solution

\begin {align} y^{\prime }+ay\left (y-x\right ) -1 & =0\nonumber \\ y^{\prime } & =1-\left (ay^{2}-ayx\right ) \nonumber \\ & =1+ayx-ay^{2}\tag {1} \end {align}

This is Riccati first order non-linear ODE \(y^{\prime }=P\relax (x) +A\relax (x) y+R\relax (x) y^{2}\) with \(P\relax (x) =1,Q\relax (x) =-ax,R\relax (x) =-a\). We can convert Riccati to Bernoulli which is easier to solve using the substitution \(u=y-x\)\begin {align*} u^{\prime } & =y^{\prime }-1\\ & =\left (1+ayx-ay^{2}\right ) -1\\ & =\left (1+a\left (u+x\right ) x-a\left (u+x\right ) ^{2}\right ) -1\\ & =1+aux+ax^{2}-a\left (u^{2}+x^{2}+2ux\right ) -1\\ & =1+aux+ax^{2}-au^{2}-ax^{2}-2aux-1\\ & =-aux-au^{2}\\ u^{\prime } & =-aux-au^{2} \end {align*}

This is of the form \(u^{\prime }=P\relax (x) +Q\relax (x) u+R\relax (x) u^{2}\) and since \(P\relax (x) =0\) then it is Bernoulli differential equation. (when \(P\relax (x) \neq 0\) and \(R\relax (x) \neq 0\) it is Riccati). To solve Bernoulli we always start by dividing by \(u^{2}\)\[ \frac {u^{\prime }}{u^{2}}=-\frac {ax}{u}-a \] Then we let \(\zeta =\frac {1}{u}\), hence \(\zeta ^{\prime }=-\frac {u^{\prime }}{u^{2}}\), therefore the above becomes\begin {align*} -\zeta ^{\prime } & =-ax\zeta -a\\ \zeta ^{\prime }-ax\zeta & =a \end {align*}

Integrating factor is \(e^{-\int axdx}=e^{-a\frac {x^{2}}{2}}\), hence \(d\left ( e^{-a\frac {x^{2}}{2}}\zeta \right ) =ae^{-a\frac {x^{2}}{2}}\). Integrating both sides gives\[ e^{-a\frac {x^{2}}{2}}\zeta =a\int e^{-a\frac {x^{2}}{2}}dx+C \] But \[ \int e^{-a\frac {x^{2}}{2}}dx=\sqrt {\frac {\pi }{2a}}\operatorname {erf}\left ( \sqrt {\frac {a}{2}}x\right ) \] Therefore\begin {align*} e^{-a\frac {x^{2}}{2}}\zeta & =a\sqrt {\frac {\pi }{2a}}\operatorname {erf}\left ( \sqrt {\frac {a}{2}}x\right ) +C\\ \zeta & =e^{a\frac {x^{2}}{2}}\left (a\sqrt {\frac {\pi }{2a}}\operatorname {erf}\left (\sqrt {\frac {a}{2}}x\right ) +C\right ) \end {align*}

Hence\begin {align*} u & =\frac {1}{\zeta }\\ & =e^{-a\frac {x^{2}}{2}}\left (a\sqrt {\frac {\pi }{2a}}\operatorname {erf}\left (\sqrt {\frac {a}{2}}x\right ) +C\right ) ^{-1} \end {align*}

Since \(u=y-x\) then\begin {align*} y & =u+x\\ & =e^{-a\frac {x^{2}}{2}}\left (a\sqrt {\frac {\pi }{2a}}\operatorname {erf}\left (\sqrt {\frac {a}{2}}x\right ) +C\right ) ^{-1}+x\\ & =\frac {e^{-a\frac {x^{2}}{2}}}{\sqrt {\frac {a\pi }{2}}\operatorname {erf}\left ( \sqrt {\frac {a}{2}}x\right ) +C}+x \end {align*}

Verification