# Differentiation Rules

Computer Science I · Calculus · https://tryals.app/learn/computer-science-i/differentiation-rules

## ## Basic Differentiation Rules

Instead of evaluating limits every time, **differentiation rules** compute derivatives mechanically through algebra.

| Rule | Formula | Example |
| --- | --- | --- |
| **Power rule** | $\frac{d}{dx} x^n = n x^{n-1}$ | $\frac{d}{dx} x^3 = 3x^2$ |
| **Constant multiple** | $\frac{d}{dx}(c f) = c f'$ | Constants factor out |
| **Sum rule** | $(f + g)' = f' + g'$ | Sum of derivatives |

Standard derivatives round out the toolkit: $\frac{d}{dx} e^x = e^x$, $\frac{d}{dx} \ln x = \frac{1}{x}$, and $\frac{d}{dx} \sin x = \cos x$.

## ## Combination & Chain Rules

Combining functions requires precise rules, especially for products and compositions.

| Combination Rule | Formula | Key Distinction |
| --- | --- | --- |
| **Product rule** | $(fg)' = f'g + fg'$ | Not the product of derivatives |
| **Quotient rule** | $(f/g)' = \frac{f'g - fg'}{g^2}$ | Note the minus sign & order |
| **Chain rule** | $[f(g(x))]' = f'(g(x)) \cdot g'(x)$ | Outer times inner derivative |

> **Common pitfall:** Forgetting the **chain rule** inner derivative. $\frac{d}{dx}\sin(x^2) = \cos(x^2) \cdot 2x$, not just $\cos(x^2)$. Omitting $g'(x)$ is the #1 mistake.

## Practice questions

4 of this lesson's 10 practice questions, with answers. The full set is in the app.

### 1. Backpropagation is efficient because it reuses each layer's intermediate derivative instead of recomputing it for every weight.

**Answer:** True

**Why:** True. The chain rule applied naively would recompute the same partial products once per weight; backpropagation sweeps backward once, caching each layer's error signal and reusing it for every weight feeding that layer. It is dynamic programming on the computation graph, which is what makes training large networks feasible.

Page: https://tryals.app/practice/computer-science-i/differentiation-rules/backpropagation-is-efficient-because-it-reuses-each-layers

### 2. Select every derivative below that is computed CORRECTLY.

A. The derivative of (2x + 5)^3 is 6(2x + 5)^2
B. The derivative of a constant is that constant
C. The derivative of x times e^x is e^x
D. The derivative of x^4 is 4x^3
E. The derivative of 5x^2 is 10x

**Answer:** A. The derivative of (2x + 5)^3 is 6(2x + 5)^2; D. The derivative of x^4 is 4x^3; E. The derivative of 5x^2 is 10x

**Why:** The product rule gives (x e^x)' = e^x + x e^x, not e^x alone, and the derivative of a constant is 0. The composition (2x + 5)^3 correctly picks up the inner factor 2, giving 3(2x + 5)^2 times 2 = 6(2x + 5)^2.

Page: https://tryals.app/practice/computer-science-i/differentiation-rules/select-every-derivative-below-that-is-computed-correctly

### 3. Automatic differentiation computes exact derivatives of a program without symbolic algebra and without finite differences. What makes that possible?

A. Numerical approximation with a very small step size
B. Sampling the function at many points and fitting a curve
C. Symbolic manipulation of the source code before compilation
D. The chain rule applied mechanically to elementary operations

**Answer:** D. The chain rule applied mechanically to elementary operations

**Why:** Every operation has a known derivative and the chain rule composes them, so the derivative is computed exactly to machine precision alongside the value, no step size, no symbolic blowup. It is what PyTorch and JAX do, and why backpropagation is a special case rather than a separate invention.

Page: https://tryals.app/practice/computer-science-i/differentiation-rules/automatic-differentiation-computes-exact-derivatives-of-a-program

### 4. Complete the chain rule applied to a specific composition.

**Answer:** The derivative of sin(x^2) is **cos(x^2) times 2x**.

**Why:** The outer derivative gives cos(x^2) and the inner derivative contributes a factor of 2x. Answering cos(x^2) alone is exactly the omission the lesson warns about, and differentiating inside the cosine to get cos(2x) misapplies the rule at the wrong level.

Page: https://tryals.app/practice/computer-science-i/differentiation-rules/complete-the-chain-rule-applied-to-a-specific-composition
