Approach a point from one side only: a limit exists exactly when the left and right limits agree, which fails at a step. Let the output or the input run off to infinity, meet vertical and horizontal asymptotes, and watch the sigmoid level off at 0 and 1.
Find left-hand and right-hand limits, and decide whether a limit exists by comparing them.
Describe infinite limits and vertical asymptotes, using 1/x and 1/x^2 near 0.
Find limits at infinity of rational functions by dividing through by the highest power of x.
Show that the sigmoid tends to 1 and to 0 as its input runs off each way, and explain why its flat ends slow learning.
Prove a limit at infinity by finding, for each tolerance, a point beyond which the function stays in the band.
In review. The maths and code on this page are checked by automated tests on every change, but an independent reader has not signed it off yet. Spot a mistake or a confusing step? Tell us.
The question
Logistic regression turns a score \(z\) into a probability with the sigmoid, \({\sigma(z) = 1/(1 + e^{-z})}\). A score of 10 gives 0.99995 and a score of 20 gives 0.999999998. Does the probability ever reach 1? And the step function, which a perceptron uses to turn a score into a plain yes or no, jumps from 0 to 1 at \({z = 0}\). What is its limit there?
From the last lesson
1. What is \({\lim_{x \to 0} \sin(x)/x}\), and in which units?
Show answer
1, with \(x\) in radians.
2. Substituting the point gives \({0/0}\). What does that tell you?
Show answer
Only that substitution has failed. Factor and cancel, rationalise, or squeeze to find the limit.
Intuition
So far \(x\) has approached \(a\) from both sides at once. Watch each side on its own.
M04.1.3-F1
Left: at the step, inputs just left of 0 give 0 and inputs just right of 0 give 1. The two sides head to different values, so there is no limit at 0. Right: at the hole of \({(x^2 - 1)/(x - 1)}\), both sides head to 2, and 2 is the limit.
A limit is one number that the outputs approach from both sides. When the two sides head to different numbers, as at a step, each side still has a limit of its own, called a one-sided limit, but the function has no limit there. The two other new ideas of this lesson let something run off to infinity: the output, near a point where a fraction’s bottom tends to 0, or the input, as \(x\) grows without end. The sigmoid needs the second.
Build it up
Step 1. One side at a time. Write \({x \to a^-}\) for “\(x\) tends to \(a\) from the left”, with \({x < a}\), and \({x \to a^+}\) for “from the right”, with \({x > a}\). For the step function \(H\), which is 0 for \({x < 0}\) and 1 for \({x \geq 0}\):
Step 2. Outputs that run off. Near 0, \({1/x}\) is huge: at \({x = 0.1, 0.01, 0.001}\) it is 10, 100 and 1000, and at the same distances left of 0 it is \({-10}\), \({-100}\) and \({-1000}\). No band round any number can hold it. We write \({\lim_{x \to 0^+} 1/x = +\infty}\): the outputs pass any bound, however large. \(\infty\) is not a number here; the sign says only “grows without bound”. The line \({x = 0}\), which the graph hugs, is a vertical asymptote.
Step 3. Inputs that run off. Let \(x\) grow instead. At \({x = 10, 100, 1000}\), \({1/x}\) is 0.1, 0.01 and 0.001: it heads to 0, and we write \({\lim_{x \to \infty} 1/x = 0}\). The line \({y = 0}\), which the graph hugs far out, is a horizontal asymptote.
M04.1.3-F2
\({1/x}\) near its two asymptotes. Close to 0 the output runs off, up on the right and down on the left; far out it settles on 0 in both directions.
Step 4. Divide by the highest power. For a rational function far out, the highest powers win. Dividing top and bottom by \(x\) makes this visible, because every other term becomes a number over a power of \(x\), which tends to 0:
Step 5. The sigmoid. As \(z\) grows, \({e^{-z} = 1/e^{z}}\) shrinks towards 0, so \({\sigma(z) = 1/(1 + e^{-z})}\) tends to \({1/(1 + 0) = 1}\). As \(z\) runs off to \({-\infty}\), \({e^{-z}}\) grows without bound and \(\sigma\) tends to 0. Both lines, \({y = 0}\) and \({y = 1}\), are horizontal asymptotes, and \(\sigma\) never touches either: \({e^{-z}}\) is always positive, so \({1 + e^{-z}}\) is more than 1 and \({\sigma(z)}\) lies strictly between 0 and 1.
M04.1.3-F3
The sigmoid levels off at 0 and at 1. Over the same run of 2 it rises 0.46 in the middle but only 0.016 between \({z = 4}\) and 6: far out, the graph is almost flat.
Those flat ends matter for learning. Training adjusts a score by following how much the output changes when the score changes. Out on a flat end, a change in \(z\) barely changes \({\sigma(z)}\), so that guide almost vanishes. A unit whose score sits there is called saturated; DL01.3 returns to this when it compares activation functions, and the next module turns “how much the output changes” into the derivative.
The formal statement
NoteDefinitions: one-sided, infinite, and at infinity
One-sided.\({\lim_{x \to a^+} f(x) = \ell}\) if for every \({\varepsilon > 0}\) there is a \({\delta > 0}\) with \({\abs{f(x) - \ell} < \varepsilon}\) whenever \({a < x < a + \delta}\). From the left, the window is \({a - \delta < x < a}\).
Infinite.\({\lim_{x \to a^+} f(x) = +\infty}\) if for every \({M > 0}\) there is a \({\delta > 0}\) with \({f(x) > M}\) whenever \({a < x < a + \delta}\); similarly for \({-\infty}\) (with \({f(x) < -M}\)) and for the left side. Then the line \({x = a}\) is a vertical asymptote.
At infinity.\({\lim_{x \to \infty} f(x) = \ell}\) if for every \({\varepsilon > 0}\) there is a number \(N\) with \({\abs{f(x) - \ell} < \varepsilon}\) whenever \({x > N}\); for \({x \to -\infty}\), use \({x < N}\). Then the line \({y = \ell}\) is a horizontal asymptote.
Each is the tolerance game with one move changed: the window has one side only, or the band becomes “above \(M\)”, or the window becomes “beyond \(N\)”.
Theorem.\({\lim_{x \to a} f(x) = \ell}\) exactly when both one-sided limits exist and equal \(\ell\).
Why. If the two-sided limit is \(\ell\), its window \({0 < \abs{x - a} < \delta}\) contains both half-windows, so each one-sided limit is \(\ell\). Conversely, given \(\varepsilon\), take a left window \(\delta_1\) and a right window \(\delta_2\), and let \(\delta\) be the smaller. Every \(x\) with \({0 < \abs{x - a} < \delta}\) lies in one of the two half-windows, so \({\abs{f(x) - \ell} < \varepsilon}\).
The two facts about \({1/x}\), proved. Given \({M > 0}\), take \({\delta = 1/M}\): if \({0 < x < 1/M}\), then \({1/x > M}\). So \({1/x \to +\infty}\) as \({x \to 0^+}\). Given \({\varepsilon > 0}\), take \({N = 1/\varepsilon}\): if \({x > N}\), then \({0 < 1/x < \varepsilon}\). So \({1/x \to 0}\) as \({x \to \infty}\).
The sigmoid, proved. The limit laws of M04.1.2 hold for \({x \to \infty}\) too, with \(N\) in place of \(\delta\) in the proofs. Given \({0 < \varepsilon < 1}\), take \({N = \ln(1/\varepsilon)}\). For \({z > N}\), since \({e^{-z}}\) falls as \(z\) grows (M01.4),
\[
0 < e^{-z} < e^{-N} = \varepsilon ,
\]
so \({e^{-z} \to 0}\), and by the sum and quotient laws \({\sigma(z) \to 1/(1 + 0) = 1}\). For \({z \to -\infty}\), multiply top and bottom by \({e^{z}}\): \({\sigma(z) = e^{z}/(e^{z} + 1)}\), and \({e^{z} \to 0}\), so \({\sigma(z) \to 0/(0 + 1) = 0}\).
Rational functions at infinity. Divide top and bottom by the highest power of \(x\) in the bottom. If the top and bottom have the same degree, the limit is the ratio of their leading coefficients. If the top has the lower degree, the limit is 0. If it has the higher degree, there is no finite limit.
Go deeper: the number e as a limit at infinity
M01.4.2 met \(e\) as the number that \({(1 + 1/n)^n}\) settles towards. That is a limit at infinity, taken over whole numbers \(n\): \({e = \lim_{n \to \infty} (1 + 1/n)^n}\). Why does it settle at all? By the binomial theorem (M01.8.4), the \(k\)-th term of the expansion is \({\binom{n}{k} / n^k}\). The top of \({\binom{n}{k}}\) is \({n(n - 1) \cdots (n - k + 1)}\), with \(k\) factors, over \({k!}\). Dividing each of those factors by one of the \(k\) copies of \(n\) gives
Each bracket grows with \(n\), and a larger \(n\) adds more terms, so \({(1 + 1/n)^n}\) grows with \(n\). Each term is at most \({1/k!}\), which is at most \({1/2^{k-1}}\), so the total stays below \({1 + (1 + \tfrac12 + \tfrac14 + \cdots) = 3}\) (M01.7.3). An increasing sequence that never passes a ceiling must settle on a limit. That last step is a basic property of the real numbers, called completeness, which is taken as an axiom. The limit is \({e \approx 2.718282}\).
Worked example
Find every asymptote of \({r(x) = (2x + 1)/(x - 1)}\), and how the graph approaches each.
Far out. Step 4 gave \({r(x) \to 2}\) as \({x \to \infty}\), and the same division works as \({x \to -\infty}\). So \({y = 2}\) is a horizontal asymptote. To see from which side the graph approaches, write \(r\) as 2 plus a remainder:
For \({x > 1}\) the remainder is positive, so the graph is above 2; for \({x < 1}\) it is below. A table agrees: \({r(10) \approx 2.3333}\), \({r(100) \approx 2.0303}\), \({r(1000) \approx 2.0030}\), and \({r(-10) \approx 1.7273}\). The same form gives the window of the game: \({\abs{r(x) - 2} < \varepsilon}\) whenever \({x > 1 + 3/\varepsilon}\).
Near 1. The bottom tends to 0 and the top tends to 3. From the right, \({x - 1}\) is a small positive number, so \({r(x)}\) is large and positive: \({r(1.1) = 32}\) and \({r(1.01) = 302}\). From the left, \({x - 1}\) is small and negative: \({r(0.9) = -28}\) and \({r(0.99) = -298}\). So
and \({x = 1}\) is a vertical asymptote. There is no two-sided limit at 1, not even an infinite one.
M04.1.3-F4
Values of \({r(x)}\) computed far out close in on 2, from above on the right and from below on the left. Values near \({x = 1}\) run off: up on the right of the vertical asymptote, down on the left.
Code
One-sided values and limits at infinity, in plain Python.
import mathdef step(x):return0if x <0else1def r(x):return (2* x +1) / (x -1)for h in (0.1, 0.01, 0.001):print(f"h = {h:<6} step(-h) = {step(-h)} step(h) = {step(h)} 1/(-h) = {1/-h:7.0f} 1/h = {1/ h:6.0f}")for x in (10, 100, 1000, -10, -100):print(f"r({x}) = {r(x):.4f}")
Now the sigmoid: its values far out, and the rise over a run of 2, which shrinks as \(z\) grows.
def sigmoid(z):return1/ (1+ math.exp(-z))for z in (0, 2, 4, 6, 10, 20):print(f"sigmoid({z:>2}) = {sigmoid(z):.10f} rise from z to z + 2: {sigmoid(z +2) - sigmoid(z):.6f}")print("sigmoid(37) == 1.0 in floating point:", sigmoid(37) ==1.0)
sigmoid( 0) = 0.5000000000 rise from z to z + 2: 0.380797
sigmoid( 2) = 0.8807970780 rise from z to z + 2: 0.101217
sigmoid( 4) = 0.9820137900 rise from z to z + 2: 0.015514
sigmoid( 6) = 0.9975273768 rise from z to z + 2: 0.002137
sigmoid(10) = 0.9999546021 rise from z to z + 2: 0.000039
sigmoid(20) = 0.9999999979 rise from z to z + 2: 0.000000
sigmoid(37) == 1.0 in floating point: True
In exact arithmetic \({\sigma(37)}\) is less than 1, but \({e^{-37} \approx 8.5 \times 10^{-17}}\) is too small to change \({1 + e^{-37}}\) in a computer’s floating-point numbers, so the result rounds to exactly 1.0. The other end fails louder: for \({z = -1000}\) the formula asks for \({e^{1000}}\), which is too large. Writing \({\sigma(z) = e^{z}/(1 + e^{z})}\) for negative \(z\), the form used in the proof, avoids that, and SciPy’s expit does the same job on whole arrays.
import numpy as npfrom scipy.special import expitdef stable_sigmoid(z):"""The sigmoid, written so that exp never sees a large positive number."""if z >=0:return1/ (1+ math.exp(-z))return math.exp(z) / (1+ math.exp(z))try: sigmoid(-1000)exceptOverflowError:print("sigmoid(-1000): math.exp(1000) is too large to compute")zs = np.array([-1000.0, -20.0, 0.0, 20.0, 37.0])print("stable:", [stable_sigmoid(z) for z in zs])print("expit: ", expit(zs))
sigmoid(-1000): math.exp(1000) is too large to compute
stable: [0.0, 2.0611536181902033e-09, 0.5, 0.9999999979388463, 1.0]
expit: [0.00000000e+00 2.06115362e-09 5.00000000e-01 9.99999998e-01
1.00000000e+00]
Explore
This module’s interactive, the limit window, lives in lesson M04.1.1. Choose the jump: it is a step, with the left side at 1 and the right side at 3. Each side on its own has a limit, but no single band narrower than the jump can hold both, which is the theorem of this lesson in a picture.
Pitfalls
M04.1.3-F5
Wrong beside right. Left:\({1/x}\) runs to \({+\infty}\) on the right of 0 but to \({-\infty}\) on the left, so it has no limit at 0, not even an infinite one. Right:\({1/x^2}\) runs to \({+\infty}\) on both sides, so \({\lim_{x \to 0} 1/x^2 = +\infty}\).
“\({\lim_{x \to 0} 1/x = \infty}\).”
Only the one-sided limits exist: \({+\infty}\) from the right and \({-\infty}\) from the left. The sides disagree, so \({1/x}\) has no limit at 0. Compare \({1/x^2}\), which runs off upwards on both sides.
“\(\infty\) is a number, so \({\infty - \infty = 0}\) and \({\infty / \infty = 1}\).”
“Tends to \(\infty\)” only says “grows without bound”, and such forms are indeterminate, like \({0/0}\). \({(2x + 1)/(x - 1)}\) is a ratio of two quantities that both run off, yet it tends to 2, not 1; and \({x^2 - x}\) is a difference of two quantities that both run off, yet it tends to \({+\infty}\), not 0.
“A graph can never cross its horizontal asymptote.”
A horizontal asymptote describes the far ends only. \({x/(x^2 + 1)}\) tends to 0 at both ends and crosses its asymptote \({y = 0}\) at \({x = 0}\). A vertical asymptote is different: beside it the graph runs off to infinity on at least one side, so it cannot pass across that line without a break.
“For a large enough score the sigmoid equals 1.”
Never in exact arithmetic: \({e^{-z} > 0}\), so \({\sigma(z) < 1}\) for every \(z\). In floating point \({\sigma(37)}\) rounds to 1.0, and then \({\ln(1 - \sigma(z))}\) becomes \({\ln 0}\). ML01.6.2 shows the cost, an infinite log loss, and why the loss is computed from the score instead.
Check yourself
Recall
1. When does \({\lim_{x \to a} f(x)}\) exist, in terms of one-sided limits?
Show answer
Exactly when the left-hand and right-hand limits both exist and are equal. The limit is then their common value.
2. What are the one-sided limits of the step function at 0?
Show answer
0 from the left and 1 from the right. They differ, so the step has no limit at 0.
3. What does \({\lim_{x \to a^+} f(x) = +\infty}\) mean in words, and what is the line \({x = a}\) called?
Show answer
As \(x\) comes down to \(a\) from the right, \({f(x)}\) grows past every bound. The line \({x = a}\) is a vertical asymptote.
3: the top and bottom have the same degree, and the ratio of their leading coefficients is 3.
5. What are the limits of \({\sigma(z)}\) as \({z \to \infty}\) and as \({z \to -\infty}\)?
Show answer
1 and 0. The lines \({y = 1}\) and \({y = 0}\) are horizontal asymptotes, and \(\sigma\) never reaches either.
Exercises
1.★ Let \({f(x) = x + 1}\) for \({x < 2}\) and \({f(x) = x^2 - 1}\) for \({x \geq 2}\). Find both one-sided limits at 2. Does \({\lim_{x \to 2} f(x)}\) exist? Answer again with \({x^2}\) in place of \({x^2 - 1}\).
Show solution
From the left, \(f\) is \({x + 1}\), a polynomial, so the left-hand limit is \({2 + 1 = 3}\). From the right, \(f\) is \({x^2 - 1}\), so the right-hand limit is \({4 - 1 = 3}\). They agree, so the limit exists and is 3. With \({x^2}\) instead, the right-hand limit is 4, which differs from 3: a jump, and no limit at 2.
2.★★ Find the asymptotes of \({g(x) = (3x^2 - x)/(x^2 - 4)}\), and the one-sided limits at \({x = 2}\).
Show solution
Horizontal. Top and bottom have degree 2, so dividing by \({x^2}\) gives
\[
\frac{3 - 1/x}{1 - 4/x^2} \to 3 ,
\]
and \({y = 3}\) is a horizontal asymptote at both ends.
Vertical. The bottom \({x^2 - 4 = (x - 2)(x + 2)}\) is 0 at \({x = \pm 2}\), and the top is not (it is 10 at 2 and 14 at \({-2}\)), so nothing cancels and both are vertical asymptotes. At 2 the top tends to 10 and the factor \({x + 2}\) to 4. From the right, \({x - 2}\) is small and positive, so \({g(x) \to +\infty}\); from the left it is small and negative, so \({g(x) \to -\infty}\). For example, \({g(2.01) \approx 252.1}\) and \({g(1.99) \approx -247.9}\).
3.★★★ Show that \({0 < 1 - \sigma(z) < e^{-z}}\) for every \(z\). Use it to find a score \(N\) beyond which \({\sigma(z)}\) is within \({\varepsilon = 0.001}\) of 1, and so prove \({\lim_{z \to \infty} \sigma(z) = 1}\) again.
The top is positive, so \({1 - \sigma(z) > 0}\). The bottom is more than 1, so the fraction is less than its top, \({e^{-z}}\). Now \({e^{-z} < \varepsilon}\) exactly when \({z > \ln(1/\varepsilon)}\), so \({N = \ln(1/\varepsilon)}\) works for every \({\varepsilon > 0}\). For \({\varepsilon = 0.001}\) that is \({N = \ln 1000 \approx 6.9078}\): every score above about 6.91 gives a probability within 0.001 of 1.
Summary card
A limit needs both sides to agree; either end of it may run off to infinity.
M04.1.3-F1
Sides disagree, no limit; sides agree, the limit.
Two-sided from one-sided.\({\lim_{x \to a} f(x) = \ell}\) exactly when both one-sided limits equal \(\ell\).
Vertical asymptote.\({f(x) \to \pm\infty}\) as \({x \to a}\) from one side, as \({1/x}\) at 0.
Horizontal asymptote.\({f(x) \to \ell}\) as \({x \to \pm\infty}\); for a rational function, divide by the highest power.
The sigmoid tends to 1 and to 0 and never reaches either; its flat ends are saturated.
Sources and next steps
Sources. Each was opened and checked against this lesson on 12 November 2026.
Gilbert Strang and Edwin Herman, Calculus Volume 1 (OpenStax), Section 2.2, The limit of a function: one-sided limits, Theorem 2.2 (a limit exists exactly when both one-sided limits exist and are equal), infinite limits and vertical asymptotes, and Theorem 2.3 on \({1/(x - a)^n}\), which tends to \({+\infty}\) on both sides for even \(n\), and for odd \(n\) to \({+\infty}\) on the right and \({-\infty}\) on the left. Section 4.6, Limits at infinity and asymptotes: limits at infinity with \(N\), horizontal asymptotes, rational functions handled by dividing by the highest power of \(x\) in the bottom, and the remarks that a graph may cross a horizontal asymptote but not a vertical one, beside which it runs off to infinity.
Ian Goodfellow, Yoshua Bengio and Aaron Courville, Deep Learning, MIT Press, 2016, Section 6.3.2: sigmoid units saturate to a high value when \(z\) is very positive and to a low value when it is very negative, and widespread saturation can make gradient-based learning very difficult.
Stanford CS231n, Neural Networks Part 1, “Commonly used activation functions”: sigmoids saturate and kill gradients, since at either tail the gradient is almost zero.