Unlock 100+ guides
search toc
Log in or sign up
Sign out
What does this mean?
Why is this true?
Give me some examples!
Searching Tips
Search for a recipe:
"Creating a table in MySQL"
Search for an API documentation: "@append"
Search for code: "!dataframe"
Apply a tag filter: "#python"
Useful Shortcuts
/ to open search panel
Esc to close search panel
to navigate between search results
d to clear all current filters
Enter to expand content preview
Doc Search
Code Search Beta
Start speaking...
Voice search is only supported in Safari and Chrome.
Navigate to

Comprehensive Guide on Continuity and Limits of Functions

schedule Aug 12, 2023
Last updated
Master the mathematics behind data science with 100+ top-tier guides
Start your free 7-days trial now!

Motivating example of continuity of functions

Before stating the formal definition of continuity and limits of functions, we will first go over a simple motivating example. Suppose we have the function $f(x)=2x$ with a hole at $x=4$ drawn below:

This means that the function is defined everywhere except for when $x=4$. Because of the existence of a hole at $x=4$, we say that the function is not continuous.

Intuition behind continuity of functions

One way of identifying whether a function is continuous or not is to ask if it's possible to draw the curve without ever lifting your pencil. In this case, if we were to draw the line $f(x)=2x$ from left to right, say starting from the origin, we would have to lift up our pencil at exactly $x=4$ because the function is not defined there. We can then continue to keep drawing the curve from after $x=4$. The fact that we cannot continuously draw the function without ever lifting up our pencil means that our function is not continuous. This means that if we can draw the function in one go, then it is continuous!

Intuition behind limits of functions

Let's now intuitively understand the concept of limits of functions. We know that $x=4$ is assumed to be undefined for our function $f(x)=2x$. This still means that values extremely close to $ x=4$ such as $x=3.999$ and $x=4.0001$ are defined. In fact, we can even go closer to $x=4$ by adding more $9$s to $3.999...$, as well as by adding more $0$s to $4.00...1$. In other words, we can get as close to $x=4$ as we wish but will never exactly reach $x=4$.

The function value at the undefined spot $x=4$ is:

$$\begin{equation}\label{eq:oLvpBtsf9BHT2E4730d} L=f(4)=8 \end{equation}$$

Remember, since $x=4$ is not defined, $f(4)$ is not defined either! Let's denote $f(4)$ as the limit $L$.

Now, let's play a simple game where you tell me how close you want to be to this limit $L=8$, and if I manage to give you some value of $x$ where $f(x)$ is closer to $L$ than what you specified, then I win the game - otherwise, I lose the game.

Let's play the first round of the game! Suppose you tell me that you want to be at least $4$ units close to $L=8$. This means that if I manage to give you some $x$ where $4\le{f(x)}\le12$, then I win the game. Equivalently, I can give you any $x$ value that satisfies:

$$\begin{equation}\label{eq:K5zUiPfH5jmwymdfKnx} \vert{f(x)-8}\vert\lt4 \end{equation}$$


  • $8$ is the limit $L$ and $4$ is the distance criteria that you specified.

  • $\vert{f(x)-8}\vert$ represents the distance between the function value and the limit. The absolute value is needed because we are only interested in how far away $f(x)$ is from $8$ and not whether $f(x)$ is above or below $8$.

Let's illustrate \eqref{eq:K5zUiPfH5jmwymdfKnx} on our graph:

The green interval is defined by \eqref{eq:K5zUiPfH5jmwymdfKnx}. As long as I give you a $x$ such that $f(x)$ is within the green interval, then I win the game. I can easily calculate the interval of $x$ values that satisfy this criterion:

Clearly, I can give you any number between $x=2$ and $x=6$ to win this game. Equivalently, picking a $x$ in the interval $(2,6)$ can also be expressed like so:

$$\begin{equation}\label{eq:k4MpHVwEQKj6KD1NkNN} \vert{x-4}\vert\lt2 \end{equation}$$

Where $4$ is the $x$ value for which $f(x)$ is undefined and $2$ specifies the interval. For instance, \eqref{eq:k4MpHVwEQKj6KD1NkNN} tells us that I shouldn't pick $x=7$ because $\vert{7-4}\vert=3\not\lt2$.

Now, in order to win the game, you may be tempted to specify a stricter condition for the second round. For instance, you specify that you want to be at least $1$ unit close to $L=8$. This is not at all a problem for me because I'll just give you a number between $ x=3.5$ and $x=4.5$ and I'll win the round again:

For the third round, you set even a stricter condition and specify that you want to be at least $0.1$ unit close to $L=8$. Again, I won't break a sweat because I'll give you a number between $x=3.95$ and $x=4.05$ to win the game once more.

The key here is that I will always win the game no matter how close to $L=8$ that you specify 😎. If you ask me to give a $x$ such that $f(x)$ is $0.0000001$ units away from the limit, I will still be able to do so! The other key insight is that this game is logically equivalent to the statement that we can get as close to the limit $L$ as we wish.

Deriving the formal definition of limits

Let's review how our previous game worked - you tell me to come up with some $x$ such that $f(x)$ is at least some distance (e.g. $0.1$ units) close to the limit $L$. I will always be able to give you this $x$ no matter how close you set the distance to be (and so I always win the game).

Let's generalize this game:

  • instead of a fixed function $f(x)=2x$, we'll just have some arbitrary $f(x)$.

  • instead of focusing on $x=4$, we focus on some point $x=c$. Let's assume that $f(x)$ is not defined at $x=c$.

The next few generalizations we make require some discussion so I won't include them in the above bullet list.

Instead of specifying some distance (e.g. $0.1$ units) close to the limit $L$, let's use the symbol $\varepsilon$ (read as epsilon). This means that you give me some $\varepsilon$, then my goal is to give you some $x$ value such that $f(x)$ is within the interval $(L-\varepsilon,L+\varepsilon)$. Equivalently, this can be expressed like so:

$$\begin{equation}\label{eq:TW6pt8R7yxZSoi4mAPr} \vert{f(x)-L}\vert\lt\varepsilon \end{equation}$$

Inequality \eqref{eq:TW6pt8R7yxZSoi4mAPr} means that the distance between $f(x)$ and $L$ must be less than the given $\varepsilon$. Graphically, we can represent this like so:

Since $\varepsilon$ represents how close to the limit $L$ we wish to be, $\varepsilon$ must always be positive. $\varepsilon$ cannot be zero because we know that $x=c$ is not defined.

Now, to win the game, I must find some $x$ such that the corresponding function value is within the green interval specified by \eqref{eq:TW6pt8R7yxZSoi4mAPr}. The $x$ values that satisfy this criterion is shown in the red interval below:

Here, we are using the symbol $\delta$ to describe the red interval. As long as we are within $\delta$ from $c$, then the corresponding function value should be within $\varepsilon$ from $L$. This means that we choose $x$ such that:

$$\begin{equation}\label{eq:i0Dh993PNe0rn1ziqvg} \vert{x-c}\vert\lt\delta \end{equation}$$

Just like how $\varepsilon\gt0$, we have that $\delta$ must also be strictly greater than $0$.

We've introduced many symbols and you might be overwhelmed 🤯, so let's take a moment to see how this all relates to the motivating example from earlier. Again, let $f(x)=2x$ where $x=c$ is not defined. Suppose you tell me that you want a $x$ such that $f(x)$ is within $\varepsilon=4$ from $L=8$. Substituting $\varepsilon$ and $L$ into \eqref{eq:TW6pt8R7yxZSoi4mAPr} gives:

$$\vert{f(x)-L}\vert\lt\varepsilon \;\;\;\implies\;\;\; \vert{f(x)-8}\vert\lt4$$

This interval is shown below:

Now, I can easily calculate that if I choose a $x$ within the interval $(2,6)$, then the corresponding function values $f(x)$ will be within $\varepsilon=4$ from $L$. This interval $(2,6)$ will be centered around $c=4$, which means we can equivalently express the interval using the format of \eqref{eq:i0Dh993PNe0rn1ziqvg} like so:

$$\begin{equation}\label{eq:kcJojUUPD0KGS3YMsZb} \vert{x-c}\vert\lt\delta \;\;\;\implies\;\;\; \vert{x-4}\vert\lt2 \end{equation}$$

Here, we set $\delta=2$. Let's illustrates this interval:

Great, as long as I pick any $x$ that satisfies \eqref{eq:kcJojUUPD0KGS3YMsZb}, then I win the game!

The main idea is that no matter what $\varepsilon$ you give me, I can construct some interval using $\delta$ such that if I pick any $x$ value within this interval, then I will be at least within $\varepsilon$ of $L$. In other words, given $\varepsilon\gt0$, there exists some $\delta\gt0$ such that if $\vert{x-c}\vert\lt\delta$, then $\vert{f(x)}-L\vert\lt\varepsilon$. This is precisely the formal definition of limits!


Just a quick note before we look into the formal definition of limits. We have assumed our function to be undefined at $x=c$, but this assumption is not necessary at all as we have not relied on this assumption in any step. We can still define and compute limits on any point regardless of whether the function is defined at the point or not.

The reason why I made $x=c$ undefined is to emphasize that all we care about is the neighborhood of the point, that is, what happens to the function as we get closer and closer to the point of interest $x$! In other words, we don't care about what happens at the point itself.


Formal definition of limits of functions

Let $f:\mathbb{R}\to\mathbb{R}$ be a function and let $c\in\mathbb{R}$. Then, $L\in\mathbb{R}$ is called the limit of $f$ as $x$ approaches $c$, if for any $\varepsilon\gt0$, we can find $\delta\gt0$ such that if $\vert{x−c}\vert\lt\delta$, we have $\vert{f(x) − L}\vert\lt\varepsilon$. We denote the limit of $f$ as $x$ approaches $c$ as:


Proving the limit of a function (1)

Consider the function $f:\mathbb{R}\to\mathbb{R}$ below:


Using the formal definition of limits of functions, prove that the limit of $f$ when $x$ approaches $1$ is equal to $2$, that is:


Proof. Given $\varepsilon\gt0$, I need to show that there exists some $\delta\gt0$ such that if $\vert{x-1}\vert\lt\delta$, then $\vert{f(x)-L}\vert\lt\varepsilon$. Before we begin our formal proof, let's do some scratch work to find $\delta$ first:

$$\begin{equation}\label{eq:fBb1c2rh9T2qo9ldNZ4} \begin{aligned}[b] &\;\;\;\;\;\;\;\;\;\vert{f(x)-L}\vert\lt\varepsilon\\ &\Longleftrightarrow\Big\vert{\frac{2x(x-1)}{x-1}-2}\Big\vert\lt\varepsilon\\ &\Longleftrightarrow\vert2x-2\vert\lt\varepsilon\\ &\Longleftrightarrow\vert{2(x-1)}\vert\lt\varepsilon\\ &\Longleftrightarrow2\vert{x-1}\vert\lt\varepsilon\\ &\Longleftrightarrow\vert{x-1}\vert\lt\frac{\varepsilon}{2} \end{aligned} \end{equation}$$

Here, note the following:

  • the $\Longleftrightarrow$ means that the current step implies the next step but also that the next step implies the current step.

  • in the second step, we crossed out $(x-1)$ - we can do so because we're interested in the limit as $x$ tends to $1$ so $x$ will not be exactly equal to $1$, but rather just extremely close to $1$. Therefore, we can safely cross out $(x-1)$.

Remember, the goal is to show that there exists some $\delta\gt0$ such that if $\vert{x-1}\vert\lt\delta$, then $\vert{f(x)-L}\vert\lt\varepsilon$. Our work in \eqref{eq:fBb1c2rh9T2qo9ldNZ4} tells us that if we let $\delta$ to be:

$$\begin{equation}\label{eq:LamyG0IsWdlH6EURjnv} \delta=\frac{\varepsilon}{2} \end{equation}$$

Then we have that:

$$\begin{equation}\label{eq:EvsgO32sNzI9jkGDCWr} \vert{x-1}\vert\lt\delta \implies \vert{f(x)-L}\vert\lt\varepsilon \end{equation}$$

Note that the reason the former implies the latter in \eqref{eq:EvsgO32sNzI9jkGDCWr} is because every step in \eqref{eq:fBb1c2rh9T2qo9ldNZ4} is related by a bi-directional implication $\Longleftrightarrow$. Great, \eqref{eq:EvsgO32sNzI9jkGDCWr} is exactly what we wanted to prove!

Therefore, by the definition of limits of functions, we conclude that:


Before we move on to the next section, let's take a step back and intuitively understand what we've done here. If you give me any positive $\varepsilon$, then I can use \eqref{eq:LamyG0IsWdlH6EURjnv} to obtain a $\delta$ that allows me to construct the interval $\vert{x-1}\vert\lt\delta$. If I pick $x$ within this interval, then $\vert{f(x)-L}\vert\lt\varepsilon$ will be true, which means that the corresponding function value $f(x)$ will be within distance $\varepsilon$ of $L$.

For instance, suppose you give me $\varepsilon=6$. I then use \eqref{eq:LamyG0IsWdlH6EURjnv} to obtain $\delta=3$. From \eqref{eq:EvsgO32sNzI9jkGDCWr}, we know that:

$$\begin{equation}\label{eq:WSd2Pf0ngVKMoAyt5rz} \vert{x-1}\vert\lt3 \implies \vert{f(x)-L}\vert\lt6 \end{equation}$$

Let's pick some number that satisfies the left-hand side - say $x=2$. From \eqref{eq:WSd2Pf0ngVKMoAyt5rz}, we know that $\vert{f(2)-L}\vert\lt6$, which means that the function value at $x=2$ is within $\varepsilon=6$ distance of $L$. We have proven that this result is always true, but we can still confirm this by hand:

$$\begin{align*} \vert{f(2)-L}\vert&=\Big\vert\frac{2(2)(2-1)}{2-1}-2\Big\vert\\ &=\vert{4-2}\vert\\ &=2 \end{align*}$$

This is less than $\varepsilon=6$, which is exactly the result we should expect!

Finally, let's end by plotting $f$:

We see that there is indeed a "hole" at $x=1$ where the function is not defined! Note that even if the function is not defined at $x=1$, the limit of the function as $x$ approaches $1$ is still defined.


Proving the limit of a function (2)

Consider the following function:


Prove the following:

$$\lim_{x\to2} f(x) =3$$

Proof. For any given $\varepsilon\gt0$, we must find some $\delta\gt0$ such that:

$$\vert{x-2}\vert \lt\delta\implies \vert{f(x)-3}\vert\lt\varepsilon$$

Let's work backward and try to find this $\delta$ like so:

$$\begin{equation}\label{eq:QLhJ8pIuEWSW9GUVwCE} \begin{aligned}[b] &\;\;\;\;\;\;\;\;\;\vert{f(x)-L}\vert\lt\varepsilon\\ &\Longleftrightarrow\Big\vert{(2x-1)-3}\Big\vert\lt\varepsilon\\ &\Longleftrightarrow\vert2x-4\vert\lt\varepsilon\\ &\Longleftrightarrow2\vert{x-2}\vert\lt\varepsilon\\ &\Longleftrightarrow\vert{x-2}\vert\lt\frac{\varepsilon}{2} \end{aligned} \end{equation}$$

This implies the following:

$$\vert{x-2}\vert\lt\frac{\varepsilon}{2} \implies \vert{f(x)-3}\vert\lt\varepsilon$$

Therefore, if we let $\delta=\varepsilon/2$, then we have managed to find $\delta\gt0$ such that we can get as arbitrarily close as we wish to the function limit of $L=3$. In other words, the limit of our $f(x)$ as $x$ approaches $2$ is:

$$\lim_{x\to2} f(x) =3$$

Here's a diagram to illustrate what we have found:

This means that given any $\varepsilon\gt0$ no matter how small, I can always find some $x$ within the interval $2-\varepsilon$ and $2+\varepsilon$ that will get me closer to the function limit $L=3$ than $\varepsilon$. This completes the proof.


Formal definition of continuity of functions

Let $f:\mathbb{R}\to\mathbb{R}$ be a function. $f$ is said to be continuous at $c\in\mathbb{R}$ if and only if the following 3 conditions are satisfied:

  • $f(c)$ is defined.

  • $\lim_{x\to{c}}f(x)$ exists.

  • $\lim_{x\to{c}}f(x)=f(c)$.

If any of these conditions fail at $x=c$, then $f$ is said to be discontinuous at $x=c$.


Proving that a function is continuous

Consider the following function:


Show that $f$ is continuous at $x=2$.

Solution. Firstly, $f(2)$ is defined since:

$$\begin{align*} f(2)&=2(2)-1\\ &=3 \end{align*}$$

Next, in our previous examplelink, we have shown that the limit of $f(x)$ as $x$ approaches $2$ is:


Therefore, the following three conditions are satisfied:

  • $f(2)$ is defined.

  • $\lim_{x\to2}f(x)$ exists.

  • $\lim_{x\to2}f(x)=f(2)$.

By definition of continuity of functions, we conclude that $f$ is continuous at $x=2$.

Let's now take a moment to intuitively understand why our function is continuous at $x=2$:

Observe how the function does not have a hole at $x=2$, that is, we can take a pencil and draw the function without lifting up our pencil at the region $x=2$. This is what it means for a function to be continuous at a particular point.


Proving that a function is discontinuous at a point (1)

Consider the following function:


Is $f$ continuous at $x=1$?

Solution. Clearly, when $x=1$, the denominator becomes zero, and so the function is not defined at this point. This means that $f$ is discontinuous at $x=1$.

The graph of $f$ is shown below:

As can be seen, there is a hole at $x=1$, which means the function is not defined there. If we take a pencil and try to draw the function from say $x=0$ to $x=2$, we will have to lift up our pencil at $x=1$ - this is why the function is not continuous at $x=1$.


Proving that a function is discontinuous at a point (2)

Consider the following function:

$$f(x)= \begin{cases} \dfrac{x^2-1}{x-1},&x\ne1\\ 1,&x=1 \end{cases}$$

Is $f$ continuous at $ x=1$?

Solution. Unlike the previous example, when $x=1$, the function is defined in this case since $f(1)=2$. Let's take the limit of $f$ as $x$ tends to $1$:

$$\begin{align*} \lim_{x\to{1}} \frac{x^2-1}{x-1} &= \lim_{x\to{1}} \frac{(x+1)(x-1)}{x-1}\\ &=\lim_{x\to{1}} x+1\\ &=2 \end{align*}$$

Therefore, we have the result that $\lim_{x\to1}f(x)=2$, but this is different from $f(1)=1$. Therefore, the third condition of continuity is not satisfied, thereby making $f$ discontinuous at $x=1$.

Graphically, $f$ looks like the following:

Notice the function value suddenly drops at $x=1$ - this is what makes the function discontinuous at this point.

Final remarks

We've explored the formal definition of continuity and limits of functions in this guide. Even though these topics are intuitively simple to understand, their formal definition is based on rigorous mathematics that is honestly quite daunting at first glance. I hope that our simple example at the start helped build your intuition about the definition!

In future articles, we will use this formal definition of continuity and limits to prove the properties of limits and other important theorems, so stay tuned!

Published by Isshin Inada
Edited by 0 others
Did you find this page useful?
Ask a question or leave a feedback...