Code › codeit-ai-sprint

From Average Rate of Change to Derivatives

A Codeit AI Engineer Sprint note on reviewing functions, rates of change, and the basic idea behind derivatives

Today the course moved past linear algebra and into average rate of change, instantaneous rate of change, and derivatives.

The first thing I revisited was the meaning of a function. A function describes a relationship where an input determines an output. If we have y=3x+6y = 3x + 6, then yy is determined by xx, so we can write it as f(x)=3x+6f(x) = 3x + 6.

The input does not have to be a single value. A function like f(x,y)=x+2yf(x, y) = x + 2y takes multiple inputs, and the same basic idea still holds. Inputs go in, and an output is determined.


Slope is a rate of change. In the line y=2x+1y = 2x + 1, a slope of 2 means that when xx increases by 1, yy increases by 2. If I choose two points, the slope can be calculated as the change in yy divided by the change in xx.

slope=ΔyΔx=y2y1x2x1\text{slope} = \frac{\Delta y}{\Delta x} = \frac{y_2 - y_1}{x_2 - x_1}

One small question I had was about order. Do we have to put x2x1x_2 - x_1 in the denominator? The answer is no, as long as the direction is consistent. If the denominator is x1x2x_1 - x_2, the numerator should also be y1y2y_1 - y_2.

y1y2x1x2=(y2y1)(x2x1)=y2y1x2x1\frac{y_1 - y_2}{x_1 - x_2} = \frac{-(y_2 - y_1)}{-(x_2 - x_1)} = \frac{y_2 - y_1}{x_2 - x_1}

The important part is consistency. If only one side changes direction, the sign changes. If both sides use the same direction, the slope stays the same.


A straight line has the same slope everywhere, but a curve does not. For a curve like y=x22x+1y = x^2 - 2x + 1, the steepness changes depending on where I look. So instead of one slope for the whole curve, I need the slope at a specific point, which is the slope of the tangent line.

The problem is that slope usually requires two points. To get the slope at one point, we first take two points on the curve, calculate the average rate of change, and then move the two points closer together.

average rate of change=f(b)f(a)ba\text{average rate of change} = \frac{f(b) - f(a)}{b - a}

This looked more complicated at first, but it is the same idea as Δy/Δx\Delta y / \Delta x. Since yy is written as f(x)f(x), f(b)f(b) replaces y2y_2, and f(a)f(a) replaces y1y_1.

The course then rewrote bb as a+ha + h.

f(a+h)f(a)h\frac{f(a + h) - f(a)}{h}

That substitution exists so the distance between the two points can be handled directly. If hh represents the horizontal distance between the points, bringing the two points together becomes the same as making hh approach zero. As hh gets closer to zero, the average rate of change gets closer to the instantaneous rate of change at that point.

limh0f(a+h)f(a)h\lim_{h \to 0} \frac{f(a + h) - f(a)}{h}

That is the basic idea behind differentiation. The slope at one point is not pulled out of nowhere. It is approached by shrinking the distance between two points until the average rate of change becomes the rate of change at a single point.


For f(x)=x22x+1f(x) = x^2 - 2x + 1, calculating the instantaneous rate of change at x=2x = 2 eventually gives a slope of 2. If I keep xx as a variable instead of plugging in one value, the result is 2x22x - 2. That is the derivative function, a function derived from the original function.

f(x)=x22x+1f(x) = x^2 - 2x + 1 f(x)=2x2f'(x) = 2x - 2

Once the derivative exists, I do not need to repeat the limit calculation every time. If I want the slope at x=2x = 2, I plug 2 into 2x22x - 2. If I want the slope at x=5x = 5, I plug in 5. The original function tells me values by position, and the derivative tells me rates of change by position.

The notation also became clearer. At first, df(x)dx\frac{df(x)}{dx} or df(x)dx\frac{d f(x)}{dx} looked like a symbol that appeared out of nowhere, but it is connected to the rate-of-change notation from earlier. Δx\Delta x and Δy\Delta y describe finite changes between two separated points. When the distance between those points keeps shrinking toward zero, the notation changes from Δ\Delta to dd, so dydx\frac{dy}{dx} represents an extremely small change in yy compared with an extremely small change in xx.

So dydx\frac{dy}{dx} is not just an ordinary fraction. It is notation for asking how much yy changes when xx changes by a tiny amount. df(x)dx\frac{d f(x)}{dx} follows the same idea. If the value of f(x)f(x) is treated as yy, then differentiating f(x)f(x) with respect to xx means looking at the tiny change in f(x)f(x) over the tiny change in xx.

The shortcut rule was familiar: bring the power down and reduce the power by one.

x22xx^2 \to 2x 2x2-2x \to -2 101 \to 0

The constant term disappears because its rate of change is zero. The formula explains it through x0x^0, but the intuition is simpler. Differentiation measures change, and a constant does not change.


It was more interesting than I expected to slow down and clean up something I had passed over vaguely before.