d/dx x³ at x = 2
- Function f(x)
- x^3
- At x =
- 2
- Derivative
- First f′(x)
- Derivative
- 12
- f(x₀)
- 8
- Tangent line
- y = 12x − 16
Checked against: 3x² = 12 at x = 2; tangent 8 + 12(x − 2)
The first or second derivative of any function f(x) at a point, to about 20 significant digits by Richardson extrapolation, with the tangent line drawn.
By AdminDrafted with AI writing toolsUpdated Checked examples: 6
At x = 1 the slope of f is 2.2232443: f rises by about 2.223 × h when x moves by a small step h.
| h | Difference quotient | Best estimate so far |
|---|---|---|
| 0.1 | 2.21933054438 | 2.21933054438 |
| 0.05 | 2.22226613145 | 2.22324466047 |
| 0.025 | 2.22299975754 | 2.22324427552 |
| 0.0125 | 2.22318314713 | 2.22324427548 |
| 0.00625 | 2.22322899347 | 2.22324427548 |
| 0.003125 | 2.22324045498 | 2.22324427548 |
Its error has only even powers of h, which Richardson extrapolation removes one at a time.
Halved h 5 times from h₀ = 0.1; the estimated error is 9.6 × 10⁻²³.
D₋ and D₊ are the left and right estimates. Their agreement supports the numerical derivative, but a finite sampling check is not a proof of differentiability.
y = 2.223244x − 1.381773
The derivative f′(x₀) is the slope of f at x₀, the limit of the central difference quotient [f(x₀ + h) − f(x₀ − h)]/2h as h shrinks to 0. The calculator evaluates that quotient for h = 0.1 × max(1, |x₀|) and repeated halvings, then combines the results by Richardson extrapolation (Ridders' method, Numerical Recipes §5.7), which cancels the h², h⁴, … error terms one at a time and reaches about 20 significant digits. The second derivative uses [f(x₀ + h) − 2f(x₀) + f(x₀ − h)]/h² the same way.
Use it to check a derivative worked out by hand, to find a rate of change where no formula is convenient, or to get a tangent line. The default, x² sin x at x = 1, has derivative 2 sin 1 + cos 1 ≈ 2.2232443 and tangent line y = 2.223244x − 1.381773.
Trig functions use radians. When the slopes from the left and right disagree, f has a corner there and the calculator reports that instead of a number.
The derivative f′(x₀) is the slope of f at the point x₀: f′(x) = lim(h→0) [f(x+h)−f(x)]/h. For f(x) = x³, the power rule gives 3x², so the slope at x = 2 is 3 × 2² = 12, and the tangent line there is y = 12x − 16.
The answer here is numerical: the value of f′(x₀) or f″(x₀) at one point, to about 20 significant digits. For the formula itself, use the rules below or the table of common derivatives.
The OpenStax differentiation rules work through the power, product and quotient rules with examples.
Trig arguments are in radians. The last column shows where each formula holds: tan, sec and cot need a nonzero denominator, and asin and acos have finite derivatives only for −1 < x < 1. atan(x) is the inverse tangent; cot(x) is 1/tan(x).
| Input f(x) | First derivative | Real-domain requirement |
|---|---|---|
| x | 1 | All real x |
| x^3 | 3x² | All real x |
| sqrt(x) | 1/(2√x) | x > 0 |
| sin(x) | cos(x) | All real x; radians |
| cos(x) | −sin(x) | All real x; radians |
| tan(x) | sec²(x) | cos(x) ≠ 0 |
| sec(x) | sec(x) tan(x) | cos(x) ≠ 0 |
| cot(x) | −csc²(x) | sin(x) ≠ 0 |
| sin(2*x) | 2cos(2x) | All real x; radians |
| cos(2*x) | −2sin(2x) | All real x; radians |
| exp(2*x) | 2e^(2x) | All real x |
| exp(-2*x) | −2e^(−2x) | All real x |
| ln(sec(x)) | tan(x) | sec(x) > 0 |
| x^x | x^x (ln(x)+1) | x > 0 |
| atan(x) | 1/(1+x²) | All real x |
| asin(x) | 1/√(1−x²) | −1 < x < 1 |
| acos(x) | −1/√(1−x²) | −1 < x < 1 |
| atan(sqrt(x)) | 1/[2√x(1+x)] | x > 0 |
| x*tan(x) | tan(x)+x sec²(x) | cos(x) ≠ 0 |
| x*sin(x) | sin(x)+x cos(x) | All real x; radians |
In xˣ the exponent varies too, so logarithmic differentiation gives xˣ(ln x + 1). Treating the exponent as a constant gives x · xˣ⁻¹ = xˣ, which misses the ln x term. At x = 2 the slope is 4(ln 2 + 1) ≈ 6.7726.
ln(sec x) has a real logarithm only where sec x > 0. √x has derivative 1/(2√x) for x > 0 and no finite derivative at 0. The OpenStax exponential and logarithm lesson derives these rules.
Order 1 is the slope f′; order 2 is f″, how fast the slope itself changes. For ln x, f″(x) = −1/x², so f″(2) = −0.25. A second derivative is not the square of the first.
| Input f(x) | Point x | Order | Derivative |
|---|---|---|---|
| cos(2*x) | 0.5 | 1 | -1.68294197 |
| cos(x) | 1 | 1 | -0.841470985 |
| cot(x) | 1 | 1 | -1.412282927 |
| x^3 | 2 | 1 | 12 |
| atan(sqrt(x)) | 4 | 1 | 0.05 |
| acos(x) | 0.5 | 1 | -1.154700538 |
| exp(2*x) | 1 | 1 | 14.778112198 |
| exp(-2*x) | 1 | 1 | -0.270670566 |
| ln(sec(x)) | 0.5 | 1 | 0.54630249 |
| sqrt(x) | 4 | 1 | 0.25 |
| sin(2*x) | 0.5 | 1 | 1.080604612 |
| asin(x) | 0.5 | 1 | 1.154700538 |
| x | 2 | 1 | 1 |
| x*sin(x) | 1 | 1 | 1.381773291 |
| x*tan(x) | 0.5 | 1 | 1.195525695 |
| x^x | 2 | 1 | 6.772588722 |
| sin(x) | 1 | 1 | 0.540302306 |
| tan(x) | 0.5 | 1 | 1.29844641 |
| sec(x) | 0.5 | 1 | 0.62250837 |
| atan(x) | 1 | 1 | 0.5 |
| x^3 | 2 | 2 | 12 |
| ln(x) | 2 | 2 | -0.25 |
| 5 | 1 | 1 | 0 |
| x^2 * sin(x) | 1 | 1 | 2.223244275 |
The tangent line at x₀ is y = f(x₀)+f′(x₀)(x−x₀). For x³ at 2, f(2) = 8 and f′(2) = 12, so y = 8 + 12(x − 2) = 12x − 16. A second derivative gives no tangent line, because it is not a slope.
exp(2*x), with derivative 2e^(2x), or exp(-2*x), with derivative −2e^(−2x).sin(2*x) and 2*sin(x) are different functions with different derivatives.x^2, sqrt(x) or x^(1/2).The first derivative starts from the central difference quotient [f(x₀ + h) − f(x₀ − h)]/2h, with h = 0.1 × max(1, |x₀|) halved repeatedly. Richardson extrapolation (Ridders' method, Numerical Recipes §5.7) combines the quotients.
Each extrapolation step cancels one more of the h², h⁴, … error terms, which takes the result to about 20 significant digits.
The second derivative uses [f(x₀ + h) − 2f(x₀) + f(x₀ − h)]/h² in the same way. The estimated error is the gap between the last two extrapolated estimates: a measure of how well they settled, not a guaranteed bound.
Slopes from the left and right are compared too. abs(x) at 0 has slope −1 from the left and +1 from the right, so it has no derivative there, even though the central quotient averages to 0. 1/x and √x have no derivative at 0 either.
A derivative is a rate at one point. To add up change over an interval, use the definite integral calculator.
Checked against: 3x² = 12 at x = 2; tangent 8 + 12(x − 2)
Checked against: cos 0 = 1
Checked against: 2 sin 1 + cos 1 with sin/cos by Taylor series in exact decimal arithmetic at 70 digits
Checked against: Independent calculation
The derivative of f at x₀ is the slope of its graph there: the limit of [f(x₀ + h) − f(x₀)]/h as h approaches 0. For f(x) = x³ at x = 2 the slope is 3 × 2² = 12, so near x = 2 the function rises about 12 units for each unit of x. The line y = 12x − 16, which touches the curve at (2, 8), is the tangent there.
Evaluate a difference quotient with a small step h. The central quotient [f(x + h) − f(x − h)]/2h beats the one-sided [f(x + h) − f(x)]/h because its error shrinks like h² rather than h: for sin x at 0 with h = 0.1 it gives 0.998334 against the exact 1. A tiny h eventually fails through rounding error, so this calculator extrapolates from moderate steps instead.
The second derivative f″(x) is the rate of change of the slope, so it measures curvature: positive where the graph bends upward, negative where it bends downward. For ln x, f″(x) = −1/x², so f″(2) = −0.25. Numerically it comes from [f(x + h) − 2f(x) + f(x − h)]/h². Where f″ changes sign the graph has an inflection point.
Use y = f(x₀) + f′(x₀)(x − x₀). For f(x) = x³ at x₀ = 2, f(2) = 8 and f′(2) = 12, so y = 8 + 12(x − 2) = 12x − 16. The tangent is also the best straight-line approximation to f near x₀: it estimates 2.1³ as 8 + 12 × 0.1 = 9.2, against the exact 9.261.
The slopes from the left and the right must agree. |x| at 0 has slope −1 from the left and +1 from the right, a corner, so it has no derivative there, even though the central quotient averages to 0. A jump, or a vertical tangent such as the cube root of x at 0, also rules one out. The calculator compares one-sided quotients and reports the corner.
This calculator includes 6 worked examples with independently sourced answers. They run in the test suite, and you can run them here too.