Numbers & Functions

7 Functions as Objects

CHAPTER 7 Functions as Objects We’ve now met every family of machine this book set out to introduce: the polynomials, the exponentials and their logarithm twins, and the trigonometric machines that go around. You could stop here and already know more about functions than most people ever learn.

But there’s one more idea, and it’s the one that turns a collection of functions into a way of thinking — the idea that quietly powers everything in the later books, from calculus to neural networks: A function isn’t only something you use. It’s something you can hold, reshape, and build with — an object in its own right.

Up to now we’ve fed numbers into machines and watched numbers come out. In this chapter we stop feeding the machines and instead pick them up, turn them over, and operate on the machines themselves. The machine becomes the raw material.

7.1 Four things you can do to any function

Take any machine f(x) — say the parabola f(x) = x2 — and watch what four simple changes do to its graph. These four moves work identically on every family. 1. Shift it up or down. Add to the output: f(x) + 3 lifts the whole graph up by 3. (You’re tampering with what comes out.)

2. Shift it left or right. Add to the input: f(x + 3) shifts the graph left by 3 — not right. The machine reaches its old behavior earlier: what f used to do at x = 3 now happens at x = 0, since f(0 + 3) = f(3).

3. Stretch or squash it. 2f(x) doubles every height (vertical stretch); f(2x) makes the machine race through its behavior twice as fast (horizontal squash). 4. Flip it. −f(x) reflects across the horizontal axis (upside down); f(−x) reflects across the vertical axis (mirror left-to-right).

x f(x) + 3 (shifts up) x f(x + 3) (shifts LEFT surprise) x 2f(x) f(2x) outside = taller inside = narrower 2f(x) vs f(2x) x −f(x) flips down f(−x) invisible (even: same curve) −f(x) and f(−x) Outside = vertical & expected Inside = horizontal & opposite Figure 7.1. The four transformations on the base parabola (gray). Outside the function acts vertically and as expected; inside acts horizontally and in the opposite direction. (In panel D the parabola is even, so f(−x) is invisible.)

Functions as Objects Outside the function (acting on the output) changes the graph vertically, and does what you’d expect. Inside the function (acting on the input) changes the graph horizontally, and does the opposite of what you’d expect.

x slides LEFT by 3 f(x + 3) = (x + 3)2 f(x) = x2 the machine reaches its old behavior earlier Figure 7.2. The left-shift surprise, explained. f(x + 3) moves the vertex from x = 0 to x = −3 — the machine reaches its old behavior earlier, so the graph slides left.

Master those two sentences and you can reshape any machine in the book. Want a sine wave twice as tall, repeating twice as fast, shifted up by one? That’s 2 sin(2x) + 1, and you can read off exactly what each piece does.

All 8 chapters of Numbers & Functions · Foundations · All courses