A function rises where its derivative is positive and falls where it is negative. Use that to find where a curve can turn, prove that a smooth peak or valley has slope zero, and tell peaks from valleys by how the sign of the slope changes.
Explain, from the mean value theorem, why a function rises where its derivative is positive and falls where it is negative.
Prove Fermat’s theorem: at an interior maximum or minimum where the derivative exists, the derivative is zero.
Find the critical points of a function and classify each one with the first-derivative test.
Give a critical point that is neither a maximum nor a minimum, and explain why.
In review. The maths and code on this page are checked by automated tests on every change, but an independent reader has not signed it off yet. Spot a mistake or a confusing step? Tell us.
The question
A computer training a model cannot see the whole loss curve: at any one setting it can ask only how high the loss is and which way it slopes. From slopes alone, can it tell where a curve turns, and whether a turn is a valley or a peak? Take the running cubic \({g(x) = x^3 - 3x}\). It climbs, dips and climbs again. Where exactly does it turn, and how would you know without drawing it?
Intuition
Walk along a graph from left to right. Where the tangent line tilts up you are climbing; where it tilts down you are descending. The tilt of the tangent is the derivative (M04.2), so: where the derivative is positive the graph rises, and where it is negative the graph falls.
M04.4.1-F1
The running cubic (top) and its slope (bottom). The green tangent arrows point the way a walker going right is heading. Where \({g'}\) is above the axis \(g\) rises, where it is below \(g\) falls, and the turns sit where \({g'}\) crosses zero.
To turn from climbing to descending the slope must change sign, and a slope that changes smoothly passes through zero on the way: a smooth curve can turn only where its tangent is flat. For the running cubic the slope is \({g'(x) = 3x^2 - 3}\), by the power rule (M04.3.1). It is positive for \(x\) below \({-1}\), negative between \({-1}\) and 1, and positive above 1. So \(g\) climbs to a peak at \({x = -1}\), where \({g(-1) = 2}\), falls to a valley at \({x = 1}\), where \({g(1) = -2}\), and then climbs for ever.
Build it up
Step 1. Rising and falling, said exactly. A function is increasing on an interval if a larger input always gives a larger output: whenever \({a < b}\) in the interval, \({f(a) < f(b)}\). It is decreasing if a larger input always gives a smaller output.
Step 2. One tangent is not enough. A slope at one point says only how the graph tilts there, while “rising” is a claim about pairs of points that may be far apart. We need a bridge from slopes to differences in height.
Step 3. The bridge. Pick two points on a smooth curve and join them by a straight line, the secant. Its slope is the average rate of change between them (M04.2.1). Now slide a tangent line along the curve between the two points. Somewhere it is parallel to the secant: at that point the slope of the curve equals its average slope.
M04.4.1-F2
The mean value theorem for the running cubic on \({[0, 2]}\): the secant (vermillion) and the tangent at \(c\), about 1.15 (green), both have slope 1.
The tangent slope \({3c^2 - 3}\) equals 1 when \({3c^2 = 4}\), so \({c^2 = 4/3}\), and the root between 0 and 2 is \({c = 2/\sqrt{3} \approx 1.15}\).
Step 4. From the bridge to rising. “The slope at \(c\) equals the average slope”, multiplied out, is
\[
f(b) - f(a) = f'(c)\,(b - a) .
\]
If \({f'}\) is positive everywhere between \(a\) and \(b\), then \({f'(c) > 0}\), and with \({b - a > 0}\) the product is positive: \({f(b) > f(a)}\). That holds for any \({a < b}\) in an interval where \({f' > 0}\), so \(f\) is increasing there. If \({f'}\) is negative throughout, the product is negative and \(f\) is decreasing.
The formal statement
NoteTheorem: the mean value theorem
If \(f\) is continuous on the closed interval \({[a, b]}\) and differentiable on the open interval \({(a, b)}\), there is at least one number \(c\) with \({a < c < b}\) and
\[
f'(c) = \frac{f(b) - f(a)}{b - a} .
\]
It is used here without proof (a block below shows where it comes from), and Step 4 turned it into the first result. Rising and falling: if \(f\) is continuous on an interval and \({f'(x) > 0}\) at every inner point, \(f\) is increasing there; if \({f'(x) < 0}\) at every inner point, \(f\) is decreasing.
NoteDefinitions: local extremes and critical points
\(f\) has a local maximum at \(c\) if \({f(c) \geq f(x)}\) for every \(x\) in some open interval around \(c\), and a local minimum at \(c\) if \({f(c) \leq f(x)}\) for every such \(x\). Either one is a local extremum.
A critical point of \(f\) is a point \(c\) inside its domain where \({f'(c) = 0}\) or where \({f'(c)}\) does not exist.
“Local” means compared with near neighbours only. The peak of the running cubic is a local maximum even though the curve later climbs far higher.
NoteTheorem (Fermat): smooth extremes are flat
If \(f\) has a local maximum or a local minimum at \(c\), \(c\) is not an end of the domain, and \({f'(c)}\) exists, then \({f'(c) = 0}\).
Proof. Suppose \(f\) has a local maximum at \(c\). Then for every small enough \(h\), positive or negative, \({f(c + h) \leq f(c)}\), so the top of the difference quotient is never positive:
\[
f(c + h) - f(c) \leq 0 .
\]
M04.4.1-F3
The proof as a picture. Secants from a peak to the right never slope up; secants to the left never slope down. The tangent is the limit of both, so it is caught between them: flat.
Take \({h > 0}\) first. The quotient is a number that is at most 0 divided by a positive number, so
\[
\frac{f(c + h) - f(c)}{h} \leq 0 .
\]
As \(h\) shrinks to 0 from the right, the quotient tends to \({f'(c)}\): the derivative exists, and a limit exists exactly when both one-sided limits exist and agree (M04.1.3). Numbers that are all at most 0 cannot have a positive limit (block below), so \({f'(c) \leq 0}\).
Now take \({h < 0}\). The top is at most 0 and the bottom is negative, so the quotient is at least 0. Letting \(h\) rise to 0 from the left gives \({f'(c) \geq 0}\). The only number that is both at most 0 and at least 0 is 0, so \({f'(c) = 0}\). For a local minimum every inequality turns round, and the conclusion is the same.
Two conditions did real work. Both signs of \(h\) were used, so \(c\) needs neighbours on both sides: it cannot be an end point. And the one-sided limits had to agree, so \({f'(c)}\) must exist. Where it does not, as at the corner of \({\abs{x}}\), an extreme can sit at a point with no slope at all, which is why a critical point may also be a point where the derivative is missing.
Fermat’s theorem narrows the search: an interior extreme can only be at a critical point. Not every critical point is an extreme, though. The next test decides.
NoteTheorem: the first-derivative test
Let \(c\) be a critical point of \(f\). Let \(f\) be continuous at \(c\) and differentiable on an open interval around \(c\), except perhaps at \(c\) itself.
If \({f'}\) changes from positive to negative at \(c\), \(f\) has a local maximum at \(c\).
If \({f'}\) changes from negative to positive at \(c\), \(f\) has a local minimum at \(c\).
If \({f'}\) has the same sign on both sides of \(c\), \(f\) has neither.
Proof of the first case. Take an interval around \(c\) on which \({f' > 0}\) to the left of \(c\) and \({f' < 0}\) to the right. For any \(x\) in it to the left of \(c\), \(f\) is increasing on \({[x, c]}\) (rising and falling, with continuity at \(c\)), so \({f(x) < f(c)}\). For any \(x\) to the right, \(f\) is decreasing on \({[c, x]}\), so again \({f(x) < f(c)}\). Every neighbour is lower: a local maximum. The second case is the mirror image. In the third, say with \({f' > 0}\) on both sides, \({f(x) < f(c)}\) on the left and \({f(x) > f(c)}\) on the right, so \(c\) is neither.
Go deeper: why a limit keeps the sign, and where the mean value theorem comes from
A limit keeps the sign. Suppose numbers \({q(h) \leq 0}\) for all small \({h > 0}\) had a positive limit \(\ell\). Use the tolerance \({\ell/2}\) in the definition of a limit (M04.1.1): for \(h\) close enough to 0, \({q(h)}\) is within \({\ell/2}\) of \(\ell\), so \({q(h) > \ell/2 > 0}\). That contradicts \({q(h) \leq 0}\), so \({\ell \leq 0}\).
The mean value theorem follows from Fermat’s. Tilt the curve until its two ends are level by subtracting the secant line, with slope \(m\):
Then \({\varphi(a) = \varphi(b) = 0}\). On \({[a, b]}\), \(\varphi\) has a largest and a smallest value (the extreme value theorem, M04.4.3). If both are at the ends, \(\varphi\) is constant and any \(c\) works; otherwise one is inside, where Fermat’s theorem gives \({\varphi'(c) = f'(c) - m = 0}\).
Worked example
Find and classify the critical points of the running cubic \({g(x) = x^3 - 3x}\).
Step 1: the derivative. By the power rule, \({g'(x) = 3x^2 - 3}\). It exists for every \(x\), so the critical points are exactly the zeros of \({g'}\).
Step 2: the zeros. Take out the common factor, then use the difference of two squares:
A product is zero only when one of its factors is, so the critical points are \({x = -1}\) and \({x = 1}\).
Step 3: the signs. The two critical points cut the number line into three intervals. On each one \({g'}\) keeps a single sign, because a continuous function can change sign only by passing through zero (the intermediate value theorem, M04.1.4). So one test point per interval is enough: \({g'(-2) = 9}\), \({g'(0) = -3}\) and \({g'(2) = 9}\). The signs can also be read off the factors:
M04.4.1-F4
The sign chart. Each factor changes sign at its own zero, the product \({g'}\) takes the sign they give, and the last row reads it as rising and falling.
Step 4: read off the answer. At \({x = -1}\) the slope changes from \(+\) to \(-\): a local maximum, of height \({g(-1) = -1 + 3 = 2}\). At \({x = 1}\) it changes from \(-\) to \(+\): a local minimum, of height \({g(1) = 1 - 3 = -2}\): the peak and the valley of the anchor figure.
The warning case. The derivative of \({x^3}\) is \({3x^2}\), zero at 0, so 0 is a critical point. But \({3x^2 > 0}\) on both sides of 0, so by the third case of the test \({x^3}\) has no extreme there: it rises into the flat spot and keeps rising out of it.
Code
From scratch first: the slope found by hand is checked against a central difference (M04.2.4), and the test reads the sign of the slope just either side of a critical point.
def g(x):return x**3-3* xdef g_slope(x):"""The derivative of g, found by hand."""return3* x**2-3def central_difference(f, x, h=1e-5):return (f(x + h) - f(x - h)) / (2* h)for x in [-2, -1, 0, 1, 2]:print(f"x = {x:2d}: by hand {g_slope(x):3d}, numerically {central_difference(g, x):8.5f}")
x = -2: by hand 9, numerically 9.00000
x = -1: by hand 0, numerically 0.00000
x = 0: by hand -3, numerically -3.00000
x = 1: by hand 0, numerically 0.00000
x = 2: by hand 9, numerically 9.00000
def first_derivative_test(slope, c, step=1e-3):"""Classify the critical point c by the sign of the slope just left and just right of it.""" left, right = slope(c - step), slope(c + step)if left >0and right <0:return"local maximum"if left <0and right >0:return"local minimum"return"neither"for c in [-1, 1]:print(f"g at x = {c:2d}: {first_derivative_test(g_slope, c)}, height {g(c)}")print("x**3 at x = 0:", first_derivative_test(lambda x: 3* x**2, 0))
g at x = -1: local maximum, height 2
g at x = 1: local minimum, height -2
x**3 at x = 0: neither
Two signs a small step away are evidence, not proof: the step can jump over a second critical point close by. The library version lets NumPy hold the polynomial, differentiate it and solve \({g'(x) = 0}\):
This module’s interactive, the descent explorer, lives in lesson M04.4.4. Choose the running cubic there and drag the ball: the read-out gives the sign of \({g'}\) under it.
Pitfalls
M04.4.1-F5
Wrong beside right. Both curves are flat at the dot, but only the right one turns there: only there does the slope change sign.
“The slope is zero here, so this is a maximum or a minimum.”
A zero slope makes a point a candidate, nothing more. \({x^3}\) is flat at 0 but its slope is positive on both sides, so it has no extreme there. Check that the sign changes.
“A minimum must have slope zero.”
Only if the slope exists there. \({\abs{x}}\) is lowest at 0, where its graph has a corner with one-sided slopes \({-1}\) and 1, so no derivative (M04.2.3); ReLU has the same kind of corner. And on an interval the lowest value can sit at an end, where the slope need not be zero: lesson M04.4.3 adds the ends to the search.
“The lowest point I found is the lowest point there is.”
A local minimum beats only its neighbours. The running cubic’s valley has height \({-2}\), yet \({g(-3) = -27 + 9 = -18}\), and \(g\) keeps falling to the left. Training has the same trap: a method that only follows slopes can settle in a valley that is not the deepest. The next lesson finds the functions that are safe from it.
Check yourself
Recall
1. On an interval where \({f'(x) < 0}\) at every point, what does \(f\) do, and which theorem guarantees it?
Show answer
\(f\) is decreasing there. By the mean value theorem, \({f(b) - f(a)} = {f'(c)(b - a)}\) for some \(c\) between \(a\) and \(b\), and that is negative whenever \({a < b}\).
2. State Fermat’s theorem, with both of its conditions on \(c\).
Show answer
If \(f\) has a local maximum or minimum at \(c\), \(c\) is not an end of the domain, and \({f'(c)}\) exists, then \({f'(c) = 0}\).
3. What is a critical point?
Show answer
A point \(c\) inside the domain where \({f'(c) = 0}\) or where \({f'(c)}\) does not exist.
4. At a critical point the slope changes from negative to positive. What kind of point is it?
Show answer
A local minimum: the function falls into it and rises out of it.
5. Why is 0 a critical point of \({x^3}\) but not an extreme?
Show answer
Its derivative \({3x^2}\) is zero at 0, so 0 is critical. But \({3x^2}\) is positive on both sides, so \({x^3}\) rises before 0 and after it: no peak and no valley.
Exercises
1.★ The cart of the running trip (an invented example) has speed \({v(t) = 4t - t^2}\) metres per second for \({0 \leq t \leq 4}\). Find the critical point of \(v\) and use the first-derivative test to say when the cart is fastest, and how fast it goes then.
Show solution
By the power rule \({v'(t) = 4 - 2t}\), which exists everywhere and is zero only at \({t = 2}\). Test points: \({v'(1) = 2 > 0}\) and \({v'(3) = -2 < 0}\), so the sign changes from \(+\) to \(-\) and \(v\) has a local maximum at \({t = 2}\), with \({v(2) = 8 - 4 = 4}\) metres per second. As \(v\) rises on all of \({[0, 2]}\) and falls on all of \({[2, 4]}\), it is the top speed of the trip.
2.★★ Find and classify every critical point of the double well \({f(x) = x^4 - 2x^2}\).
Show solution
\({f'(x)} = {4x^3 - 4x} = {4x(x^2 - 1)} = {4x(x + 1)(x - 1)}\), which is zero at \({x = -1}\), 0 and 1. Test points: \({f'(-2) = -32 + 8 = -24}\), \({f'(-0.5)} = {-0.5 + 2} = {1.5}\), \({f'(0.5)} = {0.5 - 2} = {-1.5}\) and \({f'(2) = 32 - 8 = 24}\). The signs run \(-\), \(+\), \(-\), \(+\). So \({x = -1}\) is a local minimum with \({f(-1) = 1 - 2 = -1}\), \({x = 0}\) is a local maximum with \({f(0) = 0}\), and \({x = 1}\) is a local minimum with \({f(1) = -1}\): two valleys with a hump between them.
3.★★★ Show that \({f(x) = x^3 + x}\) has no critical points and is increasing on the whole number line. Deduce that the equation \({x^3 + x = 1}\) has exactly one solution, and that it lies between 0 and 1.
Show solution
\({f'(x) = 3x^2 + 1}\) exists everywhere and is at least 1, because \({3x^2 \geq 0}\). It is never zero, so there are no critical points, and it is positive everywhere, so \(f\) is increasing: for any \({a < b}\) the mean value theorem gives \({f(b) - f(a)} = {f'(c)(b - a)} > {0}\).
A solution exists: \(f\) is continuous with \({f(0) = 0 < 1}\) and \({f(1) = 2 > 1}\), so the intermediate value theorem (M04.1.4) gives one between 0 and 1. There is only one: two solutions \({a < b}\) would need \({f(a) < f(b)}\), yet both equal 1. (Bisection puts it at about 0.6823.)
Summary card
The sign of the slope says where a function rises, falls and turns.
M04.4.1-F1
Turns sit where the slope crosses zero.
\({f' > 0}\) on an interval: \(f\) rises. \({f' < 0}\): \(f\) falls. (The mean value theorem.)
Fermat: at an interior extreme where \({f'}\) exists, \({f' = 0}\).
A critical point has \({f'(c) = 0}\) or no \({f'(c)}\) at all.
First-derivative test: \(+\) to \(-\) is a peak, \(-\) to \(+\) a valley, no change is neither.
Sources and next steps
Sources. Each was opened and checked against this lesson on 12 November 2026.
Gilbert Strang and Edwin Herman, Calculus Volume 1 (OpenStax). Section 4.3: critical points, and Fermat’s theorem (Theorem 4.2), proved from the two one-sided limits of the difference quotient. Section 4.4: the mean value theorem (Theorem 4.5), and a positive derivative means increasing (Theorem 4.8). Section 4.5: the first derivative test (Theorem 4.9).
Matthew Boelkins, Active Calculus, Section 3.3: critical numbers (Definition 3.3.6), the first derivative test, and the warning that not every critical number gives a maximum or a minimum.
Marc Peter Deisenroth, A. Aldo Faisal and Cheng Soon Ong, Mathematics for Machine Learning, the introduction to Chapter 7: stationary points are the zeros of the derivative, and following the negative gradient from a poor start leads to a minimum that is not the lowest.
Next.M04.4.2 The second derivative and convexity tells peaks from valleys with one number, the curvature, and finds the functions whose only valley is the lowest point of all.