Ma · Mathematics

How to Find the Inverse of a Sigmoid Equation

Updated 13 October 2026

At a glance

  1. 1. Name the sigmoid

    For the standard logistic sigmoid, write y = 1 / (1 + e^(-x)).

  2. 2. Isolate the exponential

    Rearrange to get e^(-x) = (1 - y) / y.

  3. 3. Take logarithms

    Apply the natural logarithm and solve for x.

  4. 4. Check the range

    A finite inverse exists only when the output y is strictly between 0 and 1.

The word “sigmoid” can describe several S-shaped functions, but it most often means the standard logistic function

σ(x)=11+e−x.\sigma(x)=\frac{1}{1+e^{-x}}.

To find its inverse, solve for the input xx in terms of the output yy. The result is the logit function. The steps below also show how to invert a shifted or rescaled logistic sigmoid.

Derive the inverse of the standard sigmoid

Set the sigmoid equal to yy and rearrange:

y=11+e−x1+e−x=1ye−x=1−yy.\begin{aligned} y &= \frac{1}{1+e^{-x}} \\ 1+e^{-x} &= \frac{1}{y} \\ e^{-x} &= \frac{1-y}{y}. \end{aligned}

Take the natural logarithm of both sides. Since ln⁡(e−x)=−x\ln(e^{-x})=-x, solving for xx gives

x=ln⁡(y1−y).\boxed{x=\ln\left(\frac{y}{1-y}\right)}.

Thus the inverse function is

σ−1(y)=logit⁡(y)=ln⁡(y1−y).\sigma^{-1}(y)=\operatorname{logit}(y)=\ln\left(\frac{y}{1-y}\right).

The expression y/(1−y)y/(1-y) is the odds associated with probability yy; the logit is the logarithm of those odds.

Check the domain

The standard sigmoid takes every real input to a value strictly between 0 and 1. Therefore its inverse accepts only 0<y<10<y<1 and returns a real number. The endpoints are approached but never reached for finite xx:

lim⁡x→−∞σ(x)=0,lim⁡x→∞σ(x)=1.\lim_{x\to-\infty}\sigma(x)=0, \qquad \lim_{x\to\infty}\sigma(x)=1.

So y=0y=0 and y=1y=1 do not have finite inverse values. In the extended limiting sense, their corresponding inputs tend to −∞-\infty and +∞+\infty respectively. Values outside [0,1][0,1] cannot be outputs of this sigmoid.

Worked example

Find the input whose sigmoid output is 0.80.8. Substitute y=0.8y=0.8 into the inverse:

x=ln⁡(0.81−0.8)=ln⁡(0.80.2)=ln⁡(4)≈1.3863.\begin{aligned} x &= \ln\left(\frac{0.8}{1-0.8}\right) \\ &= \ln\left(\frac{0.8}{0.2}\right) \\ &= \ln(4) \\ &\approx 1.3863. \end{aligned}

Check by putting this value back into the original sigmoid:

σ(1.3863)≈11+e−1.3863≈0.8.\sigma(1.3863)\approx\frac{1}{1+e^{-1.3863}}\approx 0.8.

The positive input makes sense: the standard sigmoid is above 0.50.5 when x>0x>0, and 0.80.8 is above 0.50.5.

Invert a shifted or scaled sigmoid

A common generalized form is

y=L1+e−k(x−x0),y=\frac{L}{1+e^{-k(x-x_0)}},

where LL sets the upper output limit, x0x_0 is the midpoint, and kk controls the steepness and direction. For L>0L>0 and k≠0k\ne 0, its output must satisfy 0<y<L0<y<L. Rearranging gives

Ly−1=e−k(x−x0),L−yy=e−k(x−x0),x=x0+1kln⁡(yL−y).\begin{aligned} \frac{L}{y}-1 &= e^{-k(x-x_0)}, \\ \frac{L-y}{y} &= e^{-k(x-x_0)}, \\ x &= x_0+\frac{1}{k}\ln\left(\frac{y}{L-y}\right). \end{aligned}

For example, suppose y=6/(1+e−2(x−3))y=6/(1+e^{-2(x-3)}) and you want the input that gives y=4y=4. Here L=6L=6, k=2k=2, and x0=3x_0=3:

x=3+12ln⁡(46−4)=3+12ln⁡(2)≈3.347.x=3+\frac{1}{2}\ln\left(\frac{4}{6-4}\right)=3+\frac{1}{2}\ln(2)\approx 3.347.

If the sigmoid is applied to a linear expression, such as y=σ(ax+b)y=\sigma(ax+b), first use the standard inverse to obtain ax+b=ln⁡(y/(1−y))ax+b=\ln(y/(1-y)). If a≠0a\ne0, then

x=ln⁡(y/(1−y))−ba.x=\frac{\ln(y/(1-y))-b}{a}.

Common mistakes

  • Reversing the odds: The numerator in the logit is yy, and the denominator is 1−y1-y. Reversing them changes the sign of the answer.
  • Using the formula at an endpoint: The logarithm is not finite at y=0y=0 or y=1y=1. Do not substitute either endpoint into the formula as though it returned a real number.
  • Ignoring the sigmoid’s parameters: For a scaled sigmoid, use y/Ly/L or the generalized formula; the unscaled logit alone will give the wrong input.
  • Assuming every sigmoid has a logit inverse: Some functions called sigmoid functions, such as the normal cumulative distribution function, have different inverse functions. The formula here applies to the logistic sigmoid and its stated variants.

For values extremely close to 0 or 1, the logit can have a very large magnitude. In numerical work, check that the output is valid and account for rounding before evaluating the logarithm.

References

  1. SciPy documentation: scipy.special.logit

Spotted an error? Send a correction. Read how we write and check articles in our editorial policy.