Skip to content
Tutorials Center
My learning

Topics

Lesson 8 of 68 ยท Derivatives

Differentiation Rules

Learn the power, sum, product and quotient rules with a table of standard derivatives, and check every answer with sympy diff() and a numeric test.

Computing a derivative from the limit definition works, but it is slow. Nobody wants to expand ((x + h)^7 - x^7) / h every time. Mathematicians proved a small set of differentiation rules once, and since then every derivative of an everyday formula has been a matter of applying those rules in the right order.

This lesson covers the four rules that handle most polynomials and rational functions: power, sum (with constant multiples), product and quotient. You will also see how to confirm your hand work with sympy.diff and with a quick numeric check. The next lesson adds the chain rule, and the one after it handles exponentials, logs and trig. If the definition itself is new to you, start with The Derivative as a Rate of Change.

The power rule

For any real number n:

TEXT
d/dx (x^n) = n * x^(n-1)

Bring the exponent down as a multiplier, then lower the exponent by one. So x^5 becomes 5x^4, and x^2 becomes 2x, matching what we found from the definition. The rule also works for negative and fractional powers if you rewrite first:

  • 1/x^3 = x^(-3), so the derivative is -3x^(-4) = -3/x^4.
  • sqrt(x) = x^(1/2), so the derivative is (1/2)x^(-1/2) = 1 / (2 sqrt(x)).
  • A constant is x^0 times a number, and its derivative is 0: constants do not change.

Constant multiples and sums

Differentiation is linear. Two facts follow:

TEXT
d/dx (c * f(x)) = c * f'(x)
d/dx (f(x) + g(x)) = f'(x) + g'(x)

You can pull a constant factor outside, and you can differentiate a sum term by term (differences too). Together with the power rule, this handles every polynomial:

TEXT
d/dx (4x^3 - 7x^2 + 5x - 9) = 12x^2 - 14x + 5
Python Polynomials with sympy

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

sp.diff(expr, x) differentiates with respect to x; adding a count (sp.diff(p, x, 2)) takes the derivative twice. The slope at x = 2 is 12*4 - 14*2 + 5 = 25, which you can confirm by hand.

The product rule

The derivative of a product is not the product of the derivatives. Instead:

TEXT
d/dx (f * g) = f' * g + f * g'

Differentiate the first factor and keep the second, then keep the first and differentiate the second, and add. Try x^2 * (3x + 1). Here f = x^2, g = 3x + 1, so f' = 2x and g' = 3:

TEXT
(2x)(3x + 1) + (x^2)(3) = 6x^2 + 2x + 3x^2 = 9x^2 + 2x

You can check this another way: expand first to get 3x^3 + x^2, then use the power rule to get 9x^2 + 2x. Same answer, so expanding is a legitimate shortcut when the product is simple. The product rule earns its keep when expanding is awkward, and later when one factor is something like sin x.

The quotient rule

For a ratio:

TEXT
d/dx (f / g) = (f' * g - f * g') / g^2

The numerator has a minus sign, so order matters: it is "low d-high minus high d-low, over low squared" if you like mnemonics (where "low" is the denominator). For (x^2 + 1) / (x - 2):

TEXT
f = x^2 + 1, f' = 2x      g = x - 2, g' = 1
((2x)(x - 2) - (x^2 + 1)(1)) / (x - 2)^2
= (2x^2 - 4x - x^2 - 1) / (x - 2)^2
= (x^2 - 4x - 1) / (x - 2)^2

Before using the quotient rule, check whether you can simplify first. (x^3 + x) / x is just x^2 + 1, with derivative 2x. Dividing out first is quicker and less error-prone.

flowchart TD
    S["Expression to differentiate"] --> Q{"What is the<br/>top-level shape?"}
    Q -->|"sum or constant multiple"| L["Differentiate term by term"]
    Q -->|"product f * g"| P["Product rule"]
    Q -->|"ratio f / g"| R["Quotient rule"]
    Q -->|"power of x"| W["Power rule"]
    Q -->|"function inside a function"| C["Chain rule (next lesson)"]

Look at the outermost operation first; it tells you which rule to apply.

Standard derivatives to remember

Beyond powers, a handful of derivatives are worth memorising. You will see how to derive most of them in the lesson on exponentials, logs and trig.

Function Derivative
constant c 0
x^n n x^(n-1)
e^x e^x
a^x a^x ln a
ln x 1/x
sin x cos x
cos x -sin x
tan x sec^2 x

Verifying by hand and by machine

A good habit: derive by hand, then let the computer judge. There are two independent checks.

  1. Symbolic: sympy.simplify(your_answer - sp.diff(f, x)) should be 0.
  2. Numeric: compare your formula with a central finite difference at a few points. If they agree to several digits, your rule application is almost surely right.
Python Check a product and a quotient rule answer

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The first two lines print 0, so both hand answers match. The third shows what happens when you wrongly multiply the derivatives of the factors: a non-zero leftover. The numeric slope and formula slope agree to many digits, which is a reassuring second opinion.

Common slips

  • Forgetting that a constant disappears: the derivative of x^2 + 7 is 2x, not 2x + 7.
  • Multiplying derivatives in a product: use f'g + fg', never f'g'.
  • Swapping the quotient numerator: it is f'g - fg', and swapping the order flips the sign of your answer.
  • Treating a^x like a power: x^3 and 3^x look alike but follow different rules. The variable is in the base for one and in the exponent for the other.
Python Rules in motion: a projectile

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The velocity 20 - 10t is zero at t = 2, the moment the ball stops rising, and the height then is 22 m. This is a preview of how derivatives locate maxima, which you will use in Applications of Derivatives.

Check your understanding

Quick check ยท 5 questions

of 5 answered You scored / 5 ยท perfect!

  1. 1. What is the derivative of 5x^4 - 3x + 8?

    Apply the power rule term by term: 5x^4 gives 20x^3, -3x gives -3, and the constant 8 gives 0.
  2. 2. Which is the correct product rule for d/dx (f * g)?

    The product rule adds two terms: the derivative of the first times the second, plus the first times the derivative of the second.
  3. 3. What is the derivative of 1/x^2 written as a power?

    Rewrite 1/x^2 as x^(-2). The power rule gives -2 * x^(-3), which equals -2/x^3.
  4. 4. In the quotient rule (f/g)' = (f'g - fg') / g^2, what happens if you swap the two terms in the numerator?

    Subtraction is not commutative: fg' - f'g is the negative of f'g - fg', so a swap gives the wrong sign.
  5. 5. How can you gain confidence that a hand-computed derivative is correct?

    Two independent checks, a symbolic comparison with sympy and a numeric central difference at a few points, catch nearly all rule-application slips.

Summary

  • The power rule: d/dx x^n = n x^(n-1); constants differentiate to 0.
  • Derivatives are linear: pull out constants and differentiate sums term by term.
  • Product rule: (fg)' = f'g + fg'. Quotient rule: (f/g)' = (f'g - fg') / g^2.
  • Simplify or expand first when it makes the problem easier.
  • Confirm answers with sympy.diff and a numeric central difference.

Next, handle functions nested inside other functions with The Chain Rule.