I'm struggling with the following ODE, which computed gives a different answer than the one I got doing it analytically. Maybe I have made a silly mistake or I do not get how to work with the absolute values in the correct manner.
The ODE is the following:
$\dot{x} = x^2 -1$
Analytically, I get after separating values and performing a partial fraction decomposition the following answer:
$x(t) = \dfrac{1+e^{2t+c}}{1-e^{2t+c}}$
When I compute it in Wolfram Alpha I get:
$x(t) = \dfrac{1-e^{2t+c}}{e^{2t+c}+1}$
I have checked the integrals separately and compared the solutions to the Phase Plane.
When plotting my solution I think I am getting the solutions for $x_0 < -1 $ and $x_0 > 1$ because they look like it.
I think the Wolfram Alpha solution delivers the solution for $-1<x_0<1$.
Can someone please enlighten me and tell me what I am not getting? Can I get from one solution to the other?
Is it because of the absolute values I get when integrating?
Thank you all in advance, Cheers
Santiago
You're right that the problem lies in handling the absolute values. WA may not worry about that, since it's working more formally, possibly allowing complex-valued solutions. But anyway, the correct way of dealing with real-valued solutions is the following:
First, $x(t)=-1$ and $x(t)=1$ are constant solutions. All other solutions necessarily satisfy $x \neq \pm 1$ (since different solution curves cannot cross), which means that $x^2 - 1 \neq 0$ and it's safe to separate the variables: $$ \int\frac{dx}{x^2-1} = \int dt . $$ This gives $$ \frac12 \ln \left| \frac{x-1}{x+1} \right| = t + C , $$ where $C \in \mathbf{R}$ is arbitrary, which in turn implies that $$ \frac{x-1}{x+1} = \pm e^{2(t+C)} = \pm e^{2C} e^{2t} = D e^{2t} , $$ where $D = \pm e^{2C}$ is an arbitrary nonzero real constant. So we get $$ x=-1 \quad\text{or}\quad x=1 \quad\text{or}\quad x=\frac{1+D e^{2t}}{1-D e^{2t}} \quad (D \neq 0) , $$ which can be further simplified to $$ x=-1 \quad\text{or}\quad x=\frac{1+D e^{2t}}{1-D e^{2t}} \quad (D \in \mathbf{R}) . $$ This will allow you to find the solution for any initial value, say $x(0) = x_0 \in \mathbf{R}$. If $x_0=-1$, then $x(t)=-1$, otherwise there is a unique $D \in \mathbf{R} \setminus \{ 1 \}$, namely $D=(x_0-1)/(x_0+1)$, such that the solution is given by $x(t)=\frac{1+D e^{2t}}{1-D e^{2t}}$ (for all $t$ in the maximal interval of existence).
(Notice that if $x_0>1$ so that $0<D<1$, then the solution blows up at a finite positive time when the denominator becomes zero, and if $x_0<-1$ so that $D>1$, then the solution blows up at a finite negative time. The solution with $D=1$ is singular at $t=0$, which is why that value of $D$ cannot occur if the initial value is given at $t=0$.)