Why doesn't nonexistence of $\lim_{x \to \infty^+}$ and $\lim_{x \to -\infty^-}$ cause limits at infinity to be undefined? One criterion for checking existence of limits is to check that and one-sided limits from left and right exist and agree:

(Theorem) Let $f$ be a real-valued function. One-sided limits of $f$ as $x$ approaches $a$ from the left and right exist and equal $L$:
$$
\lim_{x \to a^-} f(x) = \lim_{x \to a^+} f(x) = L
$$
if and only if the two-sided limit of $f$ at $a$ exists and also equals $L$,
$$\lim_{x \to a} f(x) = L.$$

The contrapositive of this statement can be used to conclude that a limit does not exist:

(Contrapositive) Let $f$ be a real-valued function. One-sided limits of $f$ as $x$ approaches $a$ from the left and right do not exist or do not agree if and only if the limit of $f$ at $a$ does not exist.

When applying this to a variety of contexts, you can come up with some pretty weird examples and weird results.

In the above figure, it seems to me that

*

*$\lim_{x \to 3} f(x)$ does not exist since $\lim_{x \to 3^+} f(x)$ does not exist.

*$\lim_{x \to 4} f(x)$ does not exist since $\lim_{x \to 4^-} f(x)$ and $\lim_{x \to 4^-} f(x)$ do not exist.

*$\lim_{x \to 5} f(x)$ does not exist since $\lim_{x \to 5^-} f(x)$ does not exist.

A bit more controversial is if you apply the same to the limits at infinity, which would stand to reason that

*

*$\lim_{x \to \infty} f(x)$ does not exist since $\lim_{x \to \infty^+} f(x)$ does not exist.

*$\lim_{x \to -\infty} f(x)$ does not exist since $\lim_{x \to \infty^-} f(x)$ does not exist.

However to contradict the above, many people would write $\lim_{x \to \infty} f(x)=2$ and $\lim_{x \to -\infty} f(x)=-1$.
TLDR; why does the nonexistence of left and right limits not cause limits at infinity to be undefined but does cause the limit at $x=3$, $x=4$, and $x=5$ to not exist? Real analysis answers are welcome.

Edit Thanks to answers from Troposphere and Joe, I worked out some more careful definitions and theorems:

Definition (Limit) Let $f$ be a function whose domain is a subset of $\mathbb{R}$, and let $a, L \in \mathbb{R}$. We say that the
limit of $f$ as $x$ approaches $a$ is $L$,
\begin{equation*} \lim_{x \to a} f(x)=L \end{equation*} to mean that $a$ is an accumulation point of $\textrm{dom}(f)$ and for any $\epsilon > 0$, there exists $\delta >0$ such that if $x \in \textrm{dom}(f)$ is within $\delta$ of $a$ (with $x \ne a$), then $f(x)$ is within $\epsilon$ of $L$: \begin{equation*} 0 < |x-a| < \delta \quad \rightarrow \quad 0 < |f(x)-L| < \epsilon.
\end{equation*}


Definition (One-Sided Limits) Let $f$ be a function whose domain is a subset of $\mathbb{R}$, and let $a, L \in \mathbb{R}$.:

*

*We say the limit of $f$ as $x$ approaches $a$ from the left is $L$, $$\lim_{x \to a^-} f(x)=L,$$ to mean that $a$ is an accumulation point of $\textrm{dom}(f) \cap (-\infty,a]$ and for any $\epsilon > 0$, there exists $\delta >0$ such that if $x$ is within $\delta$ of $a$ (for $x < a$), then $f(x)$ is within $\epsilon$ of $L$: \begin{equation*} 0 < a-x < \delta \quad \rightarrow \quad 0 < |f(x)-L| < \epsilon. \end{equation*}


*We say the limit of $f$ as $x$ approaches $a$ from the right is $L$, \begin{equation*} \lim_{x \to a^+} f(x)=L, \end{equation*} to mean that $a$ is an accumulation point of $\textrm{dom}(f) \cap [a,\infty)$ and for any $\epsilon > 0$, there exists $\delta >0$ such that if $x$ is within $\delta$ of $a$ (for $x > a$), then $f(x)$ is within $\epsilon$ of $L$: \begin{equation*} 0 < x-a < \delta \quad \rightarrow \quad 0 < |f(x)-L| < \epsilon. \end{equation*}


Theorem (One-Sided and Two-Sided Limits Relationship) Let $f$ be a function whose domain is a subset of $\mathbb{R}$, and let $a, L \in \mathbb{R}$. Suppose a is an accumulation point of dom(f) and that $f$ is defined everywhere in some punctured neighborhood of $a$. Then
One sided limits of $f$ from left and right at $a$ exist and equal $L$, $$\lim_{x \to a^-} f(x) = L \textrm{ and }\lim_{x \to a^+} f(x) = L,$$
if and only if the two-sided limit of $f$ at $a$ exists and also equals $L$: $$\lim_{x \to a} f(x) = L.$$


Contrapositive (One-Sided and Two-Sided Limits Relationship) Let $f$ be a function whose domain is a subset of $\mathbb{R}$, and let $a, L \in \mathbb{R}$. Suppose a is an accumulation point of dom(f) and that $f$ is defined everywhere in some punctured neighborhood of $a$. Then
At least one of the one sided limits of $f$ from left and right at $a$ does not exist or do not equal $L$: $$\lim_{x \to a^-} f(x) \ne L \textrm{ or }\lim_{x \to a^+} f(x) \ne L,$$
if and only if the two-sided limit of $f$ at $a$ does not exist or does not equal $L$: $$\lim_{x \to a} f(x) \ne L.$$

Under these definitions and theorems, I think (hope) we get the conclusions we expect:

*

*$\lim_{x \to 3} f(x)$ exists

*$\lim_{x \to 5} f(x)$ exists.

and

*

*$\lim_{x \to 3^+} f(x)$ DNE.

*$\lim_{x \to 4} f(x)$ DNE.

*$\lim_{x \to 5^-} f(x)$ DNE.

 A: The general concept of "limit" is more fundamental than "one-sided limit", and the theorem you quote is specifically not a definition of $\lim_{x\to a}$.
In particular, the theorem strictly speaking has some hidden premises that are not clearly shown in the formulation you quote, namely that

*

*$a$ is a real number, and

*$f$ is defined everywhere in some punctured neighborhood of $a$ (in $\mathbb R$).

Your conclusions don't work because the first hidden premise fails to hold in the $\infty$ cases, and the second hidden premise fails to hold in the $a\to3,4,5$ cases.
The general concept of limit can be defined* whenever the domain of the function is (a subset of) a topological space, and the $a$ in $x\to a$ is an accumulation point of the domain of the function in question.
For your example this means that limits as $x\to 3$ and $x\to 5$ make sense (and exist), but a limit as $x\to 4$ does not make sense, because $4$ is not an accumulation point of the domain. To speak about limits as $x\to\infty$ or $x\to-\infty$ we can take the underlying topological space to be the extended real line.

*namely: If $X$ and $Y$ are topological spaces, $Z$ is a (not necessarily proper) subset of $X$, $f$ is a function $Z\to Y$, $a$ is an accumulation point of $Z$, and $b\in Y$, we say that $b=\lim_{x\to a} f(x)$ iff:

For every neighborhood $B$ of $b$ in $Y$, there is a neighborhood $A$ of $a$ in $X$ such that for all $x\in (A\cap Z)\setminus\{a\}$ it holds that $f(x)\in B$.

(It's an instructive exercise to verify that this is equivalent to the usual $\varepsilon$-$\delta$ definition of limit in the special case where $X$ and $Y$ are metric spaces rather than merely topological spaces, and $Z$ includes a punctured neighborhood of $a$).

One practical reason to downplay the concept of one-sided limits is that it doesn't generalize well to higher dimensions. For example, if we take
$$ f(x,y) = \frac{xy^2}{x^2+y^4} $$
defined on $\mathbb R^2\setminus\{(0,0)\}$,
then $\lim_{h\to 0^+}f(hp,hq)=0$ for every $(p,q)\ne(0,0)$ -- that is, no matter which direction we approach $(0,0)$ from, the "single-directional limit" of $f$ exists and is $0$ -- yet $\lim_{(x,y)\to(0,0)}f(x,y)$ does not exist!
A: The theorem that you cite only applies to finite limits, not limits to infinity. Limits to infinity are an entirely different beast.
To see why, consider that if $a$ and $l$ are real numbers, $\lim_{x \to a}f(x)=l$ means "we can make $f(x)$ as close to $l$ as we like by requiring that $x$ be sufficiently close to $a$". The notation $\lim_{x \to a^+}f(x)=l$ has the same meaning, except we are only considering values of $x$ satisfying $x>a$.
On the other hand, $\lim_{x \to \infty}f(x)=l$ cannot be interpreted as "we can make $f(x)$ as close to $l$ as we like by requiring that $x$ be sufficiently close to $\infty$". It is not clear what that would even mean. Instead, the symbol "$\infty$" is being used to capture what happens to $f(x)$ when $x$ is very large, and $\lim_{x \to \infty}f(x)=l$ means "we can make $f(x)$ as close to $l$ as we like by requiring that $x$ be sufficiently large". There is no coherent definition of $\lim_{x \to \infty^+}f(x)=l$.
