induwara.lk
induwara.lkAI · Machine learning

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.

By Induwara AshinsanaUpdated Jun 10, 2026
Sigmoid calculator

Separate values with commas, spaces, or new lines. Negatives and decimals are fine. Up to 200 values.

Steepness multiplier. a = 1 is the standard sigmoid; larger a makes the curve steeper. Zero or blank falls back to 1.

Examples
Values
5
results computed
Min result
0.119203
σ(x) always lands in (0, 1)
Max result
0.880797
σ(0) = 0.5 is the midpoint
Cross-check gap
1.1e-16
stable σ vs tanh identity

Sigmoid S-curve

00.501-606x

Amber dots mark your 5 inputs; points beyond the visible range sit on the nearest edge.

Per-value results

xz = a·xσ(z)Probability
-2.0000-2.00000.119203
11.9%
-1.0000-1.00000.268941
26.9%
0.00000.00000.500000
50.0%
1.00001.00000.731059
73.1%
2.00002.00000.880797
88.1%

Step-by-step (first value)

  1. 1. Scale: z = a·x = 1.0000 × -2.0000 = -2.000000
  2. 2. e⁻ᶻ = e^(−-2.000000) = 7.389056
  3. 3. σ(z) = 1 / (1 + 7.389056) = 0.119203
Copy

Method: numerically-stable logistic sigmoid σ(z) = 1/(1+e⁻ᶻ), derivative σ′(z) = σ(z)(1−σ(z)), and inverse logit(p) = ln(p/(1−p)) — Goodfellow, Bengio & Courville, Deep Learning(2016) §3.10 & §6.2.2; reference behaviour per PyTorch torch.sigmoid and SciPy expit. Everything runs in your browser — no data leaves this page.

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:

  1. 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 as scipy.special.expit. The exponent stays ≤ 0, so nothing overflows and the result is never NaN.
  2. 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).
  3. 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

Sigmoid and its gradient — x = 0 and x = 2 (a = 1)

  1. σ(0) = 1/(1+e⁰) = 1/(1+1) = 0.500000
  2. σ′(0) = 0.5·(1−0.5) = 0.250000 (the maximum of σ′)
  3. e⁻² = 0.135335 → σ(2) = 1/1.135335 = 0.880797
  4. σ′(2) = 0.880797·0.119203 = 0.104994
  5. tanh cross-check: ½(1+tanh 1) = ½(1+0.761594) = 0.880797 ✓

Inverse (logit) with round-trip — p = 0.8

  1. Odds: p/(1−p) = 0.8/0.2 = 4
  2. logit(0.8) = ln(4) = 1.386294
  3. Round-trip: σ(1.386294) = 1/(1+e⁻¹·³⁸⁶²⁹⁴)
  4. = 1/(1+0.25) = 1/1.25 = 0.800000 ✓
  5. The logit recovers the score; the sigmoid returns the probability.

Saturation / stability edge case — x = ±1000

  1. σ(1000): z ≥ 0 branch → e⁻¹⁰⁰⁰ ≈ 0 → 1/(1+0) = 1.000000
  2. σ(−1000): z < 0 branch → e⁻¹⁰⁰⁰ ≈ 0 → 0/(1+0) = 0.000000
  3. Naive eᶻ/(1+eᶻ) at z=1000 would give Infinity/Infinity = NaN
  4. The sign-aware branch keeps the exponent ≤ 0, so neither overflows
  5. This matches scipy.special.expit and torch.sigmoid exactly.

Frequently asked questions

Sources & references

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

Rate this tool
Be the first to rate

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.