TensorTau PathToAGI Mathematics of Change Level 02

Level 02 · Mathematics of Change · Chapter 017

Functions and Slopes

How can we describe not just a quantity is, but ?

Where We Are

Up to this point, most of our mathematics described structure.

Vectors told us how to represent many numbers together.

Matrices told us how to transform vectors.

Eigenvectors and SVD told us which directions matter inside a transformation.

PCA told us which directions matter inside data.

But learning is not only about structure.

Learning is about change.

When a parameter moves, the prediction changes.

When the prediction changes, the loss changes.

If we want a machine to improve itself, we need a mathematical language for questions like:

If I increase this input a little, what happens to the output?

Is the output rising or falling?

Is it changing slowly or rapidly?

Does the rate of change stay constant, or does it itself change?

Those questions begin with two ideas that look simple but will power the entire rest of deep learning:

functions and slopes.


1. The Problem: A Table of Answers Is Not Yet a Rule

Return to the house-pricing story.

Suppose we observe:

RoomsPrice (₹ lakh)
13
25
37
49

We can store the table.

But in Chapter 001 we wanted something more powerful than memorization.

We wanted a rule:

y^=2x+1.\hat y = 2x + 1.

This rule does something important.

It accepts an input and produces an output.

If

x=3,x=3,

then

y^=2(3)+1=7.\hat y=2(3)+1=7.

If

x=10,x=10,

then

y^=21.\hat y=21.

The rule is a machine that maps one number to another.

Mathematics gives such a machine a name:

a function.


2. A Function Is a Relationship, Not a Formula Shape

We often write

y=f(x).y=f(x).

Read this as:

“yy is the output produced by the function ff when the input is xx.”

The symbol ff is not multiplication.

It is a name for a rule.

For example,

f(x)=2x+1.f(x)=2x+1.

Then

f(3)=7.f(3)=7.

Another function could be

g(x)=x2.g(x)=x^2.

Then

g(3)=9.g(3)=9.

Another could be

h(x)=max⁡(0,x).h(x)=\max(0,x).

That one will later become ReLU.

The important idea is not the formula.

It is the mapping:

input  →  rule  →  output

3. Functions as Machines

A useful mental model is a box.

      ┌───────────────┐
 x ──▶│   function f  │──▶ f(x)
      └───────────────┘

For

f(x)=2x+1,f(x)=2x+1,

the box performs:

input x
   ↓
multiply by 2
   ↓
add 1
   ↓
output

So for x=4x=4:

4 → 8 → 9

That is already the seed of a computational graph.

Later, neural networks will simply be much larger function boxes made from many smaller operations.


4. Inputs and Outputs Have Meaning and Units

Suppose

f(x)=2x+1f(x)=2x+1

models house price.

Here:

  • xx = rooms,
  • f(x)f(x) = price in ₹ lakh.

The number 2 therefore has units:

2 lakhroom.2\ \frac{\text{lakh}}{\text{room}}.

This matters.

A slope is not merely “2.”

It tells us how much output changes per unit input.

Unit awareness is one of the easiest ways to catch nonsense mathematics.

If the input is seconds and the output is metres, slope has units metres per second.

If the input is weight and the output is loss, slope has units loss per unit weight.


5. A Graph Is a Picture of a Function

A function can be represented in several equivalent ways.

Rule

f(x)=2x+1f(x)=2x+1

Table

xxf(x)f(x)
01
13
25
37

Graph

f(x)
 ↑
 9|                •
 7|            •
 5|        •
 3|    •
 1|•
 0+----------------------→ x
    0   1   2   3   4

The graph is not decoration.

It lets us see change.

A steeply rising graph means output changes quickly as input increases.

A flat graph means output barely changes.

A falling graph means output decreases as input increases.


6. The First Question About Change

Suppose we move from

x=1x=1

to

x=4.x=4.

For

f(x)=2x+1,f(x)=2x+1,

output moves from

f(1)=3f(1)=3

to

f(4)=9.f(4)=9.

Input change:

Δx=4−1=3.\Delta x=4-1=3.

Output change:

Δy=9−3=6.\Delta y=9-3=6.

The Greek letter Δ\Delta means “change in.”

So

Δx\Delta x

means change in x,

and

Δy\Delta y

means change in y.

Now ask:

How much output change occurred per unit input change?

Compute

ΔyΔx=63=2.\frac{\Delta y}{\Delta x} = \frac{6}{3} =2.

That number is the slope between the two points.


7. The Slope Formula

For two points

(x1,y1)(x_1,y_1)

and

(x2,y2),(x_2,y_2),

slope is

slope=y2−y1x2−x1\boxed{ \text{slope} = \frac{y_2-y_1}{x_2-x_1} }

or more compactly,

slope=ΔyΔx\boxed{ \text{slope} = \frac{\Delta y}{\Delta x} }

Read it literally:

change in output divided by change in input.


8. Rise Over Run

Geometry gives a second interpretation.

 y
 ↑
 9|                 • B
 8|                /|
 7|               / |
 6|              /  | rise = 6
 5|             /   |
 4|            /    |
 3|    • A----+     |
 2|      run = 3
 1|
 0+----------------------→ x

Moving from A to B:

  • horizontal movement = run,
  • vertical movement = rise.

So

slope=riserun.\text{slope} = \frac{\text{rise}}{\text{run}}.

This is the same mathematics as rate of change.

Geometry and units are telling the same story.


9. Positive, Negative, Zero and Steep Slopes

Positive slope

m>0m>0

means output rises as input increases.

 /
/

Negative slope

m<0m<0

means output falls as input increases.

\
 \

Zero slope

m=0m=0

means output does not change.

──────

Larger magnitude

Compare

m=1m=1

with

m=10.m=10.

The second changes ten output units per input unit.

So slope carries two kinds of information:

  • sign → direction of change,
  • magnitude → speed/strength of change.

This exact interpretation will later become the meaning of a gradient.


10. Why Linear Functions Are Easy

Consider

f(x)=2x+1.f(x)=2x+1.

Take any two points.

From x=0x=0 to x=1x=1:

3−11−0=2.\frac{3-1}{1-0}=2.

From x=1x=1 to x=3x=3:

7−33−1=2.\frac{7-3}{3-1}=2.

From x=−5x=-5 to x=10x=10:

21−(−9)10−(−5)=3015=2.\frac{21-(-9)}{10-(-5)} = \frac{30}{15} =2.

The slope is always 2.

That is what makes the graph a straight line.

For

f(x)=mx+b,f(x)=mx+b,

mm is the constant slope.

bb shifts the line vertically but does not change steepness.


11. A Tempting Wrong Idea: “Slope Is Just the Weight”

For a simple linear model,

y^=wx+b,\hat y=wx+b,

slope with respect to xx really is ww.

That can create a dangerous intuition:

“Slope is always just the number multiplying x.”

Not true.

Consider

f(x)=x2.f(x)=x^2.

There is no single constant multiplying xx.

The graph bends.

Its steepness changes depending on where we are.

A Tempting Wrong Idea

A straight line has one slope everywhere. A curve does not. For curves, “the slope” is incomplete unless we say where or over which interval.

That is the problem that will force derivatives.


12. Curves Change Their Rate of Change

Take

f(x)=x2.f(x)=x^2.

Some values:

xxx2x^2
00
11
24
39
416

Look at output changes for equal input steps of 1:

0 → 1 : +1
1 → 4 : +3
4 → 9 : +5
9 →16 : +7

The function is getting steeper.

So a curved function has a changing rate of change.


13. Average Slope on a Curve

For

f(x)=x2,f(x)=x^2,

find average slope from x=1x=1 to x=3x=3.

f(1)=1,f(3)=9.f(1)=1, \qquad f(3)=9.

So

9−13−1=82=4.\frac{9-1}{3-1} = \frac{8}{2} =4.

This number is correct—but what does it mean?

It summarizes the entire interval from 1 to 3.

It does not say the curve has slope 4 at every point.

The curve is less steep near 1 and more steep near 3.


14. The Secant Line

A line connecting two points on a curve is called a secant line.

 y
 ↑
 9|               • B
 8|             / |
 7|           /   |
 6|         /     |
 5|       /       |
 4|      curve
 3|    /
 2|  /
 1|• A
 0+----------------------→ x
    1           3

Its slope is

f(x2)−f(x1)x2−x1.\frac{f(x_2)-f(x_1)}{x_2-x_1}.

So average rate of change = slope of secant line.

This is our first bridge from algebra to local geometry.


15. Same Starting Point, Smaller Intervals

Now focus on the curve

f(x)=x2f(x)=x^2

at

x=2.x=2.

We want to understand how steep it is near that point.

Start with a wide interval from 2 to 3:

f(3)−f(2)3−2=9−41=5.\frac{f(3)-f(2)}{3-2} = \frac{9-4}{1} =5.

Use a smaller interval from 2 to 2.5:

6.25−40.5=4.5.\frac{6.25-4}{0.5} = 4.5.

Smaller again, 2 to 2.1:

4.41−40.1=4.1.\frac{4.41-4}{0.1} =4.1.

Smaller:

2→2.01:2\rightarrow2.01: 4.0401−40.01=4.01.\frac{4.0401-4}{0.01} =4.01.

A pattern is emerging:

intervalaverage slope
2 to 35
2 to 2.54.5
2 to 2.14.1
2 to 2.014.01

The secant slopes seem to be approaching 4.

We are not yet defining a derivative.

We are only observing a geometric phenomenon:

as the second point moves closer to the first, the average slope stabilizes toward a local steepness.

Chapter 018 will make that idea rigorous.


16. Why We Cannot Simply Use the Same Point Twice

A natural attempt is:

“If I want slope at x=2x=2, just use both points at x=2x=2.”

But then

Δx=2−2=0.\Delta x=2-2=0.

And

Δy=f(2)−f(2)=0.\Delta y=f(2)-f(2)=0.

So the slope formula becomes

00.\frac00.

Undefined.

This is not a small technical problem.

It is the central paradox that gives birth to calculus.

We need the slope at one point, but ordinary slope needs two distinct points.

Chapter 018 will solve exactly that problem.


17. Local Straightness

Curves often look straight when you zoom in far enough.

Imagine a huge circle.

From far away you see curvature.

Stand on a tiny patch and it looks almost flat.

The same happens with smooth function graphs.

far view:           zoomed view:

     ___                 /
   /     \               /
  /       \             /

This idea—local linearity—is one of the deepest reasons calculus works.

Near a point, many smooth nonlinear functions can be approximated by a line.

Later we will write this as a linear approximation.

Neural-network optimization relies on this constantly.


18. Why Slopes Matter for Learning

Suppose a model has one parameter ww.

Its loss is

L(w)=(w−3)2.L(w)=(w-3)^2.

Evaluate a few values:

wwL(w)L(w)
09
14
21
30
41
54
69

Graphically:

L(w)
 ↑
 9|•           •
 8|
 7|
 6|
 5|
 4|  •       •
 3|
 2|
 1|    •   •
 0|      •
  +----------------→ w
         3

We want the machine to move toward

w=3.w=3.

What information would help?

If we are at w=1w=1, the curve falls as ww increases.

If we are at w=5w=5, the curve rises as ww increases.

So local slope tells us which way lowers the loss.

This is why derivatives will become the machine’s compass.


19. Sign of Slope as a Direction Signal

Suppose we move slightly to the right.

Positive slope

loss rises → moving right is bad

To reduce loss, move left.

Negative slope

loss falls → moving right is good

To reduce loss, move right.

Zero slope

Locally flat.

This may indicate a minimum, maximum, saddle, or plateau—we will learn the differences later.

The key optimization idea is already visible:

To go downhill, move opposite the slope.

In one dimension this is simple.

In millions of dimensions we will replace slope with gradient.


20. Magnitude of Slope as Sensitivity

Suppose two functions at a point have slopes:

0.010.01

and

50.50.

A tiny input change affects the second output far more strongly.

So slope is also a measure of sensitivity.

This interpretation is useful across machine learning:

  • how sensitive is loss to a weight?
  • how sensitive is output to a pixel?
  • how sensitive is prediction to a feature?
  • how sensitive is a layer to its input?

Backpropagation will eventually compute these sensitivities throughout a network.


21. Units of Slope Are a Debugging Tool

Suppose

L(w)L(w)

is loss as a function of weight.

Then slope has units

loss unitsweight units.\frac{\text{loss units}}{\text{weight units}}.

If prediction is price and input is square feet, slope may be

lakhsquare foot.\frac{\text{lakh}}{\text{square foot}}.

Keeping units in mind can reveal mistakes.

For example, adding a slope directly to a prediction is often dimensionally nonsensical.

The slope tells how one changes with respect to another.


22. Domain and Range

Functions do not always accept every imaginable input.

The set of allowed inputs is the domain.

The set of possible outputs is the range.

Example:

f(x)=x.f(x)=\sqrt{x}.

For real-valued arithmetic, xx must satisfy

x≥0.x\ge0.

So domain matters.

Another example:

f(x)=1x.f(x)=\frac1x.

x=0x=0 is forbidden.

Why does this matter in ML?

Because functions such as logarithms appear in loss functions:

log⁡p\log p

requires

p>0.p>0.

Understanding domains prevents mysterious NaNs later.


23. One Input vs Many Inputs

So far we have used

y=f(x).y=f(x).

One input number.

But a model usually has many parameters:

L(w1,w2,b).L(w_1,w_2,b).

Or compactly,

L(θ).L(\boldsymbol{\theta}).

where

θ\boldsymbol{\theta}

collects all parameters.

Then “the slope” is no longer one number.

We will need to ask:

How does loss change if I move w1w_1 while holding everything else fixed?

What about w2w_2?

What about bb?

Those questions lead to partial derivatives and gradients in Chapters 019–020.

But first we must master the one-variable case.


24. Composition of Functions

Functions can feed into one another.

Suppose

f(x)=2x+1f(x)=2x+1

and

g(z)=z2.g(z)=z^2.

Then

g(f(x))g(f(x))

means:

x
↓
f
↓
2x+1
↓
g
↓
(2x+1)^2

This is function composition.

Notice the parallel with matrices:

B(Ax).B(A\mathbf{x}).

Deep neural networks are compositions of functions:

f3(f2(f1(x))).f_3(f_2(f_1(x))).

This is why understanding how change flows through composition will eventually force the chain rule.


25. A Tiny Neural-Network Preview

Consider one neuron:

z=wx+bz=wx+b

followed by activation

a=ReLU⁡(z).a=\operatorname{ReLU}(z).

Then a loss

L=(a−y)2.L=(a-y)^2.

This is a composition:

w
↓
z = wx+b
↓
a = ReLU(z)
↓
L = (a-y)^2

If ww changes slightly, zz changes.

That changes aa.

That changes LL.

Eventually we need a systematic way to trace these changes backward.

That will become backpropagation.

The whole story starts with slope.


26. Discrete Change vs Continuous Change

Not every function has a smooth graph.

Suppose

f(x)={0,x<01,x≥0f(x)= \begin{cases} 0,&x<0\\ 1,&x\ge0 \end{cases}

This function jumps.

There is no gradual transition at zero.

Another example is integer-valued room count.

A real house cannot have exactly 2.371 rooms in the usual sense.

Yet mathematical models often extend discrete variables into continuous space because calculus then becomes available.

That extension can be useful, but we should remember the modelling assumption.


27. Smoothness Preview

Chapter 001 discussed why squared error feels smoother than absolute error.

Now we can phrase that geometrically.

For

f(x)=x2,f(x)=x^2,

the slope changes gradually as x moves.

For

g(x)=∣x∣,g(x)=|x|,

the graph has a corner at zero:

\ /
 V

The slope from the left is negative.

The slope from the right is positive.

There is no single obvious line that matches both sides at the corner.

Chapter 018 will give the precise language for this.


28. How to Read a Function Graph Like an Optimizer

When you see a graph, ask four questions.

1. Is it rising or falling?

That tells sign of slope.

2. How steep is it?

That tells magnitude of slope.

3. Is steepness changing?

That tells whether the function is curved.

4. Where does slope appear to become zero?

Those locations may be important optima or flat regions.

This is much more useful than memorizing graph shapes.


29. Shape Check

Even scalar calculus has shapes.

For

f:R→R,f:\mathbb{R}\rightarrow\mathbb{R},

we have:

input x        scalar
output f(x)    scalar
Δx             scalar
Δf             scalar
Δf / Δx        scalar

Later:

f:Rn→Rf:\mathbb{R}^n\rightarrow\mathbb{R}

will produce a gradient with nn components.

Thinking about input/output structure now will make multivariable calculus much easier.


30. Code: Sample a Function


def f(x):
    return x * x

for x in [0, 1, 2, 3, 4]:
    print(x, f(x))

The important idea is that code mirrors mathematical function notation:

f(3)

means “feed 3 into the rule named f.”


31. Code: Average Rate of Change


def average_slope(f, x1, x2):
    return (f(x2) - f(x1)) / (x2 - x1)


def square(x):
    return x ** 2

print(average_slope(square, 1, 3))  # 4.0

Now shrink the interval near 2:

for h in [1, 0.5, 0.1, 0.01]:
    print(h, average_slope(square, 2, 2 + h))

Before running, predict the pattern.

You should expect values:

5
4.5
4.1
4.01

Do not yet call 4 “the derivative.”

For now, say:

the nearby average slopes are converging toward 4.

Chapter 018 will explain why that statement can become an exact definition.


32. Break It: Vertical Change With Zero Horizontal Change

Try to compute slope between

(2,4)(2,4)

and

(2,9).(2,9).

Then

Δx=0.\Delta x=0.

So

ΔyΔx=50.\frac{\Delta y}{\Delta x} = \frac50.

Undefined.

Geometrically, the line is vertical.

This reminds us:

slope is fundamentally “output change per input change.” If there is no input change to divide by, ordinary slope is undefined.


33. Break It: Large Average Interval Hides Local Behaviour

Consider

f(x)=x3−x.f(x)=x^3-x.

From x=−1x=-1 to x=1x=1:

f(−1)=0,f(1)=0.f(-1)=0, \qquad f(1)=0.

Average slope is

0.0.

Does that mean the function is flat throughout the interval?

No.

It rises and falls inside.

A single average slope can hide rich local behaviour.

This is exactly why optimization needs local rates of change.


34. Break It: Correlation Is Not Slope

Suppose two variables tend to increase together.

That is a statement about association across a dataset.

Slope describes the change of an output with respect to an input inside a function or fitted relationship.

They can be connected, but they are not interchangeable.

Later, statistics will make this distinction precise.


35. History Lens — From Motion to Calculus

Ancient mathematicians studied tangents and changing quantities long before modern notation existed.

By the seventeenth century, problems in astronomy, mechanics and geometry made the need urgent:

  • how fast is a planet moving at an instant?
  • what is the tangent to a curve at one point?
  • where does a curve reach a maximum or minimum?

Newton and Leibniz independently developed systematic calculus methods in the late seventeenth century, building on substantial earlier work by mathematicians such as Fermat, Barrow, Descartes, Cavalieri and others.

The historical pressure was the same one we now face in machine learning:

average change is not enough when the behaviour changes continuously from point to point.


36. Distinctions That Matter

PairDifference
function vs equationfunction emphasizes input→output mapping; an equation may express any relationship
output value vs slopewhat the function equals vs how fast it changes
average rate vs local ratechange across an interval vs change near one point
linear vs nonlinear functionconstant slope vs changing slope
positive slope vs large slopedirection vs magnitude
slope vs correlationfunctional rate of change vs statistical association
secant vs tangentline through two curve points vs local line touching one point

37. What We Discovered

  1. A function maps inputs to outputs.
  2. A graph visualizes that mapping.
  3. Change is represented with differences such as Δx\Delta x and Δy\Delta y.
  4. Average slope is
ΔyΔx.\frac{\Delta y}{\Delta x}.
  1. Slope sign gives direction of change.
  2. Slope magnitude gives sensitivity or steepness.
  3. Linear functions have constant slope.
  4. Nonlinear functions have changing slope.
  5. Average slope on a curve is the slope of a secant line.
  6. Shrinking the interval reveals a stable local steepness for smooth functions.
  7. Using the exact same point twice creates the undefined expression 0/00/0.
  8. Local slope is precisely the information optimization needs to know which way loss changes.
  9. Function composition prepares us for the chain rule and backpropagation.

38. Mathematics We Built

Change in input

Δx=x2−x1\Delta x=x_2-x_1

Change in output

Δy=f(x2)−f(x1)\Delta y=f(x_2)-f(x_1)

Average rate of change

f(x2)−f(x1)x2−x1\frac{f(x_2)-f(x_1)}{x_2-x_1}

Linear function

f(x)=mx+bf(x)=mx+b

where mm is constant slope.

Function composition

(g∘f)(x)=g(f(x)).(g\circ f)(x)=g(f(x)).

No derivative formula has been assumed yet.

We have earned the need for one.


39. What Each Symbol Means

SymbolRead it asMeaningIn code
xxxinputx
ffffunction/rulef
f(x)f(x)f of xoutput from input xf(x)
Δx\Delta xdelta xchange in inputx2 - x1
Δy\Delta ydelta ychange in outputf(x2)-f(x1)
mmmslope of a lineslope
bbbvertical offsetbias or b
hhhsmall nonzero input steph

40. One-Minute Explanation

A function is a machine that maps an input to an output. To understand how the output changes, compare two input points. The change in output divided by the change in input is the average slope, or rate of change, between them. Straight lines have the same slope everywhere. Curves do not: their steepness changes from place to place. If we want the local steepness near one point, we can move a second point closer and closer and watch the secant slopes stabilize. We cannot simply use the exact same point because that would require dividing 00 by 00. Solving that paradox rigorously is the job of the derivative.


41. Mastery Check

You are ready for Chapter 018 only if you can answer these without looking back:

  1. What is a function in plain English?
  2. What is the difference between ff and f(x)f(x)?
  3. What does Δ\Delta mean?
  4. Why does slope have units?
  5. What do the sign and magnitude of slope tell us?
  6. Why does a straight line have one slope everywhere?
  7. Why does x2x^2 not have one global slope?
  8. What is a secant line?
  9. Why can average slope hide local behaviour?
  10. What happens to secant slopes of x2x^2 near x=2x=2 as the interval shrinks?
  11. Why can we not compute slope at a single point by plugging the same point twice into the ordinary slope formula?
  12. Why does optimization care about local slope?
  13. How does function composition foreshadow neural networks and the chain rule?

🔭 Bridge to Chapter 018

We now know exactly what we want.

For a curve such as

f(x)=x2,f(x)=x^2,

we want the exact local slope at one point.

Ordinary slope needs two points.

If we collapse them into one, we get

00.\frac00.

Yet shrinking the gap suggests a perfectly stable answer is hiding there.

How can we obtain the slope at a single instant without ever dividing by zero?

That question forces the invention of the derivative.

Six ways to work the chapter, climbing from explaining it in your own words to investigating it like a researcher. Reading is not enough — this is where the chapter lands.

These exercises are designed to make the need for derivatives feel unavoidable before Chapter 018 introduces the formal machinery.

Level 1 — Explain It

  1. Explain a function using the “input → machine → output” picture.
  2. What is the difference between ff and f(x)f(x)?
  3. Explain slope without using the formula.
  4. What do the sign and magnitude of slope tell you?
  5. Why does a curved function not have one global slope?
  6. Explain why slope has units.
  7. Explain the difference between average slope and local steepness.

Level 2 — Calculate It

A. Linear function

Let

f(x)=3x+2.f(x)=3x+2.

Calculate the average slope between:

  1. x=0x=0 and x=1x=1
  2. x=1x=1 and x=5x=5
  3. x=−2x=-2 and x=10x=10

What pattern do you see?

B. Nonlinear function

Let

g(x)=x2.g(x)=x^2.

Calculate average slope between:

  1. 0 and 1
  2. 1 and 2
  3. 2 and 3
  4. 3 and 4

Explain what the changing slopes tell you about the graph.

C. Loss curve

Let

L(w)=(w−3)2.L(w)=(w-3)^2.

Compute the average slope from:

  1. w=0w=0 to w=1w=1
  2. w=1w=1 to w=2w=2
  3. w=4w=4 to w=5w=5
  4. w=5w=5 to w=6w=6

Use only the signs to predict which direction reduces loss.

Level 3 — Predict Before Running

For

def square(x):
    return x ** 2

predict the average slopes from x=2 to:

3
2.5
2.1
2.01
2.001

Write your predictions before running code.

Then explain why the sequence approaches a stable value.

Do not use a derivative rule such as d/dx x² = 2x yet.

Level 4 — Break It

Experiment A — Same x-coordinate

Try to calculate the slope between (2,4) and (2,9).

  • What appears in the denominator?
  • Why is the result undefined?
  • What does the line look like geometrically?

Experiment B — Average slope hides local motion

Use

f(x)=x3−x.f(x)=x^3-x.

Compute average slope from x=−1x=-1 to x=1x=1.

Then sample many points inside the interval and plot the function.

Explain why average slope 0 does not mean the function is flat.

Experiment C — Corner

Compare

f(x)=x2f(x)=x^2

and

g(x)=∣x∣.g(x)=|x|.

Around zero, compute average slopes using intervals from the left and right.

Describe what looks different without yet using formal derivative terminology.

Level 5 — Build It

Implement:

def average_rate_of_change(f, x1, x2):
    pass

Requirements:

  • raise a useful error when x1 == x2
  • verify linear functions return the same slope on many intervals
  • verify x**2 produces different slopes on different intervals
  • test at least 20 random intervals

Then build:

def secant_slopes(f, x, hs):
    pass

which returns the slopes from x to x+h for every nonzero h.

Level 6 — Investigate It

Choose three functions:

f1(x)=x2,f_1(x)=x^2, f2(x)=x3,f_2(x)=x^3, f3(x)=∣x∣.f_3(x)=|x|.

For several points xx, calculate secant slopes using

h = 1, 0.5, 0.1, 0.01, 0.001

Investigate:

  1. Which functions show a clear stable local slope?
  2. At which points does the pattern behave differently?
  3. What happens around the corner of ∣x∣|x|?
  4. How do slopes from positive h compare with negative h?
  5. What definition do you think Chapter 018 will need?

Write a hypothesis before reading Chapter 018.

Shape Check

For a scalar function

f:R→R,f:\mathbb{R}\to\mathbb{R},

fill in:

x                 → ______
f(x)              → ______
Δx                → ______
Δf                → ______
Δf / Δx           → ______

Then contrast this with a future loss

L:R1000→R.L:\mathbb{R}^{1000}\to\mathbb{R}.

Predict: would one scalar slope be enough to describe sensitivity to all 1000 parameters?

Graph Reading Drill

Sketch or plot four curves:

  1. positive constant slope
  2. negative constant slope
  3. slope increasing as x increases
  4. a curve with a corner

For each, label:

  • where output increases/decreases,
  • where it is steep/flat,
  • where local slope appears hard to define.

Mastery Gate

Do not continue until you can answer without notes:

  • What is a function?
  • What is average rate of change?
  • Why does slope have sign and magnitude?
  • Why is average slope a secant-line slope?
  • Why does a nonlinear function require location-dependent steepness?
  • Why does using one point twice produce 0/0?
  • Why does shrinking the interval help without actually setting the interval to zero?
  • Why is local slope exactly the kind of signal gradient-based learning will need?