Sigmoid Function Calculator
Compute the logistic sigmoid σ(x) = 1/(1+e⁻ˣ), its derivative σ′(x), or its inverse logit — for one value or a whole list. Numerically stable, plotted as an S-curve, with a step-by-step derivation, and verified against PyTorch. No signup, runs in your browser.
How it works
The sigmoid — also called the logistic function or expit — squashes any real number into the open interval (0, 1). It is the activation behind logistic regression and the binary-classification head of a neural network: a model produces a raw score (a logit), and the sigmoid turns it into a probability. This calculator implements the standard definition from Goodfellow, Bengio & Courville's Deep Learning(MIT Press, 2016) and reproduces the behaviour of PyTorch's torch.sigmoid.
For an input x and an optional scale a (so z = a·x), the three modes are:
- Sigmoid.
σ(z) = 1 / (1 + e⁻ᶻ). To stop the exponential from overflowing on extreme inputs, the tool uses the algebraically identical sign-aware branch — 1/(1+e⁻ᶻ) when z ≥ 0 and eᶻ/(1+eᶻ) when z < 0 — the same trick asscipy.special.expit. The exponent stays ≤ 0, so nothing overflows and the result is never NaN. - Derivative.
σ′(z) = σ(z)·(1 − σ(z)). Computed from the already-stable σ(z). It reaches its maximum of 0.25 at z = 0 and approaches 0 as the sigmoid saturates — the gradient used in back-propagation (Deep Learning §6.2.2). - Inverse (logit).
logit(p) = ln(p / (1 − p))for a probability p in (0, 1). It maps a probability back to the raw score that produces it. The domain is enforced — p at exactly 0 or 1 is rejected, since the logit there is ∓∞.
To prove correctness the module computes σ(z) twice by independent formulas — the stable branch above and the tanh identity σ(z) = ½(1 + tanh(z/2)) — and reports the largest gap between them, which reads as 0 (or ~1e-16) for every input. All arithmetic is double-precision JavaScript Math.exp / Math.log; results are rounded only for display, never for chained computation, and nothing is sent to a server.
Worked examples
Frequently asked questions
Sources & references
- PyTorch documentation — torch.nn.Sigmoid / torch.sigmoid (σ(x) = 1/(1+exp(−x)))
- SciPy documentation — scipy.special.expit (logistic sigmoid) and logit (its inverse)
- Goodfellow, Bengio & Courville — Deep Learning (MIT Press, 2016), §3.10 & §6.2.2
The formulas on this page were last cross-checked against these sources and PyTorch on 2026-06-10. The sigmoid is a stable mathematical definition, so this tool needs no rate or schedule updates — only the worked examples are periodically re-reconciled.
Related tools
Comments & feedback
Spotted a bug or want an improvement? Tell us — our team reviews every comment, and good ideas get built. Comments are public and anonymous.
Found a bug, edge case, or want to suggest an improvement?
Email me at [email protected] — most fixes ship within 24 hours.