Riccati differential equation I have to solve the following equation :
   $$ \frac{dx}{dt}(t)=-q x^2(t) +1  $$
with $x(0)=1$ and $q>0$. At first I consider the two cases:


*

*$q=1$, then I take the change of variable  $ x= \frac{u^{\prime}}{u}$ then with small calculations I got the second ord er linear homogeneous differential equation $ u^{\prime\prime} -u =0$, a solution of this equation is $u=c_1+c_2e^t$ and again to our x we get $x=\frac{c_2e^t}{c_1+c_2e^t}$ and with the initial condition  $x(0)=1$ we get $x=1$ 

*if $q$ is not $1$, directly I assume that $-q x^2(t) +1 $ is non zero and solve the equation by simple integration of $$ \int \frac{dx}{1-qx^2}= \int 1 dt$$
then I got the following solution $$ x(t)= \frac{1}{\sqrt{q} \tanh(t\sqrt{q} +c)}$$ where c is the constant determined from the initial condition $c=\operatorname{atanh}(\sqrt{q})$
Are these discussions and solution steps correct?  May I assume in the second case that $-q x^2(t) +1 $ is non zero directly?   and in the first case, considering the change of variable  $ x= \frac{u^{\prime}}{u}$  with no assumptions on $u$ is correct?
Thanks for any ideas.
 A: Very well done. I would like to suggest an alternate analysis that you may find useful also.
I will do it in steps.
Step 1: Eliminate constant forcing term.
Set the left hand side to zero and solve for $x$. This gives $x=\sqrt(1/q)$
Step 2: Shift the origin of $x$. Define
$$ z = x - \frac{1}{\sqrt{q}} \Rightarrow x = z + \frac{1}{\sqrt{q}} \tag 1$$
Step 3: Rewrite the differential equation in terms of the new variable.
From (1)
$$ \frac{dz}{dt} = \frac{dx}{dt} = -q x^2 + 1 = -q \left(z^2 + 2 z \frac{1}{\sqrt{q}} + =\frac{1}{q} \right) =-q z^2 -\frac{2}{\sqrt{q}} z $$
Step 4: Make it linear by taking reciprocals
Let $y=1/z$. Then
$$
\frac{dy}{dt} = -\frac{1}{z^2} \frac{dz}{dt} = q +\frac{2}{\sqrt{q}} y  $$
Going back to the original problem
You can trace the steps. When $q=1$, $z(0) = 0$ and from (3) $z(t) \equiv 0$. Step 4 is not valid.
If $q \ne 1$ then step 4 is valid. $z(t)$ blows up when $y(t)=0$, i.e. $y$ has a zero crossing.
A: HINT:


*

*Find/Guess a particular solution $x_p(t)$  of your DE [an easy one!]

*Use the educated guess $x(t)=x_p(t)+\frac{1}{u(t)}$
A: Uniqueness of solution is the key here.
First note that $f$ is locally Lipschitz, so the solutions are continuous and unique (they may not exists for all time).
Then note that $f(x) = 0 $ iff $x = \pm \sqrt{q}$.
Hence if a solution starts at $x_0 = \pm \sqrt{q}$, then $x(t) = x_0$ for all $t$.
Otherwise, if $f(x_0) >0$, then $f(x(t)) >0$ for all $t$ in the domain of $x$, and similarly, if $f(x_0) <0$, then $f(x(t)) <0$ for all $t$ in the domain of $x$. In particular, if $f(x_0) \neq 0$, then $f(x(t)) \neq 0$ for all $t$ in the domain of $x$.

