2.12   ODE No. 12

\[ y'(x)+y(x)^2-1=0 \] Mathematica : cpu = 0.0870792 (sec), leaf count = 34


\[\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.051 (sec), leaf count = 8


\[y \relax (x ) = \tanh \left (x +c_{1}\right )\]

Hand solution

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

This is separable. Hence

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

Integrating\[ \int \frac {dy}{1-y^{2}\relax (x) }=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}\relax (x) }=\tanh ^{-1}\relax (y) \) and the above becomes

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

Therefore

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

In terms of exponential, since \(\tanh \relax (u) =\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}}}\]