Limits and continuity

A limit asks "if you get closer and closer, where do you end up?" Even when there is no value at a spot, even when you would divide by 0, you can still say where the values are heading. Derivatives, integrals, and the idea that AI training "converges" all rest on this. If functions are new to you, start with the functions page.

Short answer. A limit is the value f(x) gets closer to as x gets closer and closer to some number a. You look at where the values are heading, not at the value at x = a itself. That is why you can say "where it is going" even at a spot where you would divide by 0, and that is what derivatives and integrals are built on. Continuous means the value it is heading for and the value on the spot are the same.

Distance dLeft xf(x)Right xf(x)

Each step you move the "Distance d" slider to the right makes d 10 times smaller and adds a row to the table. Green dots walk in from the left (x = a − d), blue dots from the right (x = a + d). The black dashed line is where both sides gather (the limit), the purple dot is the value on the spot f(a), and a hollow circle means "there is no value here." When a dot leaves the picture, an arrow (↑, ↓) shows where it went. Values in the table are rounded to 6 decimal places.

Definitions

The text below explains with tables and pictures. Textbooks define the ideas with ε and δ as follows. The function f is defined on an open interval that contains a (it does not have to be defined at a itself).

limit
If for every ε > 0 there is a δ > 0 such that |f(x) − L| < ε for every x with 0 < |x − a| < δ, then the limit of f(x) as x goes to a is L, written limx→af(x)=L.

limx→af(x)=L⟺∀ε>0,∃δ>0:0<|x−a|<δ⟹|f(x)−L|<ε

left-hand limit, right-hand limit
In the definition of a limit, keeping x on the smaller side (a − δ < x < a) gives the left-hand limit, and keeping x on the bigger side (a < x < a + δ) gives the right-hand limit. The limit exists if and only if both one-sided limits exist and are equal.

limx→af(x)=L⟺limx→a−f(x)=limx→a+f(x)=L

continuous
f is continuous at x = a when f(a) is defined, the limit limx→af(x) exists, and the two are equal. f is continuous on an interval when it is continuous at every point of the interval (at an end point, use the one-sided limit from inside).

limx→af(x)=f(a)

limit at infinity
If for every ε > 0 there is an N such that |f(x) − L| < ε for every x > N, you write limx→∞f(x)=L. x → −∞ is defined the same way with x < N.

limx→∞f(x)=L⟺∀ε>0,∃N:x>N⟹|f(x)−L|<ε

horizontal asymptote
If limx→∞f(x)=L or limx→−∞f(x)=L, the line y = L is a horizontal asymptote of the curve y = f(x).

1. A limit: look where it is heading, not at the spot

Put x = 1 into f(x) = (x² − 1) ÷ (x − 1) and you get 0 ÷ 0. There is no value. On a graph it is a straight line with a hole at x = 1.

Still, when you bring x close to 1, f(x) is clearly heading somewhere.

x0.90.990.99911.0011.011.1
f(x)1.91.991.999none (0 ÷ 0)2.0012.012.1

Coming from the left or from the right, the values gather at 2. This 2 is the limit of f(x) as x goes to 1. You write it like this.

limx→1f(x)=2

"as x gets closer and closer to 1, f(x) gets closer and closer to 2"

lim is short for limit. Under or next to the arrow you write where x is going. Two things matter most.

"Closer and closer" means "as close as you like." Section 4 shows how to say that exactly.

Try this. ① As it starts ((x² − 1) ÷ (x − 1), a = 1, d = 1), the left side is f(0) = 1 and the right side is f(2) = 3. Move the "Distance d" slider to the right and you get 1.9 and 2.1, then 1.99 and 2.01, then 1.999 and 2.001. Both sides gather at 2. A hollow circle stays at x = 1. ② Switch to sin x ÷ x and a becomes 0. The values go 0.841471, 0.998334, 0.999983 and gather at 1. This function also has no value at x = 0, because it is 0 ÷ 0 there. ③ Pick x² (a = 1). Both sides gather at 1, and f(1) = 1, so the purple dot sits right on the limit. ④ With (x² − 1) ÷ (x − 1), type 2 into the a box. The limit is 3 and the value on the spot is 3 too. The only hole is at x = 1.

2. The left limit and the right limit

There are two roads into a: from the smaller side (the left) and from the bigger side (the right). A limit you get by looking at only one road is a one-sided limit.

WrittenRead as
lim x→a⁻ f(x)Left limit. x comes in from the side smaller than a. The small − means "smaller side"
lim x→a⁺ f(x)Right limit. x comes in from the side bigger than a. The small + means "bigger side"
lim x→a f(x)The limit. It exists only when both one-sided limits exist and are the same

Example: the staircase ⌊x⌋ is the biggest whole number that is not more than x (JavaScript's Math.floor(x)). Just left of x = 1 (0.9, 0.99, 0.999) it is always 0. Just right (1.1, 1.01, 1.001) it is always 1.

lim x→1⁻ ⌊x⌋ = 0 and lim x→1⁺ ⌊x⌋ = 1. They differ, so lim x→1 ⌊x⌋ does not exist. That is true even though the value ⌊1⌋ = 1 exists. The value on the spot does not decide the limit.

3. Three ways a limit fails to exist

CaseExampleWhat you see in the lab
The sides differ⌊x⌋, x → 1The left side gathers at 0, the right side at 1. The two dots never meet
The values blow up1 ÷ x, x → 0The left side goes −1, −10, −100, …, the right side 1, 10, 100, …. The size grows without end
The values keep swingingsin(1 ÷ x), x → 0The values jump around between −1 and 1, like 0.84, −0.54, −0.51, 0.83, …, and never settle

The blow-up case is sometimes written lim x→0⁺ 1 ÷ x = +∞. Here ∞ is not a number. It is a sign that says "grows without end." It does not mean the limit exists.

Why sin(1 ÷ x) keeps swinging: as x gets close to 0, 1 ÷ x grows without end, and sin goes up and down countless times along the way. The closer you get to 0, the faster it goes up and down, so however close you get, it still passes through both −1 and 1 in between.

Try this. ① Switch to the ⌊x⌋ staircase and a becomes 1. Even with the slider all the way right, the left side is 0 and the right side is 1 (only at d = 1 is the right side f(2) = 2). The purple dot f(1) = 1 matches the right limit. Type 1.5 into the a box and both sides gather at 1: the limit exists, and the function is continuous there. ② With 1 ÷ x, the dots leave the picture at the top and bottom as you move the slider (arrows), and the table values grow 10 times each step. ③ With sin(1 ÷ x), the right side goes 0.841471, −0.544021, −0.506366, 0.82688, −0.305614, 0.035749. Type 0.5 into the a box and it gathers at 0.909297. Away from 0, this function behaves well.

4. Saying "close enough" exactly: epsilon and delta

"Closer and closer" can be pinned down with a game instead of a feeling. Someone names an allowed gap: "get f(x) within this much (ε) of 2." You answer: "just bring x within this much (δ) of a." If, however small they make ε, you can always name a δ that works, then the limit is 2.

The exact meaning of lim x→a f(x) = L: for every ε > 0 there is some δ > 0 such that whenever 0 < |x − a| < δ, it is always true that |f(x) − L| < ε.

The 0 < |x − a| part says "leave out x = a itself." ε is the Greek letter epsilon and δ is delta. By habit, both are used for "a very small amount."

The blue band across is where f(x) must land (center ± ε). The purple band up and down is where x is allowed (a ± δ). Inside the purple band, the curve is green where it is inside the blue band and orange where it is outside. A point right on the edge of the band counts as outside (it has to be "less than ε"). For a function with no limit, like the staircase, the center of the band is halfway between the two one-sided limits (0.5). That is the most generous place to put it. "Find it for me" moves δ to the biggest slider value that works.

Try this. ① As it starts (ε = 0.5, δ = 1), it does not work. When x is less than 0.5 or more than 1.5, f(x) leaves the band from 1.5 to 2.5. Bring δ down to 0.5 and it works. ② Bring ε down to 0.1 and press "Find it for me". You get δ = 0.1. For x ≠ 1 this function is f(x) = x + 1, so δ = ε always works. However small ε is, there is a δ that works, so the limit is 2. ③ With sin x ÷ x and ε = 0.1, the biggest δ that works is 0.787 (0.78 on the slider). ④ On the ⌊x⌋ staircase, when ε is 0.5 or less, even "Find it for me" fails with the smallest δ = 0.01. To fit the left value 0 and the right value 1 in one band, the band height 2ε has to be more than 1. With ε = 0.55, everything up to δ = 1 works. "There is at least one ε that no δ can handle" is exactly what "there is no limit" means.

5. Continuity: the limit equals the value on the spot

A function is continuous at x = a when all three of these hold.

  1. The value f(a) exists.
  2. The limit lim x→a f(x) exists.
  3. They are the same: lim x→a f(x) = f(a).

Put simply, you can draw the graph without lifting your pencil. There really is a dot where the values are heading, so the line carries on without a break. A function that is continuous everywhere in its range is just called a "continuous function."

There are three main ways a graph can break.

ShapeExampleWhat goes wrongTextbook name
Hole(x² − 1) ÷ (x − 1), x = 1The limit (2) exists, but there is no value on the spot (or the value differs from the limit)Removable discontinuity
Jump⌊x⌋, x = 1The left limit (0) and the right limit (1) are differentJump discontinuity
Blow-up1 ÷ x, x = 0One side or both sides grow without endInfinite discontinuity

A hole can be filled. If you set the value at x = 1 to the limit 2, you get a continuous function, the same as x + 1. A jump or a blow-up cannot be fixed by choosing one dot. Something that keeps swinging, like sin(1 ÷ x), is yet another kind of break that is none of these three.

Most functions you use often are continuous. Polynomials (x², x³ − 3x and so on), sin, cos, and eˣ are continuous everywhere, and a division is continuous everywhere except where the bottom becomes 0. Where a function is continuous, you find the limit by just putting the value in.

Try this. The last sentence of lab 1's readout tells you whether the function is continuous. x² is "continuous" at every a. (x² − 1) ÷ (x − 1) is "broken" only at a = 1. The ⌊x⌋ staircase is "broken" only when a is a whole number (−2, −1, 0, 1, 2). 1 ÷ x and sin(1 ÷ x) are continuous everywhere except a = 0.

6. Rules for working out limits

You do not need a table every time. If you know the limits of two functions, you also know the limit of their sum, product, and quotient. When x goes to the same a, and lim f(x) = A and lim g(x) = B:

RuleFormulaExample (x → 2)
Sum, differencelim (f ± g) = A ± Blim (x² + x) = 4 + 2 = 6
Constant timeslim c·f = c·Alim 3x = 3 × 2 = 6
Productlim (f·g) = A·Blim x·(x + 1) = 2 × 3 = 6
Quotientlim (f ÷ g) = A ÷ B, only if B ≠ 0lim (x + 1) ÷ x = 3 ÷ 2 = 1.5

The quotient rule has a condition. If the limit of the bottom, B, is 0, you cannot use it. If the limit of the top is 0 as well, you have the "0 ÷ 0 form" from the next section.

7. The 0 ÷ 0 form, worked by hand

As x → 1, the top and the bottom of (x² − 1) ÷ (x − 1) both go to 0. This is called the 0 ÷ 0 form. It does not mean "the answer is 0 ÷ 0." It means "you cannot tell yet." Depending on how fast the top and the bottom shrink to 0, the answer could be anything.

So with a 0 ÷ 0 form, you rewrite the formula to cancel the part that makes the 0, or you walk in with a table.

Example 1: (x² − 1) ÷ (x − 1), x → 1 (by factoring)

  1. Just put it in. Top 1 − 1 = 0, bottom 1 − 1 = 0. It is a 0 ÷ 0 form, so the quotient rule does not apply.
  2. Factor the top. x² − 1 = (x − 1)(x + 1).
  3. Cancel the common part. (x − 1)(x + 1) ÷ (x − 1) = x + 1. When x ≠ 1, x − 1 is not 0, so you may cancel it. A limit never looks at x = 1 itself, so this is enough.
  4. Now put it in. x + 1 is continuous, so lim x→1 (x + 1) = 1 + 1 = 2.
  5. Check. The first table in lab 1: left 1.9, 1.99, 1.999 and right 2.1, 2.01, 2.001. They gather at 2.

Written only as formulas, the same work looks like this.

limx→1x2−1x−1=limx→1(x−1)(x+1)x−1

=limx→1(x+1)(x≠1)

=1+1=2

Example 2: sin x ÷ x, x → 0 (with a table)

You cannot factor this one away. Work it out while shrinking x (x is in radians, an angle measured in radius lengths).

xsin xsin x ÷ x
10.8414710.841471
0.10.09983340.998334
0.010.009999830.999983
0.0010.000999999830.99999983
closer to 001

It gathers at 1. The negative side (−0.1, −0.01, …) gives the same values, because sin(−x) ÷ (−x) = sin x ÷ x. So lim x→0 sin x ÷ x = 1. It means "when x is small, sin x is almost the same as x," and this limit is the reason the derivative of sin is cos. A table is not a proof. Textbooks use a circle of radius 1 to show cos x < sin x ÷ x < 1, and since both sides go to 1, the middle must go to 1 as well (the squeeze theorem). Section 8, "How the formula is built", walks through it one step at a time.

8. How the formula is built: sin x ÷ x → 1

The table in Example 2 only shows the values gathering at 1. Here one picture of a circle with radius 1 builds lim x→0 sin x ÷ x = 1. There is one idea: trap sin x ÷ x between two values that both go to 1. The trap is made from three areas whose order you can see. x is in radians, and the argument works for 0 < x < π ÷ 2 (about 1.57). The slider picks x from 0.01 to 1.

Press "Next" to go one step at a time. A piece is added to the formula above (the orange background marks the new piece), a shape is filled in or the dots on the number line move, and the reason appears below. The "Angle x" slider changes the angle at any step (0.01 to 1). When you reach the last step, x shrinks to 0.01 on its own. The green, blue, and purple dots on the number line come from the shape of the same color, and the orange band is the room sin x ÷ x has (from cos x to 1).

Written only as formulas, the steps above look like this, for 0 < x < π ÷ 2.

sinx2<x2<tanx2

1<xsinx<1cosx

cosx<sinxx<1

limx→0+cosx=1⟹limx→0+sinxx=1

sin(−x)−x=sinxx⟹limx→0sinxx=1

  1. Inner triangle: sin x ÷ 2. On a circle with radius 1, turn A = (1, 0) by the angle x and you get P = (cos x, sin x). The triangle OAP has base OA = 1 and height sin x, so its area is sin x ÷ 2. At x = 1 that is 0.420735.
  2. Sector: sin x ÷ 2 < x ÷ 2. The whole circle has area π and angle 2π. The sector OAP with angle x is the x ÷ (2π) share of it, so its area is x ÷ 2 (0.5 at x = 1). The triangle OAP fits inside the sector and is smaller by the thin sliver between the straight edge AP and the arc.
  3. Outer triangle: sin x ÷ 2 < x ÷ 2 < tan x ÷ 2. Draw the line up from A that just touches the circle (the tangent), and stretch OP until it meets that line at T. OP has slope sin x ÷ cos x = tan x, so T is at height tan x and the triangle OAT has area tan x ÷ 2 (0.778704 at x = 1). The sector fits inside this triangle. The order of the three areas comes straight from the picture.
  4. Divide by the inner triangle: 1 < x ÷ sin x < 1 ÷ cos x. Divide all three by sin x ÷ 2. For 0 < x < π ÷ 2, sin x is positive, so the order stays the same. tan x ÷ sin x = 1 ÷ cos x. At x = 1 you get 1, 1.188395, 1.850816. On the number line, the three dots move right, as if the line were stretched out from 0.
  5. Flip: cos x < sin x ÷ x < 1. All three are positive, so flipping each one (1 ÷ value) turns the order around (2 < 4, but 1 ÷ 2 > 1 ÷ 4). At x = 1: 0.540302 < 0.841471 < 1. sin x ÷ x is "the inner triangle as a share of the sector," and cos x is "the inner triangle as a share of the outer triangle." This is the inequality at the end of Example 2.
  6. Send x to 0: lim x→0 sin x ÷ x = 1. cos is continuous and cos 0 = 1, so as x → 0, cos x → 1. The right end is always 1. sin x ÷ x is trapped in between, so it has nowhere to go but 1. At x = 0.1: 0.995004 < 0.998334 < 1. At x = 0.01: 0.99995 < 0.999983 < 1. In the picture, the three shapes turn into thin slivers of the same shape. This rule, pinning the limit of the middle by pressing from both sides, is the squeeze theorem (not proved here). For x < 0, sin(−x) ÷ (−x) = sin x ÷ x gives the same values, so the left limit is 1 too.

Try this. ① As it starts (x = 1), the green triangle has area 0.420735. Press "Next" twice to get 0.420735 < 0.5 < 0.778704. ② At the third step, move the "Angle x" slider to 0.1. The three areas become 0.049917, 0.05, and 0.050167, almost the same. ③ Press "Next" to the end. x shrinks to 0.01, and you get cos x = 0.99995 and sin x ÷ x = 0.999983. The orange band almost disappears. Move the slider back to 1 and the band widens again, from 0.540302 to 1.

9. Going on forever: x → ∞

Instead of a number a, x can head off by growing without end. If f(x) settles on one value L as x grows through 1, 10, 100, 1000, …, you write lim x→∞ f(x) = L. On the graph, the curve hugs the line y = L more and more as you go to the right. That line is called a horizontal asymptote.

xf(x)Distance left to the limit

The scale across is logarithmic. Each step to the right makes x 10 times bigger, so x = 1 up to one million fits in one picture. The green curve is f(x), the blue dots are the values of x you picked with the slider, and the black dashed line is the horizontal asymptote.

The definition of e

You can read (1 + 1 ÷ n)ⁿ as interest. A bank pays 100% interest a year, but instead of paying it all at once, it splits the year into n parts and adds 1 ÷ n each time, and the interest already added also earns interest. With n = 1 you have 2 times your money after a year. With n = 12 (every month) you have about 2.613 times. A bigger n gives more, but not without end: it settles on one number. That number is e = 2.718281828….

e=limn→∞(1+1n)n

This is the same formula as (1 + 1 ÷ x)ˣ in the lab.

e is the base of eˣ, the function whose derivative is itself. In AI it shows up in the formulas for the sigmoid, softmax, and the normal distribution.

Try this. ① As it starts (1 ÷ x), x = 1, 10, 100 give 1, 0.1, 0.01. ② (2x + 1) ÷ (x + 3) gives 0.75 at x = 1, 1.615385 at 10, and 1.995015 at 1000, coming up to 2 from below. At x = 1000 the distance left is 0.004985. ③ (1 + 1 ÷ x)ˣ goes 2, 2.593742, 2.704814, 2.716924, … and reaches 2.71828 at x = one million. The distance left to e is 0.000001 (rounded to 6 decimal places).

10. Derivatives and integrals are limits too

Derivative. The slope at one spot on a curve is the limit of the slope of a line through two points, (f(x + h) − f(x)) ÷ h, as h goes to 0. If you just put in h = 0, you get the 0 ÷ 0 form. A limit is the tool that gets you past that 0 ÷ 0.

f′(x)=limh→0f(x+h)−f(x)h

Example: for f(x) = x² at x = 1, ((1 + h)² − 1) ÷ h = (2h + h²) ÷ h = 2 + h (h ≠ 0). As h → 0 you get 2. It is the same "cancel, then put it in" as Example 1. You can move it around on the derivatives page.

Wherever there is a derivative, the function is continuous. The other way around does not hold. |x| is continuous at x = 0, but it has a sharp corner there, so there is no derivative.

Integral. The area under a curve is estimated by adding up n thin rectangles, and then defined as the limit as n grows without end (as the width goes to 0). The more rectangles, the better the estimate, and the value it ends up at is the area. More on the integrals page.

11. A computer cannot go all the way to 0

A computer cannot follow h → 0 to the end. It picks one small number, works it out, and uses that as an estimate of the limit. The labs on this page do the same. To estimate a limit, they measure four points at 10⁻⁶, 10⁻⁷, 10⁻⁸, and 10⁻⁹ away from a, and check whether the values gather in one place, grow without end, or swing. But if you pick a number that is too small (or too big), you get a worse answer, not a better one. Computer decimals (floating-point numbers) only keep about 16 significant digits. Work out (1 + 1 ÷ x)ˣ and you get 2.71828 at x = 10⁶, close to e, but 2.71852 at x = 10¹², which is further away, then 3.035 at x = 10¹⁵, and 1 at x = 10¹⁶. That last one happens because the computer cannot tell 1 + 10⁻¹⁶ apart from 1, so it is raising 1 to a power. Derivatives have the same problem. Measure the slope of x² at x = 1 with h = 10⁻¹² and you get 2.00018, not 2. So numerical work picks a "small enough, not too small" number, and when it can, it rewrites the formula, as in Example 1, to avoid 0 ÷ 0.

12. Key properties

PropertyIn plain words
The limit does not care about the value on the spotYou leave out x = a. With no value there, or a different one, the limit is the same
If a limit exists, there is only oneYou cannot get closer and closer to two values at once
Limit = left limit = right limitThe limit exists only when both one-sided limits exist and are the same
The limit of a sum, product, or quotient is the sum, product, or quotient of the limitsFor a quotient, only when the limit of the bottom is not 0
Continuous = the limit equals the value on the spotWhere a function is continuous, you find the limit by putting the value in
Having a derivative means being continuousNot the other way around. |x| and ReLU are continuous but have no derivative at their corner

Where it is used

Common questions

What is a limit?

It is the value f(x) gets closer to as x gets closer and closer to some number a. You look at where the values are heading, not at the value at x = a itself. So a limit can exist even when there is no value at that spot.

What is the difference between the limit and the value of the function?

The value f(a) is what you get when you put x = a into the function. The limit is where the values near a are heading. (x² − 1) ÷ (x − 1) has no value at x = 1, but its limit there is 2. When the two are the same, the function is continuous at that spot.

What is 0 ÷ 0?

It has no set value. When a limit turns into the 0 ÷ 0 form, it means "you cannot tell yet." Depending on how fast the top and the bottom shrink to 0, the answer can be 1, or 0, or there may be no limit at all. You cancel the part that makes the 0, or you walk in with a table.

When is there no limit?

In three cases: when the left limit and the right limit are different (a staircase), when the values grow without end (1 ÷ x as x goes to 0), and when the values keep swinging and never settle on one number (sin(1 ÷ x) as x goes to 0).

Can a function be continuous but have no derivative?

Yes. |x| and ReLU are continuous at x = 0, but they have a sharp corner there, so the slope from the left and the slope from the right are different. That means there is no derivative at that spot. The other way around always holds: wherever there is a derivative, the function is continuous.

Words

Word used hereTextbook term
The value it is heading forLimit. lim x→a f(x)
The value on the spotFunction value. f(a)
The value from the left / from the rightLeft-hand limit / right-hand limit. lim x→a⁻, lim x→a⁺
A limit looking at only one roadOne-sided limit
Settles on one valueConverges (convergence)
Does not settle, grows without endDiverges (divergence)
Pinning it down with an allowed height ε and a width δEpsilon-delta definition
You can draw it without lifting your pencilContinuous
A breakDiscontinuity
Hole / jump / blow-upRemovable / jump / infinite discontinuity
The 0 ÷ 0 formIndeterminate form
The staircase ⌊x⌋Floor function, greatest integer function
The line across that the curve hugs far outHorizontal asymptote
A scale where each step is 10 times biggerLogarithmic scale
Pinning the middle between two sidesSqueeze theorem
A circle with radius 1Unit circle
A line that touches the circle at just one pointTangent line
Computer decimalsFloating-point numbers

Sources

← Functions and graphsDerivatives and the chain rule →