TITLE: prove or disprove: if $y'=y^2-\cos(x)$ then any solution diverges in a finite time
QUESTION [6 upvotes]: given the following ode, prove or disprove:

if $y'=y^2-\cos(x)$ then any solution diverges in a finite time.

"diverge" means, that there is a point $x$ where the solution isn't continuous (there and thereafter).

if $y(0)>1$ or $y(0)<-1$ it's clear how to show it.
for instance, take $y(0)>1$, and let say we have $x$ where for the first time $y(x)=1$.
then according to the mean value theorem there is $t$ where $y'(t)<0$ and then it applies that $y(t)<1$, thus $x$ is not the first time we reached $y(x)=1$, therefore there isn't such point.
The problem is showing that if $-1<y(0)<1$ it must go out from this range in a finite time.
Edit
I thought about a solution $y'=y^2-\cos(x)>y^2-1$, which its solution is $\frac{1-e^{2c+2x}}{e^{2c+2x}+1}$, which might have a pole. depending on y(0)

REPLY [3 votes]: Fleshing out my comment above. I'll first show the following:

There are numbers $a < \frac{\pi}{2} < b$ and a solution $y = y_0(x)$ with the properties
$$
y_0(\frac{\pi}{2}) = -1,  \; \lim_{x \to a} y_0(x) = - \infty, \; \lim_{x \to b} y_0(x) = + \infty 
$$

Proof. Let $y = y_0(x)$ be the solution with $y_0(\frac{\pi}{2}) = -1$ and let $(a, b)$ be its maximal interval of existence. Then clearly $y_0(x)$ is $< -1$ for $x < \pi/2$, close to this number. Let's say $y_0(x_0) = -1 - \delta$ for some $x_0 < \pi/2$. As in the argument given by the OP, this implies $y_0(x) < -1 - \delta$ for all $x < x_0$ as long as the solution exists. Since we know $y_0' \ge y_0^2 - 1$ and the solution of $w' = w^2 - 1, \, w(x_0) = -1- \delta$ goes to $- \infty$ in finite time as $x$ decreases below $x_0$, this implies that $y_0(x) \to - \infty$ as $x \to a$ where $a$ is finite.
Next, for $\frac{\pi}{2} \le \pi < \min(b, 3 \pi/2)$ we have $\frac{d}{dx} y_0(x) \ge - \cos x$. Consequently $y_0(x) \ge - \sin x$ on this interval and $y_0(3 \pi/2) \ge 1$.
Now if $b \le 3 \pi/2$, we are done, since the only way that is can happen is if $|y_0(x)| \to \infty$ as $x \to b$ and $y_0(x)$ cannot go to $- \infty$.
So we may assume that $b > \frac{3 \pi}{2}$. In this case as before $y(x) > 1$ for $x > 3 \pi/2$, close to $3 \pi/2$. We can again use the inequality $y_0' \ge y_0^2 - 1$ to show that $y_0(x) \to + \infty$ as $x \to b$ and $b$ is finite.
Next it follows that

For each $k \in \mathbb{Z}$  there is a solution $y = y_k(x)$ with the properties
$$
\lim_{x \to a + 2 k \pi} y_k(x) = - \infty, \; \lim_{x \to b+ 2 k \pi} y_k(x) = + \infty 
$$
where $a, \, b$ are as above.

Simply set $y_k(x) = y_0(x - 2 k \pi)$.
Finally let $y(x)$ be an arbitrary solution.

Then $y$ exists on a finite interval and goes to $\pm\infty$ at the right / left endpoint.

Proof. Pick a $c$ such that $y(c)$ is defined.  Let $M = \max(2 \pi, b-a)$. Suppose $y$ exists on $[c, c + 2M]$. We can then find a solution $y_k$ as above and a number $d \in [c, \, c + M]$ such that $y_k(d) < y(d)$. Then $d > a + 2 k \pi$. It follows that $y(x) \to \infty$ as $x \to b + 2k\pi < d + M + 2 \pi \le c + 2M$, contradiction.  Such a solution therefore must go to $+\infty$ before $x$ reaches $c + 2M$. The same argument shows that $y(x)$ must go to $-\infty$ before $x$ reaches $c - 4 M$. This completes the proof.
Edit: There was an incorrect estimate in the earlier version of the proof of the first bullet. This has now been fixed and the proof has been streamlined.