Try to prove a generalization of the IVT? Here is the statement :
"Let $f: (a,b) \to \mathbb{R}$ a continuous function on $(a,b)$ with $a<b$ and $a,b \in \bar{\mathbb{R}}$. Then for all $u \in \left(\lim \limits_{x\to a} f(x), \lim \limits_{x\to b} f(x) \right)$ or $u \in \left(\lim \limits_{x\to b} f(x), \lim \limits_{x\to a} f(x) \right)$ (with $\lim \limits_{x\to a} f(x) \ne \lim \limits_{x\to b} f(x)$) there is $k \in (a,b)$ such that $f(k) = u$."
So we have three main cases :


*

*Let $a,b \in \mathbb{R}$ with $\lim \limits_{x\to a} f(x)= \pm \infty$ and $\lim \limits_{x\to b} f(x)= \pm \infty$.

*Let $a=-\infty$ and $b=+\infty$ with $\lim \limits_{x\to -\infty} f(x)= c\in \mathbb{R}$ and $\lim \limits_{x\to +\infty} f(x)= d\in \mathbb{R}$.

*Let $a=-\infty$ and $b=+\infty$ with $\lim \limits_{x\to -\infty} f(x)= \pm \infty$ and $\lim \limits_{x\to +\infty} f(x)= \pm \infty$.
I tried to prove the first case. I want to apply the initial theorem which only works for compact interval. 
WLOG, I suppose that : $\lim \limits_{x\to a} f(x)= - \infty$ and $\lim \limits_{x\to b}(x)= + \infty$
Writing the definition of limits I obtain : 
$\forall A \in \mathbb{R}, \exists \eta_1>0, \forall x \in (a,b), \mid x-a\mid \le \eta_1 \Rightarrow f(x) \le A$.
$\forall B \in \mathbb{R}, \exists \eta_2>0, \forall x \in (a,b), \mid x-b\mid \le \eta_2 \Rightarrow f(x) \ge B$.
Then for $k \in (a,b)$, I can chose $\eta_3 = \min\{\eta_1, \eta_2\}>0$ such as for $x\in [k-\eta_3, k+ \eta_3]$ I have $f(x) \in [B,A]$.
Does that imply that I can apply the usual theorem ?
Thanks in advance !
 A: For the case $\lim_{x\to a} f(x) = -\infty$ and $\lim_{x\to b} f(x) = +\infty$:
There exists some $\eta > 0$ such that for all $x\in(a,b)$ we have:


*

*If $x - a < \eta$, then $f(x) < u - 1$.

*If $b - x < \eta$, then $f(x) > u + 1$.


By continuity, we have $f(a + \eta) \le u - 1 < u + 1 \le f(b - \eta)$.
Thus, by IVT for bounded closed interval, there exists some $k\in(a+\eta, b-\eta)$ with $f(k) = u$.
All other cases are analogue.
A: Well you don't need to consider so many cases. Just two cases are sufficient.
Case 1) $\lim_{x \to a}f(x) < u < \lim_{x \to b}f(x)$. Then it is obvious that there exist real numbers $A, B$ with $$\lim_{x \to a}f(x) < A < u < B < \lim_{x \to b}f(x)$$ and by definition of limits we can see that there is a value of $x$ near $a$ and greater than $a$ (call it $c$) such that $\lim_{x \to a}f(x) < f(c) < A$ and similarly there is a $d$ such that $d < b$ and $B < f(d) < \lim_{x \to b}f(x)$. Also since $a < b$ we can choose $c, d$ such that $c < d$. We thus have real numbers $c, d$ with $c < d$ and $f(c) < A < u < B < f(d)$. Applying IVT on closed interval $[c, d]$ we get the existence of a number $k \in (c, d)$ with $f(k) = u$.
Case 2) $\lim_{x \to b}f(x) < u < \lim_{x \to a}f(x)$. This can be done exactly in same manner as case 1) with obvious minor modifications.
Note: There is an assumption that the limits $\lim_{x \to a}f(x), \lim_{x \to b}f(x)$ belong to extended real number system $\bar{\mathbb{R}}$ which includes $\pm\infty$ also (in the same manner in which both $a, b$ belong to $\bar{\mathbb{R}}$).
