18. Power, constant-multiple, and sum rules

📖 Reading · 13 min
💡 Every code box below is live — edit it and hit Run.

Computing every derivative from the definition is possible and unbearable. The rules in this lesson replace the limit with pattern-matching, and between them they handle every polynomial in one pass.

They are theorems, not conventions. Each is proved from the definition, and the proofs are short enough to be worth reading once.

The power rule

\frac{d}{dx}x^n = nx^{n-1}

Proof for positive integers. Expand (x+h)^n with the binomial theorem:

(x+h)^n = x^n + nx^{n-1}h + \binom{n}{2}x^{n-2}h^2 + \cdots + h^n

Subtract x^n — that cancels the leading term — and divide by h:

\frac{(x+h)^n - x^n}{h} = nx^{n-1} + \binom{n}{2}x^{n-2}h + \cdots + h^{n-1}

Every term after the first still carries a factor of h, so every one of them vanishes as h \to 0:

\frac{d}{dx}x^n = nx^{n-1} \qquad\blacksquare

The rule holds for every real exponent, not just positive integers:

\frac{d}{dx}x^{-3} = -3x^{-4}, \qquad \frac{d}{dx}x^{1/2} = \tfrac12 x^{-1/2}, \qquad \frac{d}{dx}x^{\pi} = \pi x^{\pi-1}

The binomial proof only covers integers; negative exponents need the quotient rule (§2.3), rational ones need implicit differentiation (§2.9), and irrational ones need logarithmic differentiation (§2.6). All three arrive shortly. Use the rule now — it's true — and watch the proof get completed.

Two special cases fall straight out:

\frac{d}{dx}x = 1x^0 = 1, \qquad \frac{d}{dx}c = 0

The second because a constant is cx^0, or more honestly because a constant function has difference quotient \frac{c-c}{h} = 0 identically.

Constant multiple and sum

\frac{d}{dx}\left[cf(x)\right] = c f'(x), \qquad \frac{d}{dx}\left[f(x) \pm g(x)\right] = f'(x) \pm g'(x)

Both come directly from the corresponding limit laws in §1.1. For the sum:

\frac{[f(x+h)+g(x+h)] - [f(x)+g(x)]}{h} = \frac{f(x+h)-f(x)}{h} + \frac{g(x+h)-g(x)}{h}

and the limit of a sum is the sum of the limits.

Together these say differentiation is linear, which is the single most important structural fact about it. It's why \frac{d}{dx} behaves like a matrix acting on a vector space of functions, why the Laplace transform in §13.9 plays nicely with it, and why neural network gradients decompose the way they do.

Polynomials, in one pass

\frac{d}{dx}\left(4x^5 - 7x^3 + 2x - 9\right) = 20x^4 - 21x^2 + 2

Term by term, power rule on each, constants along for the ride. The constant -9 vanishes. Every polynomial derivative you will ever take works exactly like this, and the degree drops by one each time.

The mistake everyone makes once

There is no product rule of the naive kind.

\frac{d}{dx}\left[f(x)g(x)\right] \neq f'(x)g'(x)

Test it on something you can verify: f(x) = g(x) = x. The product is x^2, whose derivative is 2x. The product of derivatives is 1 \cdot 1 = 1. Not equal, not even close.

Same for quotients. The correct rules are the next lesson, and they're the reason that lesson exists.

Linearity applies to sums and constant multiples only. That's a real restriction, not an oversight.

Rewrite before you differentiate

The power rule wants a power. Much of the work in practice is putting the expression into that shape first.

As written Rewritten Derivative
\sqrt x x^{1/2} \frac12 x^{-1/2} = \frac{1}{2\sqrt x}
\frac{1}{x^3} x^{-3} -3x^{-4} = -\frac{3}{x^4}
\frac{1}{\sqrt[3]{x}} x^{-1/3} -\frac13 x^{-4/3}
\frac{x^3+2x}{x} x^2 + 2 2x
x^2\sqrt x x^{5/2} \frac52 x^{3/2}

The fourth row deserves attention: dividing through first turns a quotient into a sum, and dodges the quotient rule entirely. Always check whether the algebra simplifies before reaching for heavier machinery — it usually does, and the resulting derivative is much easier to get right.

Doing it in Python

Every rule, checked numerically:

from math import sqrt

def numerical(f, x, h=1e-6):
    """Central difference -- more accurate than the one-sided version (see 3.8)."""
    return (f(x + h) - f(x - h)) / (2 * h)

cases = [
    ("x^5",        lambda x: x**5,        lambda x: 5 * x**4),
    ("x^-3",       lambda x: x**-3,       lambda x: -3 * x**-4),
    ("x^(1/2)",    sqrt,                  lambda x: 0.5 * x**-0.5),
    ("4x^5-7x^3+2x-9", lambda x: 4*x**5 - 7*x**3 + 2*x - 9,
                       lambda x: 20*x**4 - 21*x**2 + 2),
]

x = 2.0
print(f"{'f':>18} {'numerical':>14} {'rule':>14} {'match':>8}")
for name, f, df in cases:
    n, r = numerical(f, x), df(x)
    print(f"{name:>18} {n:>14.8f} {r:>14.8f} {abs(n - r) < 1e-5!s:>8}")

The false product rule, refuted:

def numerical(f, x, h=1e-6):
    return (f(x + h) - f(x - h)) / (2 * h)

f = lambda x: x
g = lambda x: x
fg = lambda x: f(x) * g(x)

x = 3.0
print(f"d/dx [f*g] at x={x}     : {numerical(fg, x):.6f}")
print(f"f'(x) * g'(x)           : {numerical(f, x) * numerical(g, x):.6f}")
print(f"the correct product rule: {numerical(f, x)*g(x) + f(x)*numerical(g, x):.6f}")
print("\nthe naive version is simply wrong. next lesson has the real one.")

The power rule holds for exponents the binomial proof can't reach:

import sympy as sp

x = sp.Symbol('x', positive=True)
for n in (5, -3, sp.Rational(1, 2), sp.Rational(-2, 3), sp.pi, sp.sqrt(2)):
    print(f"d/dx x^({n})  =  {sp.simplify(sp.diff(x**n, x))}")

print("\nsympy agrees with n*x^(n-1) for integer, negative, rational and irrational n")

Repeated differentiation walks a polynomial down to nothing:

import sympy as sp

x = sp.Symbol('x')
p = 4*x**5 - 7*x**3 + 2*x - 9

for k in range(7):
    print(f"d^{k}/dx^{k}: {sp.diff(p, x, k)}")

print("\ndegree drops by one each time; after 6 derivatives a quintic is gone")

Worked example

Differentiate f(x) = \dfrac{3x^4 - 2\sqrt x + 5}{x^2}.

Do not reach for the quotient rule. Split the fraction first — the denominator is a single power, so every term divides cleanly:

f(x) = \frac{3x^4}{x^2} - \frac{2x^{1/2}}{x^2} + \frac{5}{x^2} = 3x^2 - 2x^{-3/2} + 5x^{-2}

Now it's three power-rule terms:

f'(x) = 3(2x) - 2\left(-\tfrac32 x^{-5/2}\right) + 5(-2x^{-3})

= 6x + 3x^{-5/2} - 10x^{-3}

Back into radical form if you prefer:

f'(x) = 6x + \frac{3}{x^{5/2}} - \frac{10}{x^3}

Check one value numerically. At x = 1: f'(1) = 6 + 3 - 10 = -1. And f(x) near 1: f(1) = 3 - 2 + 5 = 6, f(1.001) \approx 5.999 — decreasing, so a negative slope of about -1 ✓.

The exponent arithmetic in the middle term is where this goes wrong most often. \frac{x^{1/2}}{x^2} = x^{1/2 - 2} = x^{-3/2}, and differentiating gives -\frac32 x^{-5/2}; the two minus signs then combine into a plus. Write the exponents out rather than doing them in your head.

Your turn

1. \dfrac{d}{dx}\left(7x^3 - \dfrac{4}{x} + \sqrt[3]{x}\right)

2. Find the tangent line to y = x^3 - 3x at x = 2.

3. Where is the tangent to y = x^3 - 3x horizontal?

4. \dfrac{d}{dx}\left(\dfrac{x^5 - x^2}{x^3}\right) — two ways, and check they agree.

Solutions

1. Rewrite each term as a power first:

7x^3 - 4x^{-1} + x^{1/3}

Then term by term:

\boxed{21x^2 + 4x^{-2} + \tfrac13 x^{-2/3}} = 21x^2 + \frac{4}{x^2} + \frac{1}{3\sqrt[3]{x^2}}

Note the middle sign: \frac{d}{dx}(-4x^{-1}) = -4 \cdot (-1)x^{-2} = +4x^{-2}. Two negatives.

2. Point: y(2) = 8 - 6 = 2, so (2,2).

Slope: y' = 3x^2 - 3, so y'(2) = 12 - 3 = 9.

y - 2 = 9(x-2) \implies \boxed{y = 9x - 16}

3. Horizontal tangent means slope zero:

3x^2 - 3 = 0 \implies x^2 = 1 \implies x = \pm1

The points are (1, -2) and (-1, 2). These are the local minimum and local maximum of the cubic — §3.5 turns this observation into a systematic method, and §3.7 uses it to optimize.

4. Way one — simplify first.

\frac{x^5-x^2}{x^3} = x^2 - x^{-1} \implies \frac{d}{dx} = 2x + x^{-2}

Way two — quotient rule (§2.3, previewed):

\frac{(5x^4-2x)(x^3) - (x^5-x^2)(3x^2)}{x^6} = \frac{5x^7 - 2x^4 - 3x^7 + 3x^4}{x^6} = \frac{2x^7 + x^4}{x^6}

= 2x + x^{-2} \quad\checkmark

Same answer, roughly four times the work and four times the opportunity for a sign error. Simplify first is not a stylistic preference.

Check yourself in code

Verify the power rule against numerical differentiation for a range of exponents.

For n \in \{5, -3, 0.5, -2/3, 2\}, evaluate \frac{d}{dx}x^n at x = 2 both ways: the central difference \frac{f(x+h)-f(x-h)}{2h} with h = 10^{-6}, and the rule nx^{n-1}. Print both to 8 decimals and whether they agree to within 10^{-5}.

Print exactly this:

n=5        numeric 80.00000000  rule 80.00000000  match=True
n=-3       numeric -0.18750000  rule -0.18750000  match=True
n=0.5      numeric 0.35355339  rule 0.35355339  match=True
n=-0.6667  numeric -0.20998684  rule -0.20998684  match=True
n=2        numeric 4.00000000  rule 4.00000000  match=True
x, h = 2.0, 1e-6

for n in (5, -3, 0.5, -2/3, 2):
    numeric = ((x + h) ** n - (x - h) ** n) / (2 * h)
    # apply the power rule and compare
    print(f"n={round(n, 4):<8} ...")
x, h = 2.0, 1e-6

for n in (5, -3, 0.5, -2/3, 2):
    numeric = ((x + h) ** n - (x - h) ** n) / (2 * h)
    rule = n * x ** (n - 1)
    print(f"n={round(n, 4):<8} numeric {numeric:.8f}  rule {rule:.8f}  "
          f"match={abs(numeric - rule) < 1e-5}")

\frac{d}{dx}x^n = nx^{n-1} for every real n, proved here by the binomial theorem for positive integers and completed later for the rest. Differentiation is linear — it passes through sums and pulls out constants — but that is all it passes through: the derivative of a product is emphatically not the product of the derivatives. Rewrite roots and reciprocals as powers, and divide out denominators, before differentiating.

Next: what actually happens with products and quotients.