The last section filled in a recipe once, by hand. But the whole point of a recipe is that you use it again and again. Put in 2 and 3, get 2.6. Put in 4 and 1, get 3.2. Put in new numbers, get a new answer. A rule that turns an input into an answer, every time, is the most important object in this course. Why do we care? Because a neural network, when we finally meet one, is nothing but a very long rule of this kind. This section gives the rule its name and its notation.
Go back to the kitchen. A blender is a machine. Fruit goes in the top, one smoothie comes out the spout. Same fruit in, same smoothie out, every single time. That sameness is what math calls a function. Put a number in, get one number out, and the same number in always gives the same number out.
The writing f(x) = 2x + 3 is the label on the blender. The letter f is the blender's name. The x inside the brackets is the hole in the lid where you drop the fruit. The rest, 2x + 3, is what the blades do: double it, then add 3. When you read f(2) = 7, say it as "f of 2 is 7." It means "drop in a 2 and a 7 comes out." The brackets are the top of the blender, not a times sign. Nobody multiplies a blender by 2.
A table of values is the blender's record book: this went in, that came out. Some blenders have two holes in the lid, one for each item. The recipe from the last section is one of those. Two numbers go in, one number comes out. And the rule is strict in one direction only. One input can never give two different outputs. But two different inputs are allowed to give the same output, the way a 2 and a -2 both square to 4.
Take the rule "double the number, then add 3." Put in 2: 2 \times 2 + 3 = 7. Put in 0: 0 + 3 = 3. Put in 5: 10 + 3 = 13. Each input gives exactly one answer.
A function is a rule that takes an input and returns exactly one output. A machine is the picture to keep in mind: a box with a slot on the left where a number goes in and a slot on the right where one number comes out. The number going in is the input. The number coming out is the output.
The notation is f(x) = 2x + 3. Read it symbol by symbol. f is the machine's name. The x in parentheses is the input slot. The right-hand side is what the machine does to whatever sits in the slot. Then f(2), read "f of 2," means "the output when the input is 2." So f(2) = 7, f(0) = 3, and f(5) = 13. The parentheses here do not mean multiply. f(2) is not f times 2.
A table of values lists inputs beside their outputs:
| input x | 0 | 1 | 2 | 3 | 5 |
|---|---|---|---|---|---|
| output f(x) | 3 | 5 | 7 | 9 | 13 |
A machine can have two input slots. Write g(x_1, x_2) = 0.5\,x_1 + 0.2\,x_2 + 1. Then g(2, 3) means "put 2 in the first slot and 3 in the second," and g(2, 3) = 1 + 0.6 + 1 = 2.6. The order of the inputs matters: g(3, 2) = 1.5 + 0.4 + 1 = 2.9, a different number.
Two cautions. First, "exactly one output" is the whole definition. A rule that could give two different answers for the same input is not a function. Second, the reverse is allowed: two different inputs may share an output. For h(x) = x^2, both h(2) and h(-2) equal 4.
Double it, then add 3
The first box doubles the input and the second adds 3, so the pair together is f(x) = 2x + 3. Work out f(2) on paper first, then click the chip 2 and press Check. Then try 0, 5, and −1 and fill in your own table of values.
Loading interactive…
Right on try — credit. Right — the answer had already been shown, so no credit this time. Next try is worth Answer shown after three tries — this one no longer earns credit. You chose to see the answer — this one earns no credit.
What this task checks
Structure checked automatically. Whether your ideas are convincing isn't graded, so reread with the checklist.
The compiler says
A model answer
Correct answer
Also accepted:
Why
Why
Is it a function?
A function gives exactly one output for each input. Read each rule and sort it: one answer every time, or not.
Loading interactive…
Right on try — credit. Right — the answer had already been shown, so no credit this time. Next try is worth Answer shown after three tries — this one no longer earns credit. You chose to see the answer — this one earns no credit.
What this task checks
Structure checked automatically. Whether your ideas are convincing isn't graded, so reread with the checklist.
The compiler says
A model answer
Correct answer
Also accepted:
Why
Why
The record book of f(x) = 2x + 3, drawn on a line
Each mark is one output from the table of values. Look at the gaps between neighbouring marks before reading the labels: what do you notice about them?
Loading interactive…
Worked example
Basic: evaluate f(2) for f(x) = 2x + 3
-
1
The machine is f(x) = 2x + 3. Find f(2).
-
2parentheses here mean multiply: 2 times 2
f(2) means "replace every x with 2." Write the 2 inside parentheses where the x was: f(2) = 2(2) + 3.
parentheses here mean multiply: 2 times 2
-
3
Multiply first, then add: f(2) = 4 + 3.
-
4\boxed{f(2) = 7}
Say it as "f of 2 is 7." Input 2, output 7.
Worked example
Typical: a two-input machine, and why the order of the inputs matters
-
1
Let g(x_1, x_2) = 0.5\,x_1 + 0.2\,x_2 + 1. Find g(4, 1) and g(1, 4).
-
2
For g(4, 1), the 4 goes in the first slot and the 1 in the second: g(4, 1) = 0.5(4) + 0.2(1) + 1 = 2 + 0.2 + 1 = 3.2.
-
3
For g(1, 4), swap them. The 1 takes the first slot, the 4 the second: g(1, 4) = 0.5(1) + 0.2(4) + 1 = 0.5 + 0.8 + 1 = 2.3.
-
4\boxed{g(4, 1) = 3.2, \qquad g(1, 4) = 2.3}
Same two ingredients, different slots, different dish. The first slot multiplies by 0.5 and the second by 0.2, so it matters which number goes where.
Worked example
Common trap: reading f(2) as f times 2
-
1
A student sees f(x) = 2x + 3 and f(2) = 7, and concludes that f must equal 3.5, because "f times 2 is 7." Where did this go wrong, and what is f(10)?
-
2treating the machine's name as a number
The wrong belief: f(2) is a product. Then f \cdot 2 = 7 gives f = 3.5, and f(10) would be 3.5 \times 10 = 35.
treating the machine's name as a number
-
3
But f is not a number. It is the name of a rule. f(2) means "run the rule on 2," and the rule is 2x + 3: f(10) = 2(10) + 3 = 23.
-
4\boxed{f(10) = 23,\ \text{not } 35}
The tell is that 35 came from never using the "+3" at all. If a calculation with f never touches the rule on the right-hand side, the parentheses were misread as multiplication.
Where this goes next
This course, Chapter 2 and Chapter 4
Chapter 2, "From a linear model to a neuron," opens with a machine with two input slots, the very g(x_1, x_2) above. It then bolts a second machine onto the output, so 2.6 goes in and 0.931 comes out. That is two machines in a row, the output of one feeding the input of the next, exactly what the widget's two boxes do. Chapter 4, in the section "A network is a function built from functions," stacks many such machines. Every neural network in the book is a function: numbers in, numbers out, one answer per input. When a later chapter writes \hat{y} = f(x), it is saying nothing more than "the network's output for the input x," and the parentheses mean "of," never "times."
Check your understanding (counts toward your progress)
Let h(x) = x^2. Find h(-3).
Right on try — credit. Right — the answer had already been shown, so no credit this time. Next try is worth Answer shown after three tries — this one no longer earns credit. You chose to see the answer — this one earns no credit.
Why
(-3)^2 = (-3)(-3) = 9. Squaring a negative number gives a positive one. Note that h(3) is also 9: two inputs may share an output.
Correct answer
Also accepted:
Why
If f(x) = 2x + 3 and f(a) = 21, what is a?
Right on try — credit. Right — the answer had already been shown, so no credit this time. Next try is worth Answer shown after three tries — this one no longer earns credit. You chose to see the answer — this one earns no credit.
Why
2a + 3 = 21, so 2a = 18 and a = 9. Undo the machine's steps in reverse: subtract 3, then halve.
Correct answer
Also accepted:
Why
If f(x) = 2x + 3, find f(4).
Right on try — credit. Right — the answer had already been shown, so no credit this time. Next try is worth Answer shown after three tries — this one no longer earns credit. You chose to see the answer — this one earns no credit.
Why
Replace x with 4: 2(4) + 3 = 8 + 3 = 11.
Correct answer
Also accepted:
Why
Check your understanding (counts toward your progress)
Let g(x_1, x_2) = 0.5\,x_1 + 0.2\,x_2 + 1. If x_1 = 2 and g(2, x_2) = 3, what is x_2?
Right on try — credit. Right — the answer had already been shown, so no credit this time. Next try is worth Answer shown after three tries — this one no longer earns credit. You chose to see the answer — this one earns no credit.
Why
1 + 0.2\,x_2 + 1 = 3, so 0.2\,x_2 = 1 and x_2 = 5.
Correct answer
Also accepted:
Why
Let g(x_1, x_2) = 0.5\,x_1 + 0.2\,x_2 + 1. Find g(6, 5).
Right on try — credit. Right — the answer had already been shown, so no credit this time. Next try is worth Answer shown after three tries — this one no longer earns credit. You chose to see the answer — this one earns no credit.
Why
First slot 6, second slot 5: 3 + 1 + 1 = 5.
Correct answer
Also accepted:
Why
Practice: Functions, from f(2) to two input slots (5 problems · doesn’t affect your progress)
Which is the correct way to say f(3) = 9 out loud?
Right on try — credit. Right — the answer had already been shown, so no credit this time. Next try is worth Answer shown after three tries — this one no longer earns credit. You chose to see the answer — this one earns no credit.
Why
The parentheses after a machine's name mean "of." The 3 went in and the 9 came out.
"f of 3 is 9": input 3, output 9.
If f(x) = 2x + 3, evaluate f(10).
Right on try — credit. Right — the answer had already been shown, so no credit this time. Next try is worth Answer shown after three tries — this one no longer earns credit. You chose to see the answer — this one earns no credit.
Why
2(10) + 3 = 23.
Correct answer
Also accepted:
Why
If p(x) = x^2 - 1, find p(-4).
Right on try — credit. Right — the answer had already been shown, so no credit this time. Next try is worth Answer shown after three tries — this one no longer earns credit. You chose to see the answer — this one earns no credit.
Why
(-4)^2 = 16, then 16 - 1 = 15.
Correct answer
Also accepted:
Why
Let g(x_1, x_2) = 0.5\,x_1 + 0.2\,x_2 + 1. Evaluate g(0, 10).
Right on try — credit. Right — the answer had already been shown, so no credit this time. Next try is worth Answer shown after three tries — this one no longer earns credit. You chose to see the answer — this one earns no credit.
Why
0 + 2 + 1 = 3. The first slot contributes nothing when it holds a zero.
Correct answer
Also accepted:
Why
If f(x) = 2x + 3, find f(f(1)): run the machine twice, feeding the first output back in.
Right on try — credit. Right — the answer had already been shown, so no credit this time. Next try is worth Answer shown after three tries — this one no longer earns credit. You chose to see the answer — this one earns no credit.
Why
f(1) = 5. Then f(5) = 2(5) + 3 = 13. Two machines in a row, exactly what later chapters do with layers.
Correct answer
Also accepted:
Why