Logistic Function and Its Derivative Explained with Worked Examples

The logistic function maps any real to a probability between 0 and 1. Its derivative is , and its inverse is the logit .

Write 2x or 2*x to multiply, ^ for powers, and ; between simultaneous equations. You can also type factor, expand, derivative of, integrate … from a to b, limit … as x->0 or 15% of 80.

Try an example

Before you start

What Logistic function and its derivative means

The curve is S-shaped, passing through at . By the chain rule, . The slope is greatest (0.25) at and tends to 0 for large . For : and slope . The exponential is described in the derivative of e to the power kx.

Solving for gives the logit: corresponds to , the log of the odds. Logistic regression models the log-odds as a linear function of predictors and fits it by maximum likelihood; the formula makes the derivatives simple. The logistic equation also models growth that levels off, see exponential growth and decay and growth models.

For several classes the logistic function generalises to the softmax function. The shape resembles the hyperbolic tangent: . Probabilities from it add to 1 in the binary case, see the sum of probabilities.

What is it used for?

The logistic function squashes any number into a probability and has a very simple derivative.

How to use logistic function and its derivative

  1. Compute and then .
  2. For the derivative, compute .
  3. For the inverse, use .
  4. Check that lies strictly between 0 and 1.

Graph

The logistic function and its derivative p(1 − p)p = 0.5 at η = 0-6-4-2024600.20.40.60.81The logistic function and its derivative p(1 − p)ηvaluep = 1/(1 + e^(−η))slope p(1 − p)Graph with x from -6 to 6 and y from 0 to 1.05. Shows the curve p = 1/(1 + e^(−η)); the curve slope p(1 − p); point p = 0.5 at η = 0 at (0, 0.5).

The slope peaks at 0.25 where p = 0.5 and fades away in both directions.

Worked examples

These examples are worked by hand, step by step, so you can compare your own working.

Example 1: at zero

Find and at .

Worked example
Answer
p=0.5, slope 0.25p=0.5,\ \text{slope }0.25
  1. p
  2. Slope

Example 2: at η = 2

Find and the slope at .

Worked example
Answer
p=0.8808, slope 0.1050p=0.8808,\ \text{slope }0.1050
  1. p
  2. Slope

Example 3: the logit

Find when .

Worked example
Answer
2.19722.1972
  1. Formula

Special cases

A few situations come up again and again. Knowing them saves time and helps you spot answers that cannot be right.

η = 0

p

0.5.

η = 2

p

0.8808.

p = 0.8808

p(1 − p)

0.1050.

p = 0.8

logit ln(p/(1−p))

1.3863.

Word problems

p = 1/(1 + e^(−η)), dp/dη = p(1 − p) and the inverse is the logit η = ln(p/(1 − p)).

η = 0

e⁰ = 1.

  1. 1/2
  2. Check: ✓0.5

η = 2

e⁻² = 0.1353.

  1. 1/1.1353
  2. Check: ✓0.8808

Derivative Higher

p(1 − p).

  1. 0.8808 × 0.1192
  2. Check: ✓0.105

Logit Higher

p = 0.8.

  1. ln 4
  2. Check: ✓1.3863

Common mistakes

Derivative p

p ✗

p(1 − p) ✓

Chain rule.

p can exceed 1

unbounded ✗

between 0 and 1 ✓

Probability.

Logit = ln p

wrong ✗

ln(p/(1 − p)) ✓

Odds.

Maximum slope at η large

large η ✗

η = 0 gives 0.25 ✓

Symmetry.

Exam tips

  1. p = 1/(1 + e^(−η)).
  2. p′ = p(1 − p).
  3. Max slope 0.25 at η = 0.
  4. logit is the inverse.
  5. Odds = p/(1 − p).

Practice questions

Try each one on paper, then open the answer. Use the solver above to see the full working.

1. p at η = 1, 4 dp Foundation

0.7311

2. p at η = −1, 4 dp Foundation

0.2689

3. Derivative at p = 0.5 Foundation

0.25

4. Logit of p = 0.9, 4 dp Higher

2.1972

5. Derivative at p = 0.9 Higher

0.09

6. p at η = 3, 4 dp Higher

0.9526

Practice generator

Unlimited fresh questions with instant marking. Choose a level, work it out on paper, then type your answer.

Solve: …

Key terms

Logistic function
Sigmoid.
Logit
ln of odds.
Odds
p/(1 − p).
Sigmoid
S-shaped curve.
Derivative
p(1 − p).
Link function
Connects η to p.

Frequently asked questions

What is the logistic function?

1/(1 + e^(−η)).

What is its derivative?

p(1 − p).

What is the logit?

ln(p/(1 − p)), the inverse function.

What is p at η = 0?

0.5.

Which page covers softmax?

softmax and cross-entropy.

Which page covers MLE?

maximum likelihood estimation.

More in Advanced statistics and stochastic processes and the formula sheets.