If limit of $|f|$ is divergent to $\infty$, then is $f$ divergent to either $\infty$ or $-\infty$? Let $f$ be a real function and $a$ be a limit point of its domain.
Suppose $\lim_{x\to a} |f(x)| = \infty$.
How do i prove that if $f$ is continuous on its domain, its limit is either $\infty$ or $-\infty$? (And Its domain is connected)
I think continuity is essential
For example, a function $g:(0,\infty)\rightarrow \mathbb{R}$ such that $g(x)=1/x$ if $x$ is rational and $g(x)=-1/x$ is $x$ is irrational, does not have its limit at $0$.
 A: Here is what you can prove : if $\lim_{x \to a^+} |f(x)| \to \infty$, then either $f(x) \to \infty$ or $f(x) \to -\infty$. The reason is simple ; for every $M > 0$, there exists $\delta > 0$ such that if $0 < x-a < \delta$, $|f(x)| > M$. If in this interval we have $x_1$ and $x_2$ such that $f(x_1) > M > -M > f(x_2)$, then by the intermediate value theorem there would exists $x$ between $x_1$ and $x_2$ with $f(x) = 0$, contradicting $f(x) > M$ because since $x$ is between $x_1$ and $x_2$, it also satisfies $0 < x-a < \delta$. 
In a similar manner you can show that if $\lim_{x \to a^-} |f(x)| \to \infty$, then $f(x) \to \infty$ or $f(x) \to -\infty$. 
Now when $x \to a$, then "when $x$ comes from the left side" you only have one possibility, $+$ or $-$ infinity, and the same goes if $x$ "comes from the right side". Therefore the example $f(x) = \frac 1x$ can arise.
However, this is because the real line minus the point $a$ is not a connected domain. In other words, the question becomes true if $f : \Bbb R^n \to \Bbb R$ with $n > 1$. Now why is that?
If $f$ is continuous and $\lim_{x \to a} |f(x)| = \infty$, then for all $M > 0$, there exists $\delta > 0$ such that $0 < |x-a| < \delta$ in $\Bbb R^n$ implies $|f(x)| > M$. Since the open punctured ball $0 < |x-a| < \delta$ is connected by arcs, suppose $f(x_1) > M > -M > f(x_2)$. Then there exists an arc completely contained in the punctured ball, and since $f$ is continuous, you can use the intermediate value theorem to derive a contradiction. Therefore $f$ cannot change sign on that punctured ball, hence either $f(x) \to \infty$ or $f(x) \to -\infty$.
Hope that helps,   
A: This is true if (and only if) the domain of $f$ is locally connected at $a$: every neighborhood of $a$ contains a neighborhood that meets the domain of $f$ in a connected set. If sufficiently small neighbourhoods of $a$ intersected with the domain of $f$ are all disconnected (for instance if $f$ is defined on a discrete set or if the domain is contained in $\Bbb R$ and $a$ can be approached from below and from above within the domain of $f$) then it is obviously false as you can choose signs of $f$ arbitrarily on each connected component of such a neighborhood. The (added) condition that the entire domain of $f$ is connected is not sufficient: the function $f$ defined on the unit circle in the complex plane minus the point $-1$  by $f(e^{\mathbf i\phi})=\tan\frac\phi2$ (it is well defined since $\tan$ has period $\pi$) has a connected domain, it has $\lim_{z\to-1}|f(z)|=\infty$ but  $\lim_{z\to-1}f(z)$ is neither $+\infty$ nor $-\infty$.
Assume local connectedness of the domain of $f$ at $a$. You know that for every $N>0$ there is a neigbourhood $U$ of $a$ such that $|f(x)|>N$ for all $x\in U$, and we can now take $U$ to be connected. The subsets $\{x\in U\mid f(x)<-N\}$ and $\{x\in U\mid f(x)>N\}$ are disjoint, both open, and unite to $U$; since the connected set $U$ cannot be partitioned into two open subsets, one of them must be empty. If the first is empty then $\lim_{x\to a}f(x)=+\infty$, and otherwise $\lim_{x\to a}f(x)=-\infty$.
