Sub topic 1
What Is a Function?
Prerequisites
This chapter assumes you can work with integers, fractions, and decimals, solve linear equations, plot points on a coordinate plane, and evaluate expressions that contain exponents and square roots.
What is a function?
A function is a rule that assigns exactly one output to each allowed input. The input is usually called x, and the output is written as f(x) or y. If one input could produce two different outputs, the rule is not a function.
Four ways to show a function
A function can be shown as:
- A mapping, with arrows from each input to its output
- A table of input-output pairs
- A graph of points on the coordinate plane
- An equation, such as y = 2x + 3
The same function as a table:
| x | f(x) = 2x + 3 |
|---|---|
| 1 | 5 |
| 2 | 7 |
| 3 | 9 |
Reading and writing f(x)
Read f(x) as "f of x." The letter f names the function, and x is the input. The notation f(x) does not mean f multiplied by x. To define a function, write the name, the input in parentheses, and the rule: f(x) = 2x + 3.
Evaluating a function at a value
To evaluate f at a value, replace every x with that value and simplify. For example, f(4) = 2(4) + 3 = 11.
def f(x):
return 2 * x + 3
print(f(4)) # 11
print(f(-1)) # 1
print(f(1) + f(2)) # 12, because 5 + 7Exercise
If f(x) = 2x + 3, what is f(-1)?
Show answer
f(-1) = 2(-1) + 3 = -2 + 3 = 1.