How can I solve this non-linear differential equation? I'm trying to solve the equation $$y' = 1 - y^2$$
Here is my attempt:
$$y' = 1 - y^2$$
Divide by (1-y^2)
$$\frac{y'}{1-y^2} = 1$$
Integrate both sides:
$$\frac{1}{2}\log|\frac{y+1}{y-1}|=t+c$$
Rearrange
$$y = \frac{ke^{2t}+1}{ke^{2t}-1}$$
I'd have thought that solution was right, but we have to figure out a specific solution with y(0) = 0. But this isn't possible with the above equation.
 A: Since you want a solution near $y=0$, you should use $1-y$ in the denominator (as it will be positive) and can remove the absolute value signs. This changes some signs in your answer, giving $$y = \frac{ke^{2t}-1}{ke^{2t}+1}$$ and $k=1$ gives $y(0)=0$
A: Reducing from what you have a little more, we get that equal to Tanh[x-k].
Tanh[-k] == 0 //Seting x to zero
Therefore k = 0, leaving Tanh[x] as your function.
A: I wrote it down and solved it in a slightly different way. The first thing you should notice is that $y = 1$ and $y = -1$ are the two constant solutions, which allows you then to divide $y'$ by $1-y^2$, since you want to study it for $y(0) \in (-1,1)$, knowing that any solution starting in $(-1,1)$ stays there (or dies in 1).
Then yes, with some algebra you manage to get
$\left(\log \frac{1+y}{1-y}\right)' = 2$
if I haven't screwed up with the signs; now integrating it from 0 to $t$ you get:
$\log \frac{1+y(t)}{1-y(t)} - \log \frac{1+y(0)}{1-y(0)} = 2t$
without the absolute value since everything in the argument of the logs is non-negative. By imposing $y(0) = 0$ the second term in the left vanishes and you're left with an easy expression that if inverted gives the following:
$y(t) = \frac{e^{2t} - 1}{e^{2t} + 1}$
which is simply
$y(t) = \tanh (t)$
and of course double checking $y(0) = 0$.
