# Fermat's Theorem on Local Extrema: Statement and Examples

> Fermat's theorem: if f has a local max or min at c and f'(c) exists, then f'(c) = 0. Statement, graph, why the converse fails, and worked examples.

Source: https://practicecalculus.com/theorems/fermats-theorem
Updated: 2026-11-03

$$ f'(c) = 0 $$

## At a glance

- **Also called:** Fermat's theorem on stationary points, interior extremum theorem
- **Hypotheses:** $f$ has a local maximum or minimum at an interior point $c$, and $f'(c)$ exists
- **Conclusion:** $f'(c) = 0$
- **Converse:** False: $f'(c) = 0$ does not guarantee an extremum, as $x^3$ at $0$ shows
- **Used for:** Finding critical points, the closed interval method, optimization
- **Course:** Calculus 1

## Key takeaways

- At a local maximum or minimum where the derivative exists, the tangent line is horizontal.
- So every local extremum is at a critical point: $f'(c) = 0$ or $f'(c)$ does not exist.
- The converse is false. A critical point can be neither a max nor a min, like $x = 0$ for $x^3$.
- The theorem is about interior points. Extremes at the endpoints of an interval need not have zero slope.

**Fermat's theorem** (on local extrema) says that at the top of a hill or the bottom of a valley on a smooth graph, the tangent line is flat. It is the theorem behind the most common move in calculus: to find a maximum or minimum, set the derivative equal to zero.

## Statement of Fermat's theorem

Suppose that

1. $f$ has a **local maximum or local minimum** at $c$, meaning $f(c) \ge f(x)$ (or $f(c) \le f(x)$) for all $x$ in some open interval around $c$, and
2. $f'(c)$ **exists**.

Then

$$f'(c) = 0$$

Because the definition of a local extremum uses an open interval around $c$, the point $c$ must be an interior point of the domain, not an endpoint.

## What Fermat's theorem means

At a local maximum, the function rises up to $c$ and falls after it. Just to the right of $c$ the difference quotient $\frac{f(c + h) - f(c)}{h}$ is $\le 0$, and just to the left it is $\ge 0$. If the derivative exists, both one-sided limits are the same number, and the only number that is both $\le 0$ and $\ge 0$ is $0$.

```graph
title: 'Fermat''s theorem: horizontal tangents at the local max and min of y = x³ − 3x'
caption: 'The local maximum at $x = -1$ and the local minimum at $x = 1$ both have horizontal tangent lines, so $f''(-1) = f''(1) = 0$.'
x: [-2.5, 2.5]
y: [-4, 4]
functions:
  - expr: x^3 - 3x
    label: y = x³ − 3x
  - expr: '2'
    label: horizontal tangents
    dashed: true
    domain: [-2, 0]
  - expr: '-2'
    dashed: true
    domain: [0, 2]
points:
  - [-1, 2, 'local max (−1, 2)']
  - [1, -2, 'local min (1, −2)']
```

## Why each hypothesis matters, and why the converse fails

**The derivative must exist.** $f(x) = |x|$ has a minimum at $x = 0$, but $f'(0)$ does not exist because of the corner. Fermat's theorem says nothing there. This is why critical points include points where $f'$ is undefined.

**The point must be interior.** On $[0, 1]$, $f(x) = x$ has its maximum at the endpoint $x = 1$, yet $f'(1) = 1 \ne 0$. Endpoint extrema are not covered by the theorem, so the closed interval method checks endpoints separately.

**The converse is false.** $f(x) = x^3$ has $f'(0) = 0$, but $x^3$ is negative to the left of $0$ and positive to the right, so $0$ is not a local extremum. A horizontal tangent makes $c$ a **candidate**, nothing more. You still need the first or second derivative test.

## Critical points

Fermat's theorem justifies this definition: a **critical point** of $f$ is a number $c$ in its domain where $f'(c) = 0$ or $f'(c)$ does not exist. Restated, every local extremum of $f$ occurs at a critical point.

## Worked examples

**Example 1: $f(x) = x^4 - 4x^3$.**

**Step 1.** $f'(x) = 4x^3 - 12x^2 = 4x^2(x - 3)$.

**Step 2.** Critical points: $x = 0$ and $x = 3$. By Fermat's theorem these are the only possible local extrema.

**Step 3.** Classify. $f'(x) < 0$ for $x < 0$ and for $0 < x < 3$, and $f'(x) > 0$ for $x > 3$. The function decreases through $x = 0$, so $x = 0$ is not an extremum, just like $x^3$. At $x = 3$ it switches from decreasing to increasing, so $f(3) = 81 - 108 = -27$ is a local minimum.

**Example 2: a critical point where $f'$ does not exist.** For $f(x) = x^{2/3}$,

$$f'(x) = \frac{2}{3}x^{-1/3} = \frac{2}{3\sqrt[3]{x}}$$

which is never $0$ and is undefined at $x = 0$. So $x = 0$ is the only critical point, and since $f(x) \ge 0 = f(0)$ for all $x$, it is a minimum. Setting $f'(x) = 0$ alone would miss it.

**Example 3: optimization.** Two numbers add to $10$. Maximize their product $P(x) = x(10 - x)$. Since the maximum is at an interior point and $P$ is differentiable, Fermat's theorem says $P'(x) = 10 - 2x = 0$, so $x = 5$ and the maximum product is $25$. See [optimization problems](/blog/optimization-problems) for more.

## Common mistakes

1. **Assuming $f'(c) = 0$ means an extremum.** Always classify critical points with a sign chart or the second derivative.
2. **Ignoring points where $f'$ is undefined.** Corners and cusps are critical points too.
3. **Forgetting endpoints.** On a closed interval the absolute extremes may sit at the endpoints, where Fermat's theorem does not apply.

## Related theorems

Fermat's theorem pairs with the [extreme value theorem](/theorems/extreme-value-theorem) to give the closed interval method, and it is the key step in proving [Rolle's theorem](/theorems/rolles-theorem) and then the [mean value theorem](/theorems/mean-value-theorem). For classifying critical points and sketching graphs, read [curve sketching with derivatives](/blog/curve-sketching-with-derivatives).

## Frequently asked questions

### What is Fermat's theorem in calculus?

It says that if $f$ has a local maximum or local minimum at $c$ and $f$ is differentiable at $c$, then $f'(c) = 0$. It is the reason we find extrema by setting the derivative equal to zero.

### Is the converse of Fermat's theorem true?

No. $f(x) = x^3$ has $f'(0) = 0$, but $x = 0$ is not a local maximum or minimum because the function increases on both sides. A zero derivative only makes $c$ a candidate.

### Is this the same as Fermat's last theorem?

No. Fermat's last theorem is a result in number theory about the equation $x^n + y^n = z^n$. In calculus, Fermat's theorem refers to the local extremum result $f'(c) = 0$.

### What is a critical point?

A critical point of $f$ is a number $c$ in the domain where $f'(c) = 0$ or $f'(c)$ does not exist. Fermat's theorem says every local extremum happens at a critical point.
