Mathematics RU

Solver

Derivative calculator with step-by-step explanations

Type a function, and the solver finds its derivative by the same rules you’d use on paper, explains every step, simplifies the answer, checks it numerically and shows a tangent line you can slide along the graph.

Loading the solver…

What you can type

Write the function the way you would in an exercise book: x^2 sin x, e^(-x^2), ln(cos x), (x+1)/(x-1). You can leave out the multiplication sign between a number and a letter; a square root is sqrt(x) or √x, an absolute value is |x| or abs(x), a tangent is tan x (tg x works too). You can start with “f(x) =” or “y =”, and you can add the words “find the derivative of”: the solver skips them.

For a second or third derivative, add primes: (sin 2x)'', or say it in words: “second derivative of x^3 ln x”, “5th derivative of e^(2x)”. For the value at a point, add a comma: f(x) = x^3 - 3x, f'(2), or “… at x = 2”. For the equation of a tangent line: “tangent to y = x^2 at x = 1”, and for a normal: “normal to y = √x at x = 4”. If the function contains other letters, the solver treats them as constants; “with respect to y” or d/dy makes it a partial derivative.

How to find a derivative

Derivatives are almost never computed from the definition. They’re assembled from three things: a table of derivatives of simple functions, rules for sums, products and quotients, and the chain rule for composite functions. You work from the top down, from the last operation to the first.

1. Find the last operation. In $x^2 \sin x$ the last thing done is multiplication, so you need the product rule. In $\ln(\cos x)$ the last step is taking the logarithm of something: it’s a composite function. In $\frac{x^2 + 1}{x - 1}$ it’s division.

2. Apply the right rule.

  • Sum: $(u + v)' = u' + v'$, and a constant factor comes out: $(c\,u)' = c\,u'$.
  • Product: $(uv)' = u'v + uv'$.
  • Quotient: $\left(\dfrac{u}{v}\right)' = \dfrac{u'v - uv'}{v^2}$.
  • Composite function: $\bigl(f(g(x))\bigr)' = f'(g(x)) \cdot g'(x)$, the derivative of the outer function with the inner one plugged in, times the derivative of the inner one.

3. Go one level down. After applying a rule you’re left with derivatives of the pieces: $u'$, $v'$, $g'$. Treat each piece the same way until you reach functions from the table.

4. Simplify and check. Expand brackets, put things over a common denominator, cancel. The easiest way to check the answer is numerically: the slope of a secant through two nearby points of the graph should almost match the value of the derivative. That’s what the solver does, at three points.

FunctionDerivative
$x^n$$n x^{n-1}$
$\sqrt{x}$$\dfrac{1}{2\sqrt{x}}$
$e^x$$e^x$
$a^x$$a^x \ln a$
$\ln x$$\dfrac{1}{x}$
$\log_a x$$\dfrac{1}{x \ln a}$
$\sin x$$\cos x$
$\cos x$$-\sin x$
$\tan x$$\dfrac{1}{\cos^2 x}$
$\cot x$$-\dfrac{1}{\sin^2 x}$
$\arcsin x$$\dfrac{1}{\sqrt{1 - x^2}}$
$\arctan x$$\dfrac{1}{1 + x^2}$

Why it works

The derivative is the slope of the graph at a point. Take two points on the graph, with $x$-coordinates $x$ and $x + h$, and draw a straight line through them, a secant. Its slope is the ratio of the increments, and as the second point creeps up to the first, the secant turns into the tangent:

The step along the $x$-axis: how far we moved to the right. It tends to zero but never becomes zero, or there’d be nothing to divide by. The increment of the function: how far the graph rose or fell over that step. Example: $f(x) = x^2$ at $x = 3$. With $h = 0.01$ we get $\frac{3.01^2 - 9}{0.01} = \frac{0.0601}{0.01} = 6.01$, and with $h = 0.001$ already $6.001$. The ratio approaches $6 = 2 \cdot 3$, just as the formula $(x^2)' = 2x$ promises.

All the rules follow from this definition. The product rule becomes obvious if you picture $u \cdot v$ as the area of a rectangle with sides $u$ and $v$. When $x$ changes a little, the sides grow by $\Delta u$ and $\Delta v$, and the area grows by two strips, $u\,\Delta v$ and $v\,\Delta u$, plus a tiny corner $\Delta u\,\Delta v$. After dividing by $h$, the strips give $uv' + u'v$, and the corner, a product of two small quantities, vanishes in the limit.

The chain rule is about gear ratios. If $g$ stretches small segments near $x$ by a factor of $g'(x)$, and $f$ stretches segments near $g(x)$ by a factor of $f'(g(x))$, then together they stretch by the product of these factors, like two pairs of gears. That’s why a three appears in $(\sin 3x)' = 3\cos 3x$: the inner function $3x$ itself changes three times as fast as $x$.

Worked examples

Example 1. A product: $y = x^2 \sin x$

The last operation is multiplication, with $u = x^2$ and $v = \sin x$. From the table, $u' = 2x$ and $v' = \cos x$. By the product rule,

$$y' = 2x \cdot \sin x + x^2 \cdot \cos x = 2x \sin x + x^2 \cos x.$$

A check at $x = 1$: the formula gives $2 \sin 1 + \cos 1 \approx 1.6829 + 0.5403 = 2.2232$, and the slope of the secant through $x = 0.999$ and $x = 1.001$ is also $2.2232$ to four decimal places.

Example 2. A quotient: $y = \dfrac{x^2 + 1}{x - 1}$

The numerator is $u = x^2 + 1$, $u' = 2x$; the denominator is $v = x - 1$, $v' = 1$. By the quotient rule,

$$y' = \frac{2x(x - 1) - (x^2 + 1) \cdot 1}{(x - 1)^2} = \frac{2x^2 - 2x - x^2 - 1}{(x - 1)^2} = \frac{x^2 - 2x - 1}{(x - 1)^2}.$$

Don’t expand the denominator: in this form you can see that the derivative fails to exist only at $x = 1$, where the function itself isn’t defined. The numerator vanishes at $x = 1 \pm \sqrt2$: there the tangent is horizontal, and these are the turning points.

Example 3. A composite function: $y = \ln(\cos x)$

The outer function is the logarithm, the inner one is $u = \cos x$. The derivative of the logarithm is $\frac{1}{u}$, the derivative of the inner function is $-\sin x$, and their product is

$$y' = \frac{1}{\cos x} \cdot (-\sin x) = -\tan x.$$

A common mistake is to write $\frac{1}{\cos x}$ and stop. The factor $-\sin x$ is precisely the “derivative of the inner function” from the chain rule.

Example 4. The variable in both the base and the exponent: $y = x^x$

Neither the power rule works here (the exponent isn’t constant) nor the rule for exponential functions (the base isn’t constant). The logarithm comes to the rescue: $x^x = e^{x \ln x}$, and by the chain rule

$$y' = e^{x \ln x} \cdot (x \ln x)' = x^x \left(\ln x + x \cdot \frac{1}{x}\right) = x^x (\ln x + 1).$$

This technique is called logarithmic differentiation. It also helps with $(\sin x)^{\cos x}$ and with cumbersome products, where the logarithm turns multiplication into addition.

The value at a point and the tangent line

To find $f'(2)$, first find the derivative as a function, then substitute the number. The order matters: if you put two into $f$ first, you get a number, and the derivative of a number is zero. For $f(x) = x^3 - 3x$ we get $f'(x) = 3x^2 - 3$ and $f'(2) = 3 \cdot 4 - 3 = 9$.

The value of the derivative is the gradient of the tangent, so the equation of the tangent at $x_0$ can be written down at once:

$$y = f(x_0) + f'(x_0)\,(x - x_0).$$

For $y = x^2$ at $x_0 = 1$: $f(1) = 1$, $f'(x) = 2x$, $f'(1) = 2$, and the tangent is $y = 1 + 2(x - 1) = 2x - 1$. The normal is perpendicular to the tangent, with gradient $-\frac{1}{f'(x_0)}$; if the tangent is horizontal, the normal is vertical: $x = x_0$.

Sometimes a function exists at a point but its derivative doesn’t. $y = |x|$ has a corner at zero: the slope is $-1$ on the left and $1$ on the right, and there’s no single tangent. $y = \sqrt[3]{x}$ has a vertical tangent at zero, and the derivative is infinite. The solver finds such points and mentions them under the answer.

Common mistakes

  • Taking the derivative of a product to be the product of the derivatives. $(x^2 \sin x)' \ne 2x \cos x$. The right form is $u'v + uv'$: in each term only one factor is differentiated.
  • Forgetting the derivative of the inner function. $(\sin 3x)' = 3\cos 3x$, not $\cos 3x$; $(e^{-x^2})' = -2x\,e^{-x^2}$, not $e^{-x^2}$.
  • Mixing up the order in the numerator of the quotient rule. First $u'v$, then minus $uv'$. Swap them and the sign of the answer flips.
  • Using the power rule when the variable is in the exponent. $(2^x)' = 2^x \ln 2$, not $x \cdot 2^{x - 1}$; for $x^x$ neither rule works on its own.
  • The derivative of a constant. $(e^2)' = 0$ and $(\ln 5)' = 0$: these are numbers, even though they’re written with letters. But $(\pi^x)' = \pi^x \ln \pi$ and $(x^\pi)' = \pi x^{\pi - 1}$.
  • Substituting the number too early. $f'(2)$ is the value of the derivative at a point, not the derivative of $f(2)$.
  • “Finding” a derivative where there isn’t one. The formula $(\sqrt x)' = \frac{1}{2\sqrt x}$ holds only for $x > 0$; at zero the function is defined, but the derivative isn’t.

See also

Where the rules come from, how a secant becomes a tangent and why the derivative of sine is cosine are in the chapter on the derivative: it has a growing rectangle for the product rule, a gearbox for the chain rule and implicit differentiation. The derivative itself is defined through a limit; see the chapter on limits and the limit solver. Where a function increases, where it has a maximum and what its graph looks like is shown by curve sketching; the reverse problem, finding a function from its derivative, is the integral. For practice, try the derivatives trainer.

Where this is explained

Other solvers