Sub topic 3
Reading and Writing f(x)
What you need first
This chapter assumes you can do arithmetic with integers, fractions, and decimals. It also assumes you can substitute a number into an algebraic expression, including exponents and square roots. You should know the idea from the first two chapters: a function assigns exactly one output to each allowed input. Here you learn the shorthand that mathematicians use to write that idea down.
Why a special notation exists
Suppose you want to say, "The rule that doubles a number and adds 3, applied to the input 4, gives 11." That sentence is long, and it gets worse when you talk about several rules at once. Function notation shortens it to this:
f(4) = 11
The notation does three jobs:
- It gives the rule a name (
f). - It shows which input you are using (
4). - It states the output that results (
11).
Without it, you could not write "the output of the rule at input 4" in a few characters. You also could not tell two different rules apart on the same page.
The anatomy of f(x) = 2x + 3
Take this definition:
f(x) = 2x + 3
It has four parts.
fis the name of the function. It labels the rule and is not a number.xis the input variable, also called the independent variable. It stands for any allowed input.f(x)is the output. It is the value the rule produces for the inputx. You can also call it the dependent variable, because it depends onx.2x + 3is the expression that defines the rule. It tells you what to do to the input.
The equals sign in f(x) = 2x + 3 means "the output of f at x is defined to be 2x + 3." Much of the time you can treat f(x) and y as the same thing. Writing y = 2x + 3 and f(x) = 2x + 3 describes the same rule. The f(x) form is better because it names the rule and lets you plug in specific inputs.
How to read it aloud
Read f(x) as "f of x." Read f(4) as "f of 4." Read f(x) = 2x + 3 as "f of x equals two x plus three."
The phrase "f of 4" means "the function f applied to 4." It does not mean "f times 4."
Names and letters are your choice
The letter f is only a convention. The letters g and h come next because they follow f in the alphabet. The following definitions are all valid, and the first two describe the same rule:
| Notation | Reading | What it describes |
|---|---|---|
| `f(x) = 2x + 3` | f of x equals 2x plus 3 | A rule named f with input x |
| `g(t) = 2t + 3` | g of t equals 2t plus 3 | The same rule, named g, with input t |
| `A(r) = 3.14 r^2` | A of r equals 3.14 r squared | An approximate area of a circle with radius r |
| `C(n) = 5n + 20` | C of n equals 5n plus 20 | A cost that depends on the number of items n |
The input variable inside the parentheses is a placeholder. The functions f(x) = 2x + 3 and f(t) = 2t + 3 are the same function, because they do the same thing to every input. Only the placeholder changed.
Pick names that help the reader. In the area example, A reminds you of "area" and r reminds you of "radius." When a function has a real-world meaning, a meaningful letter makes the formula easier to follow.
You will also see y = f(x) on graphs. Here y is the vertical coordinate, and the equation says that each point on the graph is (x, f(x)). The point (4, 11) is on the graph of f(x) = 2x + 3 because f(4) = 11.
Putting a value inside the parentheses
The parentheses hold the input. You can put several kinds of things there:
- A number, as in
f(4). - A variable, as in
f(x)orf(t). - An algebraic expression, as in
f(x + 1)orf(2x).
When you put something else inside, you replace every x in the definition with that thing. The next chapter covers evaluation in full. For now, notice what the notation says. f(x + 1) means "apply the rule f to the input x + 1." It does not mean "compute f(x) and then add 1."
For f(x) = 2x + 3:
f(x + 1) = 2(x + 1) + 3 = 2x + 5f(x) + 1 = (2x + 3) + 1 = 2x + 4
The two results differ. The position of the "+ 1" matters: inside the parentheses it changes the input, and outside it changes the output.
The same ideas in code
A Python function mirrors the notation closely. The parameter x is the placeholder, the return line is the rule, and a call such as f(4) is the application to an input.
def f(x):
return 2 * x + 3
print(f(4)) # 11
print(f(-1)) # 1
print(f(1) + f(2)) # 12, because 5 + 7
print(f(4 + 1)) # 13, the rule applied to the input 5
print(f(4) + 1) # 12, the output of f(4), plus 1The last two lines show the difference between f(x + 1) and f(x) + 1 with x = 4. This is the same distinction you saw in the algebra above.
Common misreadings
Most mistakes with function notation come from reading it as ordinary algebra. These are the ones to watch for.
Reading f(x) as multiplication
In 3(x), the parentheses mean multiplication. In f(x), the f is a name and not a number, so there is nothing to multiply. If you cancel an x from "f(x) = 2x + 3" by dividing both sides by x, you have made this mistake.
The context tells you which reading applies. If f was defined as a function, f(x) is an application. If f is a plain constant such as f = 5, then f(x) would be multiplication, but that case is rare. Textbooks avoid it by using letters like a, b, and c for constants.
Distributing f over a sum
A function does not usually distribute over addition. In general:
f(a + b) ≠ f(a) + f(b)
Test it with f(x) = 2x + 3. Here f(1) + f(2) = 5 + 7 = 12, while f(1 + 2) = f(3) = 9. The two values differ, because the constant 3 is added once in f(3) and twice in the sum.
Distribution does hold for some functions. For f(x) = 2x, we get f(a + b) = 2a + 2b = f(a) + f(b). That is a property of that particular rule, not of function notation in general.
Treating f(2x) as 2f(x)
For f(x) = 2x + 3:
f(2x) = 2(2x) + 3 = 4x + 32f(x) = 2(2x + 3) = 4x + 6
The first doubles the input. The second doubles the output. They are different expressions.
Confusing the name with the input
f and x play different roles. You cannot swap f(x) for x(f). Likewise f(3) is a value, and f alone is the whole rule.
Writing function notation from a description
Often you must turn a sentence into notation. A reliable approach has three steps.
- Identify the input and give it a letter.
- Describe what the rule does to the input, in order.
- Name the function and write
name(input) = expression.
Example: "A taxi charges a flat fee of 4 dollars plus 2 dollars for each mile." The input is the number of miles, m. The rule multiplies by 2 and adds 4. Naming the function T for taxi gives:
T(m) = 2m + 4
Now T(5) = 14 reads "a 5-mile ride costs 14 dollars."
The order of operations in the description matters. "Add 3, then double" is f(x) = 2(x + 3). "Double, then add 3" is f(x) = 2x + 3. The parentheses carry the order.
A note on the arrow form
Some books write f: A → B, read as "f maps A to B." The set A is the set of allowed inputs, and B is a set that contains the outputs. A rule like x ↦ 2x + 3 (read "x maps to 2x plus 3") describes the same function without naming it. You do not need this form for the rest of the tutorial, but it appears in more formal texts. It also connects directly to the next topics: A is related to the domain, and the outputs that actually occur make up the range.
Summary of the notation
fnames the rule, andxis a placeholder for the input.f(x)is the output at inputx. Read it as "f of x."f(4)means the rule applied to 4. It is not a product.- The name of the input variable does not change the function.
- What you place inside the parentheses is substituted for every
x. Changes inside the parentheses affect the input, and changes outside affect the output.
Exercise
Let g(t) = 3t - 5. Explain in words what g(t + 2) means, and write it as a simplified expression. Then say whether it equals g(t) + 2.
Show answer
g(t + 2) means the rule g applied to the input t + 2. Substituting gives 3(t + 2) - 5 = 3t + 6 - 5 = 3t + 1. In contrast, g(t) + 2 = 3t - 5 + 2 = 3t - 3. The two expressions are different, so g(t + 2) does not equal g(t) + 2.
Exercise
A gym charges a 30-dollar sign-up fee plus 12 dollars per month. Write a function M for the total cost after n months, then state what M(6) means in words and find its value.
Show answer
M(n) = 12n + 30. M(6) is the total cost, in dollars, after 6 months. M(6) = 12(6) + 30 = 72 + 30 = 102, so the cost is 102 dollars.
Exercise
For f(x) = x^2 + 1, decide whether f(a + b) = f(a) + f(b) holds when a = 1 and b = 2. Show the two values.
Show answer
f(1 + 2) = f(3) = 3^2 + 1 = 10. f(1) + f(2) = (1 + 1) + (4 + 1) = 2 + 5 = 7. Since 10 is not 7, the equation fails for these values.