Lectures 1–5 | how information travels, and how we draw it
Close your eyes and listen for ten seconds. Something happened out there in the world — air moved — and something happened in here, in your head. In between, information travelled. It got converted, at least four times, into forms nothing like the original: pressure into motion, motion into electricity, electricity into whatever it is you are experiencing right now.
That chain of conversions is what this course is about. Each link takes something in and gives something out, reliably, the same way every time. We call such a link a function, and once you start looking you find them everywhere, because a function is simply the mathematical name for a rule that turns input into output.
The subject you are about to study did not arrive as one block. It grew out of people trying to understand what their senses were telling them, and the three great branches correspond, roughly and beautifully, to three ways of sensing the world.
Geometry begins with an act of deliberate forgetting. To say that a park is a rectangle 300 metres by 200 metres is to throw away the grass, the noise, the people, the smell after rain — everything except length and width. That looks like a loss. It is what makes the calculation possible: with everything else discarded, \(\sqrt{300^2+200^2}\approx 360\) metres tells you the diagonal path saves you 140 metres of walking, and it tells you that for every rectangle that ever was. Abstraction is not the opposite of reality. It is a lens that gives up colour to gain reach.
You have met functions in many disguises: a formula, a graph, a table, a sentence. All four describe the same kind of object.
The last one has outputs that are not numbers, and the third has no formula at all. Both are still functions. We will fix the number problem shortly, and the fix is more interesting than it sounds.
A function \(f\) from a set \(A\) to a set \(B\) is a rule that assigns to each element \(x\) of \(A\) exactly one element of \(B\), written \(f(x)\).
The set \(A\) is the domain. The set of values actually produced is the range. We write \(f:A\to B\), and we read \(f(x)\) as "\(f\) of \(x\)", or "the value of \(f\) at \(x\)".
Two words in that definition are doing all the work. Each: nothing in the domain is left without an answer. Exactly one: nothing gets two answers. A rule that sometimes says 3 and sometimes says 5 for the same input is not a function — it is a coin flip, and you cannot build anything on it.
Decide which of these rules are functions, and if not, say precisely which part of the definition fails.
(a) A function. Every student has exactly one birthday.
(b) Not a function, twice over. Most dates have no student attached (fails each), and if two classmates share a birthday, that date has two (fails exactly one).
(c) Not a function — that is the entire point of shuffle. The same input can produce a different output tomorrow, so nothing can be predicted from it.
(d) A function, and a famously useful one. It takes infinitely many inputs to just seven outputs, so it destroys enormous amounts of information on purpose; it is the arithmetic behind check digits, hash tables and cryptography.
(e) Not reliably. Ask most people twice and you get two answers. A rule has to be stable to be a function, which is a real constraint on what parts of the world mathematics can model.
If \(f(x)=x^{2}+4\), what is \(f(-3)\)?
decimals, fractions, pi and sqrt( ) are all fine
In a game, holding the attack button charges a strike. Charging for \(x\) seconds does $$D(x)=x^2+4$$ points of damage. Describe in words what \(D\) does, then find \(D(3)\), \(D(0)\), \(D(\sqrt5)\), and \(D(a+h)\).
In words: square the charge time, then add four. The four is the damage you do with no charge at all — a tap still hurts.
\(D(3)=9+4=13\). \(D(0)=4\). \(D(\sqrt5)=5+4=9\).
\(D(a+h)=(a+h)^2+4=a^2+2ah+h^2+4\). The variable is a placeholder; whatever goes in the box gets squared.
That last computation looks like busywork now. It answers a real question: if you are already charging for \(a\) seconds, what does holding on for \(h\) seconds longer buy you? The extra damage is \(D(a+h)-D(a)=2ah+h^2\). Divide by \(h\) to get the damage per extra second, and you have written down a difference quotient — the object Lecture 8 is built on, and the derivative after that.
An astronaut weighs 130 pounds on the launch pad. At a height of \(h\) miles the weight is $$w(h)=130\left(\frac{3960}{3960+h}\right)^{2}\ \text{pounds.}$$ Find the weight at 100 miles up, and the net change between the launch pad and the altitude of the space station, 254 miles.
\(w(100)=130(3960/4060)^2\approx 123.7\) lb.
\(w(254)=130(3960/4214)^2\approx 114.8\) lb, and \(w(0)=130\), so the net change is about \(-15.2\) lb.
Notice what this does not say. A crew member on the station is weightless, yet the formula reports 115 pounds. Both are true: gravity is barely weaker up there, and things float there because they are falling around the Earth rather than standing on it. A model answers the question it was built for and no other, and knowing which question that was is most of the skill.
A rental e-scooter costs \$1.20 to unlock. The first three minutes are free; after that it costs \$0.42 per minute. Write the cost as a function of the ride length \(t\) in minutes, find \(C(2)\), \(C(3)\) and \(C(12)\), and sketch it.
\(C(2)=1.20\), \(C(3)=1.20\), and \(C(12)=1.20+0.42(9)=\$4.98\).
This is a piecewise defined function: one rule on part of the domain, another elsewhere. The two rules agree at \(t=3\), so there is no jump — but there is a kink, and at a kink the function has no single rate of change. That kink is the first thing Chapter 2 will want to talk about.
A campus printer charges 10 cents per page, but a job of any size is rounded up to a whole page. A document runs to 2.3 pages. What does it cost? Sketch the cost for \(0<x\le 4\) pages and describe the shape in one word.
It costs 30 cents: the machine charges for 3 pages. The function is $$C(x)=0.10\lceil x\rceil,$$ a staircase. It jumps at every whole number, and at each jump the value belongs to the upper step.
Staircase functions are perfectly legal functions, and they are everywhere in pricing, postage and parking. They are also the first sign that "function" is a far wider idea than "smooth curve" — and it was exactly such awkward functions that forced mathematicians in the 1800s to write the careful definition you read above.
Our definition allows any sets \(A\) and \(B\). In practice we almost always take both to be sets of real numbers, and that sounds like a serious restriction. It is not, because anything can be encoded as numbers.
A greyscale image is 10 pixels wide and 8 pixels tall, with one number per pixel. How many numbers does it take to store?
decimals, fractions, pi and sqrt( ) are all fine
The same trick works for everything. Sound is a function from time to air pressure, sampled 44,100 times a second on a CD. Text is a function from position to character code. A colour is three numbers. A chess position is a list. Once information is numbers, functions on the real line can operate on it — which is why the mathematics you learn here applies to things that are not obviously mathematical at all.
DNA is read three letters at a time. Each of the 64 possible triples — AAA, AAC, and so on — tells the cell to add one particular amino acid, or to stop. There are 20 amino acids and one stop instruction. Is the genetic code a function? Can it be run backwards?
It is a function: each triple has exactly one meaning, the same in a bacterium and in you.
It cannot be run backwards. Sixty-four inputs map onto twenty-one outputs, so on average three different triples mean the same thing; knowing that an amino acid is leucine does not tell you which of its six codons produced it. Information about the DNA is genuinely lost in the reading.
And that redundancy is a feature. A typo in the third letter of a codon very often changes nothing at all, because the alternatives were pointing at the same amino acid anyway. The code is built so that small errors are absorbed — the same design principle behind the check digit on your bank card. Lecture 5 is about exactly this trade: what you give up when a function stops being reversible, and what you can buy with it.
Encode the word CAB as numbers in three different ways, and say what each one keeps and what it throws away.
Position in the alphabet. \(C=3\), \(A=1\), \(B=2\), so the word becomes the list \((3,1,2)\). This keeps everything: the letters and their order. You can rebuild the word exactly.
Letter counts. Count how many of each letter: one A, one B, one C, and none of the rest. That is the list \((1,1,1,0,0,\ldots)\) with 26 entries. It keeps which letters appeared and how often, and throws away the order — so CAB, BAC and ABC all give the same list.
Length. The single number 3. Almost everything is gone.
All three are legitimate encodings, and which is right depends entirely on the question. If you want to recover the word, use the first. If you want to know whether two documents are about the same subject, the second is better, because order is mostly noise for that purpose. This choice — what to keep and what to discard — is the first real decision in any piece of data analysis.
The second encoding above is worth pushing further, because it is how text is actually handed to a computer.
Pick a small list of words to pay attention to. For each sentence, count how many times each of those words appears. The sentence is now a list of numbers — and a list of numbers, as Chapter 7 will make precise, can be drawn as an arrow.
Count two kinds of word — animal words (cat, dog, chased) and finance words (market, stock, analyst) — in these three sentences, and plot each as a pair of numbers.
A has cat and nothing else from either list, and we will count mat as an animal-adjacent word for the sake of a clean picture: \((2,0)\). B has cat and chased, plus market and analyst: \((3,1)\). C has market and two more finance words: \((0,3)\).
Now look at what the picture gives you for free. A and B point in nearly the same direction, and they are about nearly the same thing. C points at a right angle to A, and they share nothing. The direction of the arrow carries the meaning; its length carries only how many words the sentence has.
That is why length has to be divided out before two sentences are compared, and the tool that does it is the angle between the arrows. We cannot compute that angle yet — it needs the dot product, which arrives in Chapter 7 — but the picture is already doing the work, and this exact example returns there.
This is the quiet premise underneath every piece of technology built since 1940: whatever it is, digitise it, and then a function can act on it. A photo filter is a function. A search ranking is a function. A large language model is a function — an extremely large one, with billions of adjustable numbers inside, taking a sequence of text-codes in and giving the next text-code out. When people ask what artificial intelligence is, the honest technical answer is: a function that somebody fitted to data. You will fit your first one in Lecture 6.
Nobody used the word function before 1673, when Leibniz wrote it down. But the idea is older than the word. In the 1350s Nicole Oresme, in Paris, drew a quantity as a height above a horizontal line and reasoned about how the height varied — a graph, three hundred years before Descartes gave us coordinates. Euler introduced the notation \(f(x)\) in 1734.
The definition you read above, with its insistence on each and exactly one, is younger still: it settled only in the nineteenth century, after mathematicians found functions so badly behaved that the old intuition ("a function is a formula") collapsed. What looks like a dry definition is a scar from an argument that lasted a century.
If functions are going to eat numbers, we had better be sure the numbers are solid. They are, but only just, and the reason took two thousand years to work out.
Draw a horizontal line, mark a point as \(0\) and another as \(1\), and every real number now has a home. The picture is so familiar that it hides three separate properties, each of which we will use.
The third one is the deep one, and it is not obvious. The rational numbers — all the fractions — are already dense: between any two of them sits another. If you plotted every fraction, the line would look completely full. And yet it would be full of holes, because \(\sqrt2\) is not a fraction, and neither is \(\pi\), and in a precise sense almost every point on the line is one of these missing ones.
The Pythagoreans, around 500 BCE, believed that every length was a ratio of whole numbers. Then someone in their own school proved that the diagonal of a unit square is not. The legend — probably invented, but the shock behind it was real — says the discoverer was drowned at sea. Their entire picture of the universe had a hole in it, at a location they could construct with a ruler.
The hole was not properly filled until 1872, when Richard Dedekind defined a real number as a cut in the rationals: pick a place to slice the fractions into a left set and a right set, and the slice itself is the number. That is what completeness means. It is why calculus works, why a continuous curve that goes from below zero to above zero must cross zero, and why nothing you do in this course will fall through a gap.
Because the line is ordered, the most useful subsets of it are the unbroken stretches, and they get their own notation.
| Notation | Means | In words |
|---|---|---|
| (a, b) | \(a<x<b\) | open: endpoints excluded |
| [a, b] | \(a\le x\le b\) | closed: endpoints included |
| [a, b) | \(a\le x<b\) | half open |
| (a, ∞) | \(x>a\) | infinity is never included; it is not a number |
In interval notation, \(-2\le x<7\) is written .
Absolute value turns the order into a distance: \(|a-b|\) is how far apart \(a\) and \(b\) are, regardless of which is bigger. This single reading makes a whole family of formulas obvious rather than memorized. \(|x-3|<2\) says \(x\) is within 2 of 3, which is the interval \((1,5)\).
\(|x+4|\le1\) describes an interval. What number is at its centre?
decimals, fractions, pi and sqrt( ) are all fine
A restaurant on a long straight avenue delivers only to addresses within 8 blocks of itself. It sits at block 23. Write the delivery zone with absolute value, then as an interval, and decide whether an address at block 32 is inside it.
"Within 8 of 23" is exactly \(|x-23|\le 8\), which is the interval \([15,31]\).
Block 32 falls one block outside. The picture makes the reason obvious in a way the inequality does not: absolute value is distance, and once you read it that way you stop memorising which direction the inequality flips.
A bolt is specified as 12.00 mm in diameter with a tolerance of 0.05 mm. A machine measures one at 11.94 mm. Write the acceptable range with absolute value and decide whether the bolt passes.
Acceptable means \(|d-12.00|\le 0.05\), that is \(11.95\le d\le 12.05\). At 11.94 mm the bolt fails, by one hundredth of a millimetre.
Every specification sheet in engineering is an absolute value inequality, and this is why: what matters is not the measurement but its distance from the target, in either direction.
Take a copy of the real line, take another, cross them at right angles, and you can name any point in a flat world with a pair of numbers \((x,y)\). This is Descartes' idea, and it is the hinge on which all of modern mathematics turns: it lets shape be described by equations, so that geometry and algebra become two languages for one subject.
Coordinates are a choice, not a fact about the world. Nothing out there is labelled \((3,-2)\); you decided where the origin was and which way was up. This matters more than it sounds. A great deal of Chapter 7, and of data science generally, consists of choosing better coordinates for a problem — finding the axes along which your data actually varies. The freedom to relabel is a tool.
Coordinates do something far more useful than labelling points. They let a shape be written as an equation, and an equation be drawn as a shape — and once that translation exists it runs in both directions, so a hard problem in one language can be carried across and solved in the other.
The circle of radius \(r\) about the origin is the set of points at distance \(r\) from it. Distance in the plane comes from the Pythagorean theorem, so the condition is $$x^2+y^2=r^2.$$ That single line is the whole hinge. On the left it is algebra; on the right it is a curve you could draw with a piece of string.
A drone is flying the straight path \(y=x+1\). A no-fly zone is the circular region of radius 5 centred at the origin. Where does the drone cross the boundary?
The boundary is \(x^2+y^2=25\). Substituting the path: $$x^2+(x+1)^2=25 \;\Longrightarrow\; 2x^2+2x-24=0 \;\Longrightarrow\; x^2+x-12=0,$$ which factors as \((x+4)(x-3)=0\). So \(x=-4\) or \(x=3\), giving the crossing points \((-4,-3)\) and \((3,4)\).
A question about where two curves meet became a quadratic equation, which is a thing we know how to kill. Notice also that the crossing points have whole-number coordinates and satisfy \(3^2+4^2=5^2\) — Pythagorean triples turning up uninvited, as they do.
René Descartes published this in 1637, in an appendix. Before it, geometry and algebra were separate subjects with separate practitioners; a Greek geometer proving a fact about conic sections and an Islamic algebraist solving a cubic were not obviously doing the same work. Afterwards they were two dialects, and any statement could be moved into whichever dialect made it easier.
That is a pattern worth watching for, because it never stopped: the whole later history of mathematics is one translation after another. Logarithms turn multiplication into addition (Chapter 3). The unit circle turns repetition into coordinates (Chapter 4). Matrices turn geometric motion into arithmetic (Chapter 7). Machine learning turns images and sentences into vectors so that geometry can be done on them. Each time, someone noticed that a hard problem was easy on the other side of a translation, and went to the trouble of building the bridge.
The graph of a function \(f\) is the set of points $$\{(x,f(x)) : x \text{ in the domain of } f\}.$$ It is the picture of every input paired with its output.
Because each input gets exactly one output, no vertical line can meet a graph twice. That is the whole content of the vertical line test: it is not an extra rule, it is the definition of a function, drawn.
If a function is given by a formula with no domain stated, the domain is understood to be every real number for which the formula produces a real number. In practice, only two things go wrong: dividing by zero, and taking an even root of a negative.
Find the domain of each: (a) \(f(x)=\dfrac{1}{x-4}\); (b) \(g(x)=\sqrt{x}\); (c) \(h(x)=\dfrac{1}{x^2-x}\); (d) \(j(t)=\dfrac{t}{\sqrt{t+1}}\).
(a) \(x\neq4\), that is \((-\infty,4)\cup(4,\infty)\).
(b) \(x\ge0\), that is \([0,\infty)\).
(c) \(x^2-x=x(x-1)\), so \(x\neq0\) and \(x\neq1\).
(d) Both problems at once: the root needs \(t+1\ge0\) and the denominator needs \(t+1\neq0\). So \(t>-1\), the interval \((-1,\infty)\).
A drone battery lasts 28 minutes. Its remaining flight time after \(t\) minutes in the air is \(R(t)=28-t\). What is the domain of the formula? What is the domain of the situation?
The formula \(28-t\) is happy with every real number, including \(t=-9\) and \(t=1000\). The situation is not: \(0\le t\le 28\).
This gap between the mathematical domain and the physical one is where most modelling errors live. A formula fitted to sales data for prices between \$2 and \$8 will cheerfully report a prediction for a price of \$400; it has no way of knowing it is being asked something absurd. Stating the domain is not bookkeeping. It is you writing down the range of situations you are actually willing to vouch for.
A graph is a compression device. A year of daily temperature readings is 365 numbers, which no one can hold in their head; drawn as a curve, the same information becomes a shape you understand in a second. This lecture is about extracting that understanding deliberately, and about the ways a picture can mislead you.
\(f\) is increasing on an interval if \(f(x_1)<f(x_2)\) whenever \(x_1<x_2\) in that interval, and decreasing if \(f(x_1)>f(x_2)\).
\(f\) has a local maximum at \(c\) if \(f(c)\ge f(x)\) for all \(x\) near \(c\); a local minimum is defined the same way with the inequality flipped. The absolute maximum and minimum are the largest and smallest values over the whole domain.
"Local" means what it says: a hilltop is a local maximum even if there is a taller mountain three valleys over. When you meet gradient descent in Lecture 8, this distinction stops being pedantic and becomes the central practical difficulty of the whole method.
Using the temperature plot above, estimate the net change in temperature from day 60 (early March) to day 220 (early August), and say why the net change tells you almost nothing about what happened in between.
Reading the plot, day 60 is around 40°F and day 220 around 82°F, so the net change \(f(220)-f(60)\) is roughly \(+42\)°F.
But the same net change would result from a straight climb, from a climb-crash-climb, or from a summer that arrived in April and stalled. Net change is a single number extracted from 160 days of behaviour; it is the crudest possible summary. Chapter 2 asks the better question — not how much did it change, but how fast was it changing at each moment.
\(f\) is even if \(f(-x)=f(x)\) for every \(x\) in the domain: the graph is a mirror image across the \(y\)-axis.
\(f\) is odd if \(f(-x)=-f(x)\): the graph is unchanged by a half-turn about the origin.
\(f\) is even and \(f(4)=9\). What is \(f(-4)\)?
decimals, fractions, pi and sqrt( ) are all fine
Decide whether each is even, odd, or neither: (a) \(f(x)=x^4-3x^2\); (b) \(g(x)=x^3+x\); (c) \(h(x)=x^2+x\).
(a) \(f(-x)=x^4-3x^2=f(x)\): even. Only even powers appear, which is where the name comes from.
(b) \(g(-x)=-x^3-x=-g(x)\): odd.
(c) \(h(-x)=x^2-x\), which is neither \(h(x)\) nor \(-h(x)\). Mixing even and odd powers destroys both symmetries. Test with \(x=1\): \(h(1)=2\), \(h(-1)=0\).
Every graph you have ever seen of real data is a lie by omission, and an honest scientist knows exactly which lie. The temperature curve above is drawn from 365 numbers, one per day — but the temperature at 3 a.m. on 14 March is not on that plot, and neither is anything else that happened between readings. The smooth line connecting the dots is an assumption, drawn in by us, that nothing wild occurred in the gap.
Sometimes that assumption is safe. Sometimes it hides everything that matters: a flash flood, a market crash, a heartbeat. The rate at which you sample decides what you are capable of seeing, and in Lecture 16 we will find the precise version of this statement — you cannot detect a cycle that repeats faster than you look.
Here is the elevation profile of a 7 km ridge trail. Find the absolute maximum and where it occurs, the absolute minimum, and every local maximum and minimum. Then answer the question that actually matters to the legs doing the walking: how much total climbing is there?
Absolute maximum 498 m at 2.1 km — the summit. Absolute minimum 149 m, at the very end of the walk, lower than the starting point.
Local maxima at 2.1 km (498 m) and 5.0 km (351 m); a local minimum at the saddle, 4.2 km (273 m). The second summit is a genuine local maximum even though it is 147 m lower than the first — local means higher than its neighbours, not highest.
Total climbing is a different quantity from net change. Net change is \(149-180=-31\) m, which makes the day sound flat. But the trail climbs \(498-180=318\) m to the summit and then another \(351-273=78\) m out of the saddle: 396 m of ascent in the legs. Net change cancels the ups against the downs; total climbing adds their sizes. Chapter 2 will separate these two questions properly, and it turns out the second one is the harder and more interesting of the two.
A sensor records a signal once per second and returns the readings \(0,0,0,0,0\), suggesting the signal is off. The figure shows what was actually happening.
The signal completes exactly one full cycle between consecutive samples, so every sample catches it at the same phase — zero. Five honest measurements, taken with a working instrument, and the conclusion is completely wrong.
This is aliasing. It is why wagon wheels spin backwards in old films, why a guitar string filmed on a phone appears to wobble slowly, and why the sampling rate of an audio file caps the highest note it can contain. The rule, which we will meet properly in Lecture 17: you cannot detect a cycle that repeats faster than you look.
The moral is not that measurement is untrustworthy. It is that a set of data points has no opinion about what happened between them, and the smooth line your software draws through them is a guess you have made, not a fact you have measured.
There are only a handful of function shapes worth memorising. Everything else is one of those shapes, moved. Learning to see a complicated formula as a simple graph that has been shifted, flipped or rescaled is one of the highest-value skills in this course, because it turns algebra you would have to compute into geometry you can see.
There are exactly five things you can do, and it pays to meet them one at a time before meeting them together. Throughout this section \(f\) is the dashed curve — some function, it does not matter which — and the solid curve is what happens to it.
Adding a constant to the output raises every point by that amount.
The graph of \(y=f(x)+d\) is the graph of \(f\) shifted up by \(d\) units when \(d>0\), and down by \(|d|\) units when \(d<0\).
This is the easiest one, because it does exactly what it says. The domain is unchanged; the range moves by \(d\).
Changing the input before the function sees it moves the graph sideways — and in the direction most people do not expect.
The graph of \(y=f(x-c)\) is the graph of \(f\) shifted right by \(c\) units when \(c>0\), and left by \(|c|\) when \(c<0\).
Think of \(f\) as a machine and the change as an interception. In \(y=f(x-1)\), whatever you type in gets 1 subtracted from it before the machine ever sees it. So to make the machine produce the output it used to produce at 0, you now have to type in 1. Every feature of the graph arrives one unit later, which means the picture slides to the right.
Outside changes happen to the answer, after the work is done, so they behave straightforwardly. Inside changes happen to the question. That distinction is worth holding on to: it explains reflections and stretches too, and it is the same reason the inverse of "add 3 then double" is "halve then subtract 3".
A minus sign flips the graph. Which axis it flips across depends on whether the minus sign is outside or inside.
\(y=-f(x)\) reflects the graph across the \(x\)-axis: every output changes sign.
\(y=f(-x)\) reflects the graph across the \(y\)-axis: every input changes sign.
\(y=f(-x)\) reflects the graph across the , because the minus sign changes every .
This gives a neat restatement of Lecture 3. An even function is one that is unchanged by a horizontal reflection, since \(f(-x)=f(x)\). An odd function is one for which the two reflections give the same result, since \(f(-x)=-f(x)\).
Multiplying the output scales every height.
The graph of \(y=a\,f(x)\) is the graph of \(f\) stretched vertically by a factor of \(|a|\). If \(|a|<1\) the stretch is a shrink toward the \(x\)-axis, and if \(a<0\) there is also a reflection across the \(x\)-axis.
\(f(2)=3\). What is the value of \(y=4f(x)\) at \(x=2\)?
decimals, fractions, pi and sqrt( ) are all fine
Zeros stay put. Wherever the graph crossed the \(x\)-axis it still does, because multiplying zero by anything leaves zero — so a vertical stretch pulls the curve away from that axis without ever moving the points on it.
Multiplying the input rescales the \(x\)-direction, and once again the effect is the reciprocal of what the number looks like.
The graph of \(y=f(bx)\) is the graph of \(f\) compressed horizontally by a factor of \(|b|\). If \(|b|<1\) the compression is a stretch away from the \(y\)-axis, and if \(b<0\) there is also a reflection across the \(y\)-axis.
\(f(6)=10\). For \(y=f(3x)\), which input \(x\) produces the output 10?
decimals, fractions, pi and sqrt( ) are all fine
Chapter 4 gives this one a name you will use constantly: for a wave, \(b\) controls the period, and a larger \(b\) means the pattern repeats more often in the same space.
The point \((3,5)\) lies on the graph of \(f\). Where does it end up on each of \(y=f(x)+4\), \(y=f(x-4)\), \(y=-f(x)\), \(y=f(-x)\), \(y=3f(x)\) and \(y=f(3x)\)?
| transformation | new point | what moved |
|---|---|---|
| \(f(x)+4\) | \((3,9)\) | output raised by 4 |
| \(f(x-4)\) | \((7,5)\) | input must be 4 larger to give the same output |
| \(-f(x)\) | \((3,-5)\) | output negated |
| \(f(-x)\) | \((-3,5)\) | input negated |
| \(3f(x)\) | \((3,15)\) | output tripled |
| \(f(3x)\) | \((1,5)\) | input only needs to be a third as large |
Tracking a single point is the fastest way to check a transformation, and it never lies. If you are ever unsure which way a graph moved, take one point you know and ask what input is now needed to produce its output.
Now all five at once. The general form is
$$y=a\,f\big(b(x-c)\big)+d,$$with \(a\) and \(d\) acting on the output and \(b\) and \(c\) acting on the input. Order matters when you apply them by hand: work from the inside out, exactly as the machine does — horizontal shift and stretch first, then the vertical ones.
| acts on | effect | watch out | |
|---|---|---|---|
| \(+\,d\) | output | shift up | — |
| \(-\,c\) inside | input | shift right | opposite sign |
| \(a\,\times\) | output | stretch vertically | negative also flips |
| \(b\,\times\) inside | input | squeeze horizontally | reciprocal, and negative also flips |
Describe how to obtain the graph of \(y=-2\sqrt{x+3}+1\) from the graph of \(y=\sqrt{x}\), in the correct order.
Read it from the inside out, because that is the order the machine works in.
The starting point of the graph moves from \((0,0)\) to \((-3,1)\), and the curve now falls instead of rising. Check with a single value: at \(x=1\), \(y=-2\cdot2+1=-3\).
Given two functions you can add, subtract, multiply and divide them pointwise: \((f+g)(x)=f(x)+g(x)\), and so on. The domain of the combination is where both are defined — and for the quotient, also where \(g(x)\neq0\).
The composition of \(f\) and \(g\) is $$(f\circ g)(x) = f(g(x)),$$ read "\(f\) after \(g\)": run \(g\) first, then feed its output into \(f\). Its domain is the set of \(x\) in the domain of \(g\) whose output \(g(x)\) lies in the domain of \(f\).
\(f(x)=x^{2}\) and \(g(x)=x+1\). Find \((f\circ g)(2)\).
decimals, fractions, pi and sqrt( ) are all fine
Let \(f(x)=x^2\) and \(g(x)=x-3\). Find \(f\circ g\) and \(g\circ f\), and evaluate both at \(x=5\).
\((f\circ g)(x)=f(x-3)=(x-3)^2\). At 5: \(4\).
\((g\circ f)(x)=g(x^2)=x^2-3\). At 5: \(22\).
Composition is not commutative. This is not a technicality — it is the reason matrix multiplication in Chapter 7 is not commutative either, since matrices are functions being composed.
Write \(H(x)=\sqrt{4+3x^2}\) as a composition of simpler functions.
Ask what you would do first with a calculator: square, multiply by 3, add 4, take the root. So with \(g(x)=4+3x^2\) and \(f(u)=\sqrt u\), we get \(H=f\circ g\). You could go further and split \(g\) itself into three steps. Decomposing like this is exactly what the chain rule will ask of you next year.
Composition is how complexity is built out of simplicity everywhere in mathematics and in computing. A neural network with twelve layers is twelve functions composed. A photo filter is a composition. A proof is a composition. It is also how complexity is tamed: faced with something intricate, the first move of a mathematician is to ask which simple steps it is made of, and in what order.
Each panel below is the parabola \(y=x^2\) after one transformation. Match them to \(y=(x-2)^2\), \(y=x^2-2\), \(y=-x^2+3\), \(y=(2x)^2\).
A is \(y=(x-2)^2\) — the whole curve slid right, because the input was intercepted and reduced by 2 before the squaring happened.
B is \(y=x^2-2\): the subtraction happens after the squaring, so it moves the output down.
C is \(y=-x^2+3\): the minus sign flips it, the \(+3\) lifts it.
D is \(y=(2x)^2\): every input is doubled before squaring, so the curve reaches any given height twice as soon — it looks squeezed horizontally. (It is also \(4x^2\), a vertical stretch by 4. For parabolas the two descriptions coincide; for most functions they do not.)
The reliable way to tell inside from outside: ask whether the change reaches the input before \(f\) does. Inside changes move the graph horizontally and do the opposite of what they look like. Outside changes move it vertically and do exactly what they say.
A photo app has two operations: \(B(v)=v+40\) raises every pixel's brightness by 40, and \(S(v)=1.5v\) increases contrast by scaling it. Pixel values are capped at 255. Take a pixel at \(v=150\) and apply the two operations in each order.
Brighten then contrast: \(S(B(150))=1.5(190)=285\), which caps at 255 — blown out to pure white, and the detail that was in that pixel is gone forever.
Contrast then brighten: \(B(S(150))=225+40=265\), also capped. Try \(v=100\) instead: \(S(B(100))=210\) but \(B(S(100))=190\). Different pictures.
Composition is not commutative, and here the difference is visible to the eye. This is exactly why photo editors have a layer order, and why every image processing pipeline is a carefully chosen sequence rather than a bag of effects.
A contractor is paid in euros. The bank converts euros to dollars at \(c(e)=1.08e\), then charges a flat \$5 wire fee, \(w(d)=d-5\), and finally tax withholding takes 22%, \(t(d)=0.78d\). The payment is 2,000 euros. Write the whole trip as one composition and compute what lands in the account.
The bank applies them in the order stated, so the composite is \(t(w(c(e)))\), read right to left: $$t(w(c(2000)))=t(w(2160))=t(2155)=\$1680.90.$$
Now suppose the tax were taken before the fee: \(w(t(c(2000)))=w(1684.80)=\$1679.80\). A dollar and ten cents apart, from nothing but the order.
Writing the composite as a single formula, \(0.78(1.08e-5)=0.8424e-3.90\), shows something worth noticing: a chain of linear steps collapses into one linear step. That is a small miracle, and Chapter 7 explains it — it is the reason a stack of matrix layers with nothing nonlinear between them is just one matrix, and therefore the reason neural networks need activation functions at all.
Every function throws information away, or it does not. That single distinction — whether the output still contains enough to reconstruct the input — turns out to be one of the most consequential ideas in mathematics, and the rest of the course keeps returning to it: it is invertibility in Chapter 3, it is the determinant in Chapter 7, and it is what a compression algorithm is doing on purpose.
A function \(f\) is one-to-one if different inputs always give different outputs: whenever \(x_1\neq x_2\), we have \(f(x_1)\neq f(x_2)\).
Equivalently, and more usefully in practice: if \(f(x_1)=f(x_2)\) then \(x_1=x_2\).
Graphically this is the horizontal line test: no horizontal line may meet the graph more than once. Compare it with the vertical line test, which asks whether you have a function at all. The vertical test is about the definition; the horizontal test is about whether the definition can be run backwards.
If \(f\) is one-to-one with domain \(A\) and range \(B\), its inverse \(f^{-1}\) is the function with domain \(B\) defined by $$f^{-1}(y)=x \iff f(x)=y.$$ It satisfies \(f^{-1}(f(x))=x\) and \(f(f^{-1}(y))=y\): each undoes the other.
Warning: \(f^{-1}\) does not mean \(1/f\). The notation is unfortunate and universal.
\(f(x)=3x-6\). What is \(f^{-1}(0)\)?
decimals, fractions, pi and sqrt( ) are all fine
The procedure is three lines: write \(y=f(x)\), solve for \(x\), then swap the names. Swapping the names is what reflects the graph across the line \(y=x\), since the point \((a,b)\) on \(f\) becomes \((b,a)\) on \(f^{-1}\).
Find the inverse of \(f(x)=\dfrac{2x+3}{x-1}\), and state the domain and range of both.
Set \(y=\dfrac{2x+3}{x-1}\) and solve for \(x\): $$y(x-1)=2x+3 \Rightarrow yx-y=2x+3 \Rightarrow x(y-2)=y+3 \Rightarrow x=\frac{y+3}{y-2}.$$ So \(f^{-1}(x)=\dfrac{x+3}{x-2}\).
\(f\) has domain \(x\neq1\) and range \(y\neq2\); the inverse swaps these, with domain \(x\neq2\) and range \(y\neq1\). Domain and range always trade places, which is a good check on your work.
\(f(x)=x^2\) has no inverse. Fix it.
Restrict the domain to \([0,\infty)\). On that smaller domain \(f\) is one-to-one and the inverse is \(f^{-1}(x)=\sqrt x\). Restricting to \((-\infty,0]\) instead gives the inverse \(-\sqrt x\), which is equally valid and a different function.
Nothing about \(x^2\) changed. We changed the question. This move — shrink the domain until the function becomes reversible — is exactly how the inverse trigonometric functions of Chapter 4 are defined, and it is the reason your calculator returns only one answer for \(\arcsin\).
A code is a function. Encoding is applying it; decoding is applying its inverse. A code that is not one-to-one is not a code — it is a shredder.
A shift cipher with \(k=3\) moves each letter three places along the alphabet. What does the letter X become?
one letter
Some functions destroy information by accident, and some do it on purpose. A JPEG throws away detail your eye is bad at noticing and keeps what it is good at; that is why the file is a tenth the size, and why there is no button anywhere that restores the original. An audio compressor does the same to sound. A hash function is designed so that inverting it is not merely impossible in principle but expensive in practice, which is what protects your password.
So the question is this function one-to-one? is never idle. It is the question of whether anything can be undone: a message decoded, a signal recovered, a system of equations solved, a matrix inverted. You will ask it in every remaining chapter.
Shift ciphers are named for Julius Caesar, who according to Suetonius used a shift of three for military correspondence. They were secure for roughly nine hundred years, until the polymath al-Kindi, working in ninth-century Baghdad — the same intellectual world that gave us the word algebra — wrote the first known account of frequency analysis: count how often each symbol appears, compare with the natural frequencies of the language, and the shift falls out immediately.
That is a striking thing to notice. Al-Kindi's attack works because the code preserves too much structure. Being one-to-one makes a code usable; it does not make it safe.
European and US shoe sizes are related by \(E(u)=1.27u+30.8\), rounded to the nearest half size. What should someone who wears a US 10.5 ask for in Milan? And if a shop says a shoe is EU 39, what is that in US sizes?
\(E(10.5)=1.27(10.5)+30.8=44.1\), so EU 44.
For the reverse, invert: \(e=1.27u+30.8 \Rightarrow u=\dfrac{e-30.8}{1.27}\), so \(E^{-1}(39)=\dfrac{8.2}{1.27}\approx 6.5\).
Notice the rounding, though. \(E\) is one-to-one as a formula on the reals, but the rounded version is not: US 10.4 and US 10.5 both land on EU 44. The inverse of the rounded function does not exist, which is precisely why converted sizes never quite fit and why every shop tells you to try them on.
A website stores your password by applying a function \(H\) and keeping only the output. When you log in, it applies \(H\) to what you typed and compares. Why is it important that \(H\) is not invertible in practice — and why must it still be a function?
It must be a function because the same password must always produce the same output; otherwise you could never log in twice.
It must be hard to invert because the stored outputs will eventually be stolen. If \(H\) could be run backwards, the thief would have every password. A hash is chosen so that going forwards is instant and going backwards is, as far as anyone knows, hopeless — even though an inverse exists in the abstract for any one-to-one \(H\).
So there are three grades of undoability worth keeping separate: invertible (a shift cipher — run it backwards in a second), not invertible at all (the genetic code, or a function that maps many inputs to one output), and invertible in principle but not in this universe (a cryptographic hash). Modern security lives entirely in that third category.
For each, decide whether the process is one-to-one, and say what is lost if not.
(a) One-to-one, with a catch: with the gaps between letters preserved, yes. Strip the gaps and it is not — the same dot-dash stream can be read several ways.
(b) Not one-to-one. Three numbers per pixel become one, so an enormous amount of information is discarded; no "uncolourise" button can be honest, only a plausible guess.
(c) Not one-to-one: the order was thrown away, and \([3,1,2]\) and \([2,1,3]\) sort to the same list.
(d) One-to-one, inverse \(\dfrac{x+1}{6}\).
(e) Not one-to-one, deliberately: 91 and 97 both become A. That is the purpose of grades — to discard detail that we judge not worth carrying. Every summary statistic you will ever compute is a non-invertible function, and the whole craft is choosing what to lose.
You now have the vocabulary the whole course runs on: a function as a rule moving information, a graph as its portrait, the translation between algebra and geometry, transformations as a way of seeing whole families at once, and invertibility as the question of whether anything was lost.
Chapter 2 asks the next question, and it is the one that opens calculus: not what does this function do, but how fast is it doing it. On the way it will ask how much a curve bends — which turns out to explain why folding a slice of pizza stops it flopping — and it will end by building complicated functions out of nothing but powers of \(x\), so that a machine with only arithmetic can compute a square root.
It is worth saying plainly what calculus will and will not be. It is not a new subject that replaces this one. It is this one, with a single extra move performed at the end of every argument: let the step shrink.
You will compute an average rate of change over an interval; calculus lets the interval shrink to nothing and calls the result a derivative. You will estimate an area with rectangles; calculus lets the rectangles thin out and calls the result an integral. You will approximate a curve with a polynomial of degree three; calculus keeps going and calls the result a series. In every case the object you build here is the honest, computable, slightly-wrong version, and the limit is the icing.
That is also why we will not pretend the world is flat. Graphs bend, surfaces curve, and a shortest path on a sphere is not a straight line. You will meet the bending in Chapter 2 and again on the sphere in Chapter 5, long before anyone hands you the machinery for it — because the machinery is easier to want once you have already seen what it is for.
Next: Chapter 2 — Flat and curved functions.