2.12   ODE No. 12

\[ y'(x)+y(x)^2-1=0 \]

Mathematica : cpu = 0.0671634 (sec), leaf count = 34

DSolve[-1 + y[x]^2 + Derivative[1][y][x] == 0,y[x],x]
 
\[\left \{\left \{y(x)\to \frac {e^{2 x}-e^{2 c_1}}{e^{2 x}+e^{2 c_1}}\right \}\right \}\]

Maple : cpu = 0.032 (sec), leaf count = 8

dsolve(diff(y(x),x)+y(x)^2-1 = 0,y(x))
 
\[y \left (x \right ) = \tanh \left (x +c_{1} \right )\]

Hand solution

\begin{align} \frac {dy}{dx}+y^{2}\left ( x\right ) -1 & =0\nonumber \\ \frac {dy}{dx} & =1-y^{2}\left ( x\right ) \tag {1}\end{align}

This is separable. Hence

\begin{align*} \frac {dy}{dx}\frac {1}{1-y^{2}\left ( x\right ) } & =1\\ \frac {dy}{1-y^{2}\left ( x\right ) } & =dx \end{align*}

Integrating

\[ \int \frac {dy}{1-y^{2}\left ( x\right ) }=x+C \]

Using \(\int \frac {1}{a+by^{2}}dy=\frac {\sqrt {-\frac {a}{b}}\tanh ^{-1}\left ( \frac {y}{\sqrt {\frac {-a}{b}}}\right ) }{a}\) and since \(a=1,b=-1\), then \(\int \frac {dy}{1-y^{2}\left ( x\right ) }=\tanh ^{-1}\left ( y\right ) \) and the above becomes

\[ \tanh ^{-1}\left ( y\right ) =x+C \]

Therefore

\begin{equation} y=\tanh \left ( x+C\right ) \tag {2}\end{equation}

In terms of exponential, since \(\tanh \left ( u\right ) =\frac {e^{u}-e^{-u}}{e^{u}+e^{-u}}\) then (2) can also be written as

\[ y=\frac {e^{x+C}-e^{-\left ( x+C\right ) }}{e^{x+C}+e^{-\left ( x+C\right ) }}=\frac {e^{x}e^{C}-e^{-x}e^{-C}}{e^{x}e^{C}+e^{-x}e^{-C}}\]

Multiplying numerator and denominator by \(e^{-C}e^{x}\)

\[ y=\frac {e^{2x}-e^{-2C}}{e^{2x}+e^{-2C}}\]

To get same answer as Mathematica, since \(C\) is constant, let \(C_{1}=-C\), then

\[ y=\frac {e^{2x}-e^{2C_{1}}}{e^{2x}+e^{2C_{1}}}\]