Calculus, Linear Algebra & Discrete Math Derivatives & Differentiation Second derivative test for concavity and local extrema

Second Derivative & Concavity Calculator

Enter a function and this calculator differentiates it twice, evaluates the second derivative at the point you name, scans the interval you choose for every sign change, and reports the resulting inflection points and concavity runs. The sign of the second derivative is what separates a hill from a valley once the slope has already hit zero, so the calculator also applies the second derivative test whenever the first derivative is zero at your point. The interval table and the graph show the whole shape rather than one number.

Calculator

This calculator runs in your browser. Enable JavaScript for live results — the inputs, formula and worked example below remain fully readable without it.

Inputs this calculator takes, with typical values
InputWhat to enterExample
Function f(x)Use ^ for powers, * for multiplication (2*x, 2x and a plain space all work, so x sin(x) is read as a product), and the function names sin, cos, tan, sec, csc, cot, asin, acos, atan, sinh, cosh, tanh, exp, ln, log (base 10), sqrt, cbrt and abs. The constants pi and e are recognised.x^3 - 6x^2 + 9x + 2
Evaluate at xThe point where you want a number and a concavity verdict.1
Interval startLeft end of the window searched for inflection points.-2
Interval endRight end of that window. A narrower window separates crossings that sit close together.6

It returns

  • Second derivative at your point — Positive means the curve bends upward there; negative means it bends downward.
  • Second derivative, simplified
  • Concavity at your point
  • Inflection points in the interval
  • First derivative at your point
  • f at your point
  • Number of inflection points found

The formula

f(x)=ddx[f(x)]=d2ydx2
f(x)f(x+h)2f(x)+f(xh)h2

In plain text: f″(x) = d/dx [f′(x)]; the curve is concave up where f″ > 0 and concave down where f″ < 0

  • f″(x)Second derivative — the rate at which the slope itself is changing (units of f per unit of x squared)
  • f′(x)First derivative, the slope of the curve (units of f per unit of x)
  • xThe point being examined (units of x)

An inflection point requires the second derivative to change sign, not merely to equal zero. x to the fourth power at the origin is the standard counterexample.

Updated Category Derivatives & Differentiation Verified against published test cases Reading time 10 min

What the second derivative tells you that the first cannot

The first derivative tells you which way a curve is going. The second derivative tells you how that direction is changing — whether the slope is getting steeper or flatter as you move right. Geometrically it is the bend, or concavity, of the graph.

Two functions can both be increasing everywhere and look completely different. y = x rises at a constant rate; y = x² on the positive axis rises faster and faster. Both have positive first derivatives on x > 0. Only the second one has a positive second derivative, and that is what makes it curve upward.

The physical reading is the most memorable. If f is position and x is time, the first derivative is velocity and the second is acceleration. A car with positive velocity and negative acceleration is still moving forward but braking. That is exactly a concave-down stretch of the position graph, and the language transfers to every other application: sales still growing but growth slowing, an outbreak still spreading but spreading less fast, a population still rising toward its ceiling.

Where the second derivative changes sign, the bend reverses. That point is the inflection point, and in an applied model it is usually the most interesting single point on the curve — the moment a growth process stops accelerating and starts decelerating, which arrives long before the quantity itself peaks.

How the calculator finds the second derivative and locates inflection points

The derivative is symbolic. The calculator differentiates your expression once using the power, product, quotient and chain rules, simplifies, then differentiates the result again. Both intermediate expressions appear in the steps, so you can check your own first derivative before worrying about the second. Symbolic differentiation is exact everywhere the function is defined, unlike the finite-difference formula shown alongside the main formula, which is an approximation and loses accuracy as h shrinks.

Inflection points are found numerically, and deliberately so. Solving f″(x) = 0 in closed form is impossible for most functions — try it for e^(−x²)·sin x. Instead the calculator samples the second derivative at 401 evenly spaced points across your interval, notes every place where the sign flips between consecutive samples, and refines each crossing with 60 rounds of bisection. That resolves each root to roughly machine precision.

Sign change, not zero, is the criterion. This matters more than any other detail on the page. f(x) = x⁴ has f″ = 12x², which equals zero at the origin — yet the curve is concave up on both sides and has no inflection there at all. Because the calculator looks for sign changes rather than zeros, it correctly reports zero inflection points for x⁴, and that case ships as one of its test vectors.

The method's one limitation follows from the sampling: two inflection points closer together than the sample spacing, (b − a)/400, can be missed as a pair. Narrow the interval if you suspect that, and the resolution improves proportionally.

Worked example: x³ − 6x² + 9x + 2 on the interval from −2 to 6

Take the default function, f(x) = x³ − 6x² + 9x + 2.

  1. First derivative. f′(x) = 3x² − 12x + 9, which factors as 3(x − 1)(x − 3). So the critical points are x = 1 and x = 3.
  2. Second derivative. f″(x) = 6x − 12 = 6(x − 2).
  3. Evaluate at x = 1. f″(1) = 6 − 12 = −6. Negative, so the curve is concave down there.
  4. Run the second derivative test. f′(1) = 3 − 12 + 9 = 0 and f″(1) = −6, which is negative, so x = 1 is a local maximum. Its height is f(1) = 1 − 6 + 9 + 2 = 6.
  5. Do the same at the other critical point. f″(3) = 18 − 12 = +6, so x = 3 is a local minimum, at height f(3) = 27 − 54 + 27 + 2 = 2.
  6. Find the inflection point. 6(x − 2) = 0 gives x = 2, and the second derivative goes from negative to positive there, so the sign really does change. The height is f(2) = 8 − 24 + 18 + 2 = 4.

Notice where the inflection sits: at x = 2, exactly halfway between the maximum at 1 and the minimum at 3. That is a property of every cubic — its inflection point is the midpoint of its two critical points, and it is also the centre of symmetry of the curve. The concavity table on this page reports concave down on the run from −2 to 2 and concave up from 2 to 6, split at the one crossing it found.

How to read the concavity verdict

A positive second derivative means concave up. The curve holds water. Tangent lines lie below the graph, and any chord between two points on the curve lies above it. On a cost curve this is the shape of increasing marginal cost — each extra unit costs more than the last.

A negative second derivative means concave down. The curve sheds water, tangent lines lie above the graph, and chords lie below it. This is the shape of diminishing returns: output still rising, each increment smaller than the one before.

A zero second derivative means nothing on its own. A single point where f″ = 0 is a candidate inflection, not an inflection. You must check that the sign differs on the two sides. The calculator does this by construction, but if you are working by hand, test a point either side rather than trusting the zero.

The second derivative test has a gap. At a critical point where f′ = 0, a positive second derivative proves a local minimum and a negative one proves a local maximum. When the second derivative is also zero the test says nothing at all — , x⁴ and −x⁴ all have both derivatives zero at the origin and produce an inflection, a minimum and a maximum respectively. In that case fall back to the first derivative test, which examines the sign of f′ on either side; the critical points calculator applies it.

Second derivatives of the standard functions

Each row lists f, its first derivative and its second derivative, plus where the curve bends upward. These are the textbook results this calculator reproduces.
f(x)f′(x)f″(x)Concave up where
2x2Everywhere
3x²6xx > 0
x⁴4x³12x²Everywhere except x = 0, where f″ = 0 but the sign does not change
sqrt(x)1/(2√x)−1/(4x^1.5)Nowhere on x > 0
e^xe^xe^xEverywhere
ln x1/x−1/x²Nowhere on x > 0
sin xcos x−sin xFrom −π to 0, and every 2π shift of that run
1/x−1/x²2/x³x > 0
x·e^(−x)(1−x)·e^(−x)(x−2)·e^(−x)x > 2

The fourth-power row is the reason this calculator counts sign changes rather than zeros. The last row shows the standard pattern of a rise-then-decay model: a maximum at x = 1 and an inflection at x = 2.

Traps in concavity problems

  • Calling every zero of the second derivative an inflection point. The sign must change. x⁴ at the origin has a zero second derivative and no inflection whatsoever.
  • Missing an inflection where the second derivative is undefined. Concavity can flip at a point where f″ does not exist, such as cbrt(x) at the origin. Neither this calculator nor a solution of f″ = 0 will report it, because the scan discards samples at which f″ is not finite. Check such points by hand.
  • Confusing concave down with decreasing. They are independent. ln x is increasing and concave down everywhere on its domain; 1/x on the negative axis is decreasing and concave down.
  • Applying the second derivative test where the first derivative is not zero. The test classifies critical points only. At a non-critical point the second derivative tells you about bend, not about maxima and minima.
  • Trusting the test when the second derivative is also zero. It is inconclusive there and gives no information at all, so use the first derivative test instead.
  • Searching too narrow an interval. The calculator only reports inflection points inside the window you set. If the window ends at 6 and the next sign change is at 6.5, you will never see it.

Where the second derivative shows up next

Curve sketching. The classic workflow is: find the domain, compute the first derivative for increasing and decreasing runs and critical points, compute the second derivative for concavity and inflection points, then check the limits at infinity for asymptotes. The result is a complete qualitative picture without plotting a single point. The limit calculator handles the last step.

Taylor series. The quadratic term of a Taylor expansion is f″(a)(x − a)²/2, so the second derivative is precisely the curvature the best quadratic approximation carries. Everything a Taylor polynomial knows about bend is stored in the second derivative.

Error bounds for numerical integration. The error bound for the trapezoidal rule is proportional to the maximum of the absolute second derivative across the interval, because the trapezoid rule is exact for straight lines and its error is driven entirely by how far the curve bends away from one.

Optimisation in several variables. In two or more dimensions the second derivative becomes a matrix of second partials, and its determinant plays the role that the sign of f″ plays here. That is the second derivative test for surfaces, and it is why determinants appear in multivariable optimisation.

One caution about physical data: the second derivative amplifies noise far more aggressively than the first. Differentiating measured data twice is rarely worth doing without smoothing first, which is why applied work usually fits a model and differentiates the model.

Frequently asked questions

What is the difference between a zero second derivative and an inflection point?

A zero is necessary but not sufficient. An inflection point needs the second derivative to actually change sign there, so that the curve switches from concave up to concave down or the other way. x⁴ at the origin has a zero second derivative and stays concave up on both sides, so it has no inflection point. This calculator counts sign changes precisely to avoid that trap.

Can a curve have an inflection point where the second derivative does not exist?

Yes, and this calculator will not find it. cbrt(x) has an inflection at the origin, where the second derivative is undefined, because the concavity flips from up to down across that point. The scan here drops any sample at which f″ is not finite rather than bridging across the gap, and that is deliberate: bridging would also report the origin as an inflection of 1/x, which has none, because zero is not in its domain at all. So wherever f″ blows up or leaves the domain, evaluate the sign just either side by hand.

Why does the second derivative test sometimes fail?

Because it is silent when the second derivative is zero at the critical point. , x⁴ and −x⁴ all have both derivatives zero at the origin, yet they produce an inflection, a minimum and a maximum. When that happens, use the first derivative test: check the sign of f′ just left and just right of the point.

How precisely are the inflection points located?

Each sign change is bracketed by two of 401 evenly spaced samples, then narrowed by 60 bisection steps, each of which halves the bracket. Starting from an interval of width 8 the final bracket is far below double-precision resolution, so the printed value is limited by floating-point arithmetic rather than by the method.

Does concave up mean the function is increasing?

No — the two are independent. Concavity is about the slope's rate of change, not the slope's sign. e^(−x) is decreasing and concave up everywhere; ln x is increasing and concave down everywhere. You need both derivatives to know the shape.

What interval should I search?

Wide enough to contain the behaviour you care about, narrow enough that features are not crowded. The default window of eight units resolves crossings to about 0.02 before bisection refines them. If you expect two inflection points very close together, shrink the window around them rather than widening it.

Why is my second derivative printed differently from my textbook's?

The calculator simplifies mechanically — folding constants and collecting like terms — but it never factors or applies identities. So it may print 6·x − 12 where a book writes 6(x − 2). Substituting a value into both forms is the quickest way to confirm they agree.

Can I use this on a function of two variables?

No. Every letter other than x is treated as a constant here, so you would get a partial second derivative rather than the full picture. For surfaces you need the matrix of second partials and its determinant to classify critical points; start with the partial derivative calculator for the individual entries.

References

  • Calculus, 8th edition (concavity and the second derivative test, section 4.3) — James Stewart, Cengage Learning
  • Thomas' Calculus, 14th edition (applied maxima and minima, chapter 4) — Hass, Heil & Weir, Pearson
  • Numerical Recipes: The Art of Scientific Computing, 3rd edition (root finding by bisection) — Press, Teukolsky, Vetterling & Flannery, Cambridge University Press