MathsCalculus

Derivative
calculator.

Type a function to get its derivative, every step, and the slope at any point.

How it’s worked out

The derivative of f at x is the slope of the curve at that point. You get it as the limit of the slope between two points h apart, as h shrinks to zero:

f′(x)\displaystyle f'(x)=limh→0⁡f(x+h)−f(x)h\displaystyle {}= \lim_{h \to 0} \frac{f(x + h) - f(x)}{h}
  • f(x) is your function, the formula you type in the box.
  • h is a small step along the x-axis. The fraction is the slope of the line through two nearby points on the curve.
  • f′(x), read “f prime of x”, is what that slope settles on. It is a new function: put in any x and it gives the slope there.

Nobody works out that limit by hand for every function. Instead you use a few rules, proved once from the limit, and apply them piece by piece. The tool does the same. It reads your formula as a tree of sums, products, powers and functions, applies the matching rule at each branch, then expands and collects like terms. The table shows the rules and the result the tool gives for each one.

Rulef(x)f′(x)
Power rulex5x^{5}5x45x^{4}
Root as a power(x\sqrt{\mathstrut x}12(x\frac{1}{2\sqrt{\mathstrut x}}
Exponentiale3xe^{3x}3e3x3e^{3x}
Natural logln⁡(x)\ln\left(x\right)1x\frac{1}{x}
Sinesin⁡(x)\sin\left(x\right)cos⁡(x)\cos\left(x\right)
Productxexx\,e^{x}xex+exx\,e^{x} + e^{x}
Chainsin⁡(x2)\sin\left(x^{2}\right)2xcos⁡(x2)2x\,\cos\left(x^{2}\right)

For a quotient the answer is longer, so it gets its own line. For f(x) = x/(x² + 1) the tool gives

ddx(xx2+1)\displaystyle \frac{d}{dx}\left(\frac{x}{x^{2} + 1}\right)=−x2(x2+1)2+1(x2+1)2\displaystyle {}= -\frac{x^{2}}{\left(x^{2} + 1\right)^{2}} + \frac{1}{\left(x^{2} + 1\right)^{2}}

The two fractions share a denominator and are left separate. Added together they give 1−x2(x2+1)2\frac{1 - x^2}{\left(x^2 + 1\right)^2}, the same function written as one fraction.

Written with u and v for two parts of a formula, the three rules that do most of the work are:

(uv)′\displaystyle (uv)'=u′v+uv′,\displaystyle {}= u'v + uv',(uv)′\displaystyle \left(\frac{u}{v}\right)'=u′v−uv′v2,\displaystyle {}= \frac{u'v - uv'}{v^2},(f(g(x)))′\displaystyle \bigl(f(g(x))\bigr)^{\prime}=f′(g(x))g′(x)\displaystyle {}= f'(g(x))\,g'(x)

The second derivative f″ is the derivative of f′. It tells you how the slope itself is changing, so its sign says which way the curve bends. The tool repeats the rules up to the fourth derivative.

Once you pick a point x₀, the tangent line is the straight line that touches the curve there with the same slope:

y\displaystyle y=f′(x0)(x−x0)+f(x0)\displaystyle {}= f'(x_0)\,(x - x_0) + f(x_0)

Here x₀ is your point, f(x₀) is the height of the curve there and f′(x₀) is the slope. The last step in the working checks the exact value against a five-point estimate built from f at x₀ − 2h, x₀ − h, x₀ + h and x₀ + 2h. If you use a function with no rule here, such as floor or gamma, that estimate is the answer and it is labeled as one. Angles in sin, cos and tan are in radians.

Worked examples

A product rule question on a problem set

Maya has to find the slope of f(x) = x² sin x at x = 1. With u = x² and v = sin x, the product rule gives u′v + uv′:

f′(x)\displaystyle f'(x)=x2cos⁡(x)+2xsin⁡(x)\displaystyle {}= x^{2}\,\cos\left(x\right) + 2x\,\sin\left(x\right)

At x = 1 that is cos 1 + 2 sin 1 ≈ 2.2232. The curve is at height 0.8415, so the tangent line is y = 2.2232x − 1.3818. If her answer key prints 2x sin x + x² cos x, it is the same function with the terms in a different order.

Open this example in the tool

The biggest box from a square sheet

Jordan cuts a square of side x cm from each corner of a 10 cm by 10 cm card and folds up the sides. The box has volume V(x) = x(10 − 2x)², which expands to 4x³ − 40x² + 100x cubic centimeters. The derivative is

V′(x)\displaystyle V'(x)=12x2−80x+100\displaystyle {}= 12x^{2} - 80x + 100

At a 1 cm cut, V′(1) = 32: the volume is still growing by about 32 cm³ for each extra centimeter, so a bigger cut helps. Searching from 0 to 5 finds where V′ = 0. At x = 53\tfrac{5}{3} ≈ 1.6667 cm the box holds its largest volume, about 74.07 cm³. The other zero, x = 5, is the cut that leaves no base at all, so V = 0 there. The second derivative, V′′(x)=24x−80V''(x) = 24x - 80, is negative at 53\tfrac{5}{3}, which confirms the maximum.

Open this example in the tool

Marginal cost at a bakery

A bakery models the daily cost of baking x loaves as C(x) = 0.02x³ − 1.5x² + 60x + 500 dollars. The derivative C′(x) is the marginal cost, the extra cost of one more loaf at that output:

C′(x)\displaystyle C'(x)=3x250−3x+60\displaystyle {}= \frac{3x^{2}}{50} - 3x + 60

At 40 loaves, C′(40) = 36, so loaf number 41 adds about $36.00. The second derivative is C′′(x)=3x25−3C''(x) = \frac{3x}{25} - 3. It changes sign at x = 25, the inflection point. That is where marginal cost is lowest, about $22.50 per loaf. Past 25 loaves each extra loaf costs a little more than the last.

Open this example in the tool

Reading your result

The formula is the exact derivative, typeset with stacked fractions and roots. Products are expanded and like terms collected, so the form can differ from your textbook while being the same function. Put any x into both forms to check: they give the same number.

The slope at your point is f′(x₀). A positive value means f is rising there; a negative value means it is falling. Its size is the rate: for f(x) = x³ − 3x at x = 2 the slope is 9, so a small step h in x changes f by about 9h. The tangent line is that same approximation drawn as a line.

Concavity comes from f″(x₀). Positive means the curve bends upward like a cup; negative means it bends down like a cap. For x³ − 3x at x = 2, f″(2) = 12, so it is concave up there.

Turning points are listed where f′ changes sign. Stewart’s second derivative test (section 4.3) classifies them: f′ = 0 with f″ > 0 is a local minimum, and f′ = 0 with f″ < 0 is a local maximum. When f″ is also 0 the test says nothing, so the tool uses the first derivative test instead and compares the sign of f′ just left and right of the point. Inflection points are where f″ changes sign.

An estimate label means no exact rule exists for part of your function. The value comes from a five-point difference. On a smooth stretch of curve it agrees with the true slope to many decimal places, but it is less precise for f‴ and f⁽⁴⁾. At a jump, such as floor(x) at a whole number, or a sharp corner, no derivative exists, and the calculator says so instead of giving a number. Move the point off the jump to get a slope.

Common mistakes

  • Multiplying the derivatives in a product. The derivative of x² sin x is not 2x cos x. The product rule needs both terms: 2x sin x + x² cos x.
  • Dropping the inner derivative. The derivative of sin(x²) is 2x cos(x²), not cos(x²). The chain rule multiplies by the derivative of the inside.
  • Getting the quotient rule backwards. The top is u′v − uv′, in that order. Swapping it flips the sign of the whole answer.
  • Using degrees. The rule that sin x has derivative cos x only holds when x is in radians. A slope worked out in degrees is off by a factor of π180\tfrac{\pi}{180}.
  • Treating an exponential like a power. The power rule does not apply when x is in the exponent. The derivative of 2x2^x is 2xln⁡22^x \ln 2, not x⋅2x−1x \cdot 2^{x-1}.
  • Asking for a slope where none exists. |x| has a corner at 0 and √x has a vertical tangent at 0, so neither has a derivative there. The tool says so instead of giving a number.
  • Calling every flat point a maximum or minimum. x³ has f′(0) = 0 but keeps rising on both sides. Check the sign of f′ on each side, or f″.

Questions people ask

Use the keys under the box, or type: sqrt turns into √, pi into π, ^ starts a power and / starts a stacked fraction. Type e then ^ for e to a power. ln is the natural log and log is base 10, so the derivative of log x is the derivative of ln x divided by ln 10.

Sources