Derivation of $\tanh$ solution to $\frac{1}{2}f''=f^3 - f$

Multiply through with $4f'$ and integrate to get $$ (f')^2=f^4-2f^2+C $$ in a shorter way.

For a twice continuously differentiable function, $f'(∞)=0$ implies that all higher derivatives also vanish. This gives for the value at infinity $$ 0=\frac12f''(∞)=f(∞)(f(∞)^2-1)\text{ and }0=(f'(∞))^2=f(∞)^4-2f(∞)^2+C $$ which gives the variants $f(∞)=0$ and the symmetric $f(∞)=\pm1$ (note that for any solution $f$, also $-f$ is a solution).


Or put in a physical way, $f''=-V'(f)$ with the potential function $V(y)=-(y^2-1)^2$. The "particle" obeying this law of motion starts in the local minimum at $y=0$ and is supposed to come to rest at infinity. This is only possible if it stays at the minimum or approaches asymptotically one of the maxima at $y=\pm 1$.


The first variant implies $C=0$, and that the zero solution is the single and unique solution for these conditions.

$f(∞)=1$ implies $C=1$ and thus $$ f'=\pm(f^2-1) $$ Since the solution starts at $0$, and $f\equiv\pm1$ are solutions of this first order ODE, $|f|<1$. To get a solution growing from $0$ to $1$ you need the negative sign, that is $$ f'(x)=1-f(x)^2\\\implies\\ \frac{f'(x)}{1+f(x)}+\frac{f'(x)}{1-f(x)}=2 \\ \implies\\\ln|1+f(x)|-\ln|1-f(x)|=2x+2C \\\implies\\ f(x)=\frac{e^{2x+2C}-1}{e^{2x+2C}+1}=\frac{e^{x+C}-e^{-(x+C)}}{e^{x+C}+e^{-(x+C)}} $$