# Derivatives and Rates of Change

Computer Science I · Calculus · https://tryals.app/learn/computer-science-i/derivatives-and-rates-of-change

## The Instantaneous Rate

The **derivative** measures how fast a function changes at one exact instant. It is the limit of **average rates of change** over shrinking intervals:

$$f'(x) = \lim_{h \to 0} \frac{f(x + h) - f(x)}{h}$$

This fraction is the slope between two points. As $h \to 0$, the points merge into the **slope of the tangent line**.

| Concept | Meaning | Real-world example |
| --- | --- | --- |
| **$f'(t)$** | Velocity | Rate position changes |
| **$f'(x) > 0$** | Increasing | Curve rises steeply |
| **$f'(x) = 0$** | Horizontal | Peak, valley, or flat |

Notation varies: $f'(x)$, $\frac{df}{dx}$, and $\frac{dy}{dx}$ all mean the same thing.

## Limits and Pitfalls

A function with a sharp corner or a jump is **not differentiable** there because the slope has no single value.

Every differentiable function is continuous, but not vice versa. A corner is continuous yet not differentiable.

> **Common pitfall:** Confusing the **derivative** (slope) with the **function value** (height). 

$f'(x)$ tells you how fast it changes, not where it sits. $f'(x) = 0$ means the function is momentarily flat, **not** that $f(x) = 0$.

## Practice questions

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

### 1. Gradient descent takes a step proportional to the derivative. Why does a learning rate that is too large make the loss increase?

A. Because the derivative changes sign when the step is too large
B. Because the loss function is undefined outside a small neighbourhood
C. Because large steps accumulate floating-point error faster
D. Because the derivative describes the slope only near the current point

**Answer:** D. Because the derivative describes the slope only near the current point

**Why:** A derivative is a statement about an infinitesimal neighbourhood, and a large step leaves the region it describes, in a narrow valley you cross the bottom and climb higher than you started. That is why learning rate is the most consequential hyperparameter, and why schedules and adaptive methods exist.

Page: https://tryals.app/practice/computer-science-i/derivatives-and-rates-of-change/gradient-descent-takes-a-step-proportional-to-the-derivative-why

### 2. A function f satisfies f(4) = 100 and f'(4) = -2. Select every statement that follows.

A. The function must cross zero near x = 4
B. The value of f is negative at x = 4
C. The function is changing slowly compared with a point where the derivative is -50
D. The function is decreasing at x = 4
E. The tangent line at x = 4 slopes downward

**Answer:** C. The function is changing slowly compared with a point where the derivative is -50; D. The function is decreasing at x = 4; E. The tangent line at x = 4 slopes downward

**Why:** A negative derivative means falling, and its small size means falling gently. Nothing about f' constrains the height: f(4) is 100, firmly positive, and at 2 units of fall per unit of x it would take about 50 units of x to reach zero.

Page: https://tryals.app/practice/computer-science-i/derivatives-and-rates-of-change/a-function-f-satisfies-f-4-100-and-f-4-2-select-every

### 3. Sort each described point by whether the function is differentiable there.

**Answer:**

- Differentiable: A smooth curve with a single well-defined tangent, A flat spot where the tangent is horizontal
- Not differentiable: A sharp corner where the slope jumps from -1 to +1, A jump discontinuity, A point where the function is undefined

**Why:** A flat spot is perfectly differentiable, with derivative zero, zero slope is not the same as no slope. Corners give two competing slopes, and jumps or gaps break continuity, which differentiability requires.

Page: https://tryals.app/practice/computer-science-i/derivatives-and-rates-of-change/sort-each-described-point-by-whether-the-function-is-differentiable

### 4. Gradient descent steps in the direction of the derivative of the loss.

**Answer:** False

**Why:** False. The gradient points *uphill*, toward increasing loss, so the step is taken in the opposite direction, which is where the minus sign in $\theta \leftarrow \theta - \eta \nabla L$ comes from. Stepping along the gradient is gradient *ascent*, which is what you want when maximising a likelihood.

Page: https://tryals.app/practice/computer-science-i/derivatives-and-rates-of-change/gradient-descent-steps-in-the-direction-of-the-derivative-of-the-loss
