As we noted above, the definition of limits that we have been working with was quite informal and not mathematically rigorous. In this (optional) section we will work to understand the rigorous definition of limits.
Here is the formal definition — we will work through it all very slowly and carefully afterwards, so do not panic.
Definition 1.7.1
Let \(a \in \mathbb{R}\) and let \(f(x)\) be a function defined everywhere in a neighbourhood of \(a\text{,}\) except possibly at \(a\text{.}\) We say that
the limit as \(x\) approaches \(a\) of \(f(x)\) is \(L\)
or equivalently
as \(x\) approaches \(a\text{,}\) \(f(x)\) approaches \(L\)
and write
\begin{align*}
\lim_{x \to a} f(x) &= L
\end{align*}
if and only if for every \(\epsilon \gt 0\) there exists \(\delta \gt 0\) so that
\begin{align*}
f(x)  L \lt \epsilon & \text{ whenever } 0 \lt xa \lt \delta
\end{align*}
Note that an equivalent way of writing this very last statement is
\begin{gather*}
\text{if } 0 \lt xa \lt \delta \text{ then } f(x)  L \lt \epsilon.
\end{gather*}
This is quite a lot to take in, so let us break it down into pieces.
Definition 1.7.2 The typical 3 pieces of a definition
Usually a definition can be broken down into three pieces.
 Scene setting — define symbols and any restrictions on the objects that we are talking about.
 Naming — state the name and any notation for the property or object that the definition is about.
 Properties and restrictions — this is the heart of the definition where we explain to the reader what it is that the object (in our case a function) has to do in order to satisfy the definition.
Let us go back to the definition and look at each of these pieces in turn.

Setting things up — The first sentence of the definition is really just setting up the picture. It is telling us what the definition is about and sorting out a few technical details.

Let \(a \in \mathbb{R}\) — This simply tells us that the symbol “\(a\)” is a real number ^{ 1 }.

Let \(f(x)\) be a function — This is just setting the scene so that we understand all of the terms and symbols.

defined everywhere in a neighbourhood of \(a\text{,}\) except possibly at \(a\) — This is just a technical requirement; we need our function to be defined in a little region ^{ 2 } around \(a\text{.}\) The function doesn't have to be defined everywhere, but it must be defined for all \(x\)values a little less than \(a\) and a little more than \(a\text{.}\) The definition does not care about what the function does outside this little window, nor does it care what happens exactly at \(a\text{.}\)
 Names, phrases and notation — The next part of the definition is simply naming the property we are discussing and tells us how to write it down. i.e. we are talking about “limits” and we write them down using the symbols indicated.

The heart of things — we explain this at length below, but for now we will give a quick explanation. Work on these two points. They are hard.

for all \(\epsilon \gt 0\) there exists \(\delta \gt 0\) — It is important we read this in order. It means that we can pick any positive number \(\epsilon\) we want and there will always be another positive number \(\delta\) that is going to make what ever follows be true.

if \(0 \lt xa \lt \delta\) then \(f(x)L \lt \epsilon\) — From the previous point we have our two numbers — any \(\epsilon \gt 0\) then based on that choice of \(\epsilon\) we have a positive number \(\delta\text{.}\) The current statement says that whenever we have chosen \(x\) so that it is very close to \(a\text{,}\) then \(f(x)\) has to be very close to \(L\text{.}\) How close it “very close”? Well \(0 \lt xa \lt \delta\) means that \(x\) has to be within a distance \(\delta\) of \(a\) (but not exactly \(a\)) and similarly \(f(x)L \lt \epsilon\) means that \(f(x)\) has to be within a distance \(\epsilon\) of \(L\text{.}\)
That is the definition broken up into pieces which hopefully now make more sense, but what does it actually mean? Consider a function we saw earlier
\begin{align*}
f(x) &= \begin{cases}
2x & x\neq3\\
9 & x=3
\end{cases}
\end{align*}
and sketch it again:
We know (from our earlier work) that \(\lim_{x \to 3} f(x) = 6\text{,}\) so zoom in around \((x,y)=(3,6)\text{.}\) To make this look more like our definition, we have \(a=3\) and \(L=6\text{.}\)
 Pick some small number \(\epsilon \gt 0\) and highlight the horizontal strip of all points \((x,y)\) for which \(yL \lt \epsilon\text{.}\) This means all the \(y\)values have to satisfy \(L\epsilon \lt y \lt L+\epsilon\text{.}\)
 You can see that the graph of the function passes through this strip for some \(x\)values close to \(a\text{.}\) What we need to be able to do is to pick a vertical strip of \(x\)values around \(a\) so that the function lies inside the horizontal strip.
 That is, we must find a small number \(\delta \gt 0\) so that for any \(x\)value inside the vertical strip \(a\delta \lt x \lt a+\delta\text{,}\) except exactly at \(x=a\), the value of the function lies inside the horizontal strip, namely \(L\epsilon \lt y=f(x) \lt L+\epsilon\text{.}\)
 We see (pictorially) that we can do this. If we were to choose a smaller value of \(\epsilon\) making the horizontal strip narrower, it is clear that we can choose the vertical strip to be narrower. Indeed, it doesn't matter how small we make the horizontal strip, we will always be able to construct the second vertical strip.
The above is a pictorial argument, but we can quite easily make it into a mathematical one. We want to show the limit is \(6\text{.}\) That means for any \(\epsilon\) we need to find a \(\delta\) so that when
\begin{align*}
3\delta \lt x \lt 3+\delta \text{ with $x \neq 3$} && \text{we have } &&
6\epsilon \lt f(x) \lt 6+\epsilon
\end{align*}
Now we note that when \(x \neq 3\text{,}\) we have \(f(x)=2x\) and so
\begin{align*}
6\epsilon \lt f(x) \lt 6+\epsilon && \text{implies that} &&
6\epsilon \lt 2x \lt 6+\epsilon\\
\end{align*}
this nearly specifies a range of \(x\) values, we just need to divide by \(2\)
\begin{align*}
3\epsilon/2 \lt x \lt 3+\epsilon/2\\
\end{align*}
Hence if we choose \(\delta = \epsilon/2\) then we get the desired inequality
\begin{align*}
3\delta \lt x \lt 3+\delta
\end{align*}
i.e. — no matter what \(\epsilon \gt 0\) is chosen, if we put \(\delta=\epsilon/2\) then when \(3\delta \lt x \lt 3+\delta\) with \(x \neq 3\) we will have \(6\epsilon \lt f(x) \lt 6+\epsilon\text{.}\) This is exactly what we need to satisfy the definition of “limit” above.
The above work gives us the argument we need, but it still needs to be written up properly. We do this below.
Example 1.7.3 Formal limit of a simple function
Find the limit as \(x \to 3\) of the following function
\begin{align*}
f(x) &= \begin{cases}
2x & x\neq 3\\
9 & x=3
\end{cases}
\end{align*}
Proof
We will show that the limit is equal to \(6\text{.}\) Let \(\epsilon \gt 0\) and \(\delta =
\epsilon/2\text{.}\) It remains to show that \(f(x)6 \lt \epsilon\) whenever \(x3 \lt \delta\text{.}\)
So assume that \(x3 \lt \delta\text{,}\) and so
\begin{align*}
3\delta \lt x \lt 3+\delta && \text{multiply both sides by 2}\\
62\delta \lt 2x \lt 6+2\delta\\
\end{align*}
Recall that \(f(x)=2x\) and that since \(\delta=\epsilon/2\)
\begin{align*}
6\epsilon \lt f(x) \lt 6+\epsilon.
\end{align*}
We can conclude that \(f(x)6 \lt \epsilon\) as required.
Because of the \(\epsilon\) and \(\delta\) in the definition of limits, we need to have \(\epsilon\) and \(\delta\) in the proof. While \(\epsilon\) and \(\delta\) are just symbols playing particular roles, and could be replaced with other symbols, this style of proof is usually called \(\epsilon\)–\(\delta\) proof.
In the above example everything works, but it can be very instructive to see what happens in an example that doesn't work.
Example 1.7.4 Formal limit where limit does not exist
Look again at the function
\begin{align*}
f(x) &= \begin{cases}
x & x \lt 2\\
1 & x=2\\
x+3 & x \gt 2
\end{cases}
\end{align*}
and let us see why, according to the definition of the limit, that \(\ds \lim_{x
\to 2} f(x) \neq 2\text{.}\) Again, start by sketching a picture and zooming in around \((x,y) = (2,2)\text{:}\)
Try to proceed through the same steps as before:
 Pick some small number \(\epsilon \gt 0\) and highlight a horizontal strip that contains all \(y\)values with \(yL \lt \epsilon\text{.}\) This means all the \(y\)values have to satisfy \(L\epsilon \lt y \lt L+\epsilon\text{.}\)
 You can see that the graph of the function passes through this strip for some \(x\)values close to \(a\text{.}\) To the left of \(a\text{,}\) we can always find some \(x\)values that make the function sit inside the horizontal\(\epsilon\)strip. However, unlike the previous example, there is a problem to the right of \(a\text{.}\) Even for \(x\)values just a little larger than \(a\text{,}\) the value of \(f(x)\) lies well outside the horizontal\(\epsilon\)strip.
 So given this choice of \(\epsilon\text{,}\) we can find a \(\delta \gt 0\) so that for \(x\) inside the vertical strip \(a\delta \lt x \lt a\text{,}\) the value of the function sits inside the horizontal\(\epsilon\)strip.
 Unfortunately, there is no way to choose a \(\delta \gt 0\) so that for \(x\) inside the vertical strip \(a \lt x \lt a+\delta\) (with \(x \neq a\)) the value of the function sits inside the horizontal\(epsilon\)strip.
 So it is impossible to choose \(\delta\) so that for \(x\) inside the vertical strip \(a\delta \lt x \lt a+\delta\) the value of the function sits inside the horizontal strip \(L\epsilon \lt y=f(x) \lt L+\epsilon\text{.}\)
 Thus the limit of \(f(x)\) as \(x \to 2\) is not \(2\text{.}\)
Doing things formally with \(\epsilon\)'s and \(\delta\)'s is quite painful for general functions. It is far better to make use of the arithmetic of limits (Theorem 1.4.3) and some basic building blocks (like those in Theorem 1.4.1). Thankfully for most of the problems we deal with in calculus (at this level at least) can be approached in exactly this way.
This does leave the problem of proving the arithmetic of limits and the limits of the basic building blocks. The proof of the Theorem 1.4.3 is quite involved and we leave it to the very end of this Chapter. Before we do that we will prove Theorem 1.4.1 by a formal \(\epsilon\)–\(\delta\) proof. Then in the next section we will look at the formal definition of limits at infinity and prove Theorem 1.5.3. The proof of the Theorem 1.5.9, the arithmetic of infinite limits, is very similar to that of Theorem 1.4.3 and so we do not give it.
So let us now prove Theorem 1.4.1 in which we stated two simple limits:
\begin{align*}
\lim_{x \to a} c &= c & \text{ and } && \lim_{x \to a} x &= a.
\end{align*}
Here is the formal \(\epsilon\)–\(\delta\) proof:
Proof
Proof of Theorem 1.4.1
Since there are two limits to prove, we do each in turn. Let \(a,c\) be real numbers.
This completes the proof.