Note · Fundamental concepts
What is a function in math? Inputs, outputs and graphs
A function in math is a rule that gives exactly one output for each input, like a taxi fare worked out from the miles driven. How to write one, read its graph and tell the main kinds apart.
Comments marked the Graphite mark are Graphite’s.
Graphite’s comments.
Contents · 7 sections
A function in math is a rule that takes an input and gives back exactly one output. Put in the number of miles a taxi drives and the fare rule gives one price; put in a side length and the area rule gives one area. The inputs and outputs are usually numbers, but they don't have to be. What makes something a function is only this: the same input always gives the same single output.
In short
- A function pairs each allowed input with exactly one output; many inputs may share an output, but no input gets two.
- It can be written as a formula, f(x) = 3 + 2x, shown as a table of pairs, or drawn as a graph.
- Linear, quadratic and exponential functions start out looking alike and then grow at completely different speeds.
What makes a rule a function?
The everyday picture is a vending machine. Press B4 and you get the same snack every time. A machine that sometimes gave crisps and sometimes a drink for B4 would be broken, and in mathematics that rule would not be a function. Two buttons giving the same snack is fine. So "exactly one output for each input" is the whole requirement, and it runs one way only.
Some examples help fix the line. "Each person's birth date" is a function of the person: everyone has one. "Each person's children" is not, because one input can have several outputs, or none. "The square of a number" is a function, since 3 and −3 both give 9 and that is allowed. Going backward, "the number whose square is 9" is not, because it has two answers. That is why the square root sign √9 is defined to mean only the positive answer, 3: the choice turns the rule into a function.
The set of allowed inputs is called the domain, and the set of outputs that actually come out is the range. A rule like 1 divided by x has every number except 0 in its domain, since dividing by zero gives no answer. In the formal language of set theory, a function is just a set of input-output pairs in which no input appears twice. The inputs needn't be numbers: a function can take a word and return its length, or take a photograph and return a label.
How do you write a function down?
The usual notation is f(x), read "f of x". The letter f names the rule, x stands for the input, and f(x) is the output. Leonhard Euler first wrote functions this way in 1734. Writing f(x) = 3 + 2x says: to get the output, double the input and add 3. Then f(5) means "the output when the input is 5", which is 3 + 10 = 13. The x is only a placeholder; f(t) = 3 + 2t is the same function.
Take a real one. A taxi charges 3 dollars to start and 2 dollars a mile. The fare is a function of the miles, m: fare(m) = 3 + 2m. As a table:
| Miles, m | Fare, 3 + 2m |
|---|---|
| 0 | 3 dollars |
| 1 | 5 dollars |
| 2 | 7 dollars |
| 5 | 13 dollars |
| 10 | 23 dollars |
To draw its graph, put miles along the horizontal axis and fare up the vertical one, and mark each pair as a point: (0, 3), (1, 5), (2, 7) and so on. The points fall on a straight line that crosses the vertical axis at 3, the starting charge, and climbs 2 for every 1 across, the price per mile. Reading the graph backward answers a different question: a 19 dollar ride was 8 miles.
A graph also gives a quick test. A curve is the graph of a function only if no vertical line crosses it more than once, because a vertical line marks one input, and two crossings would mean two outputs. A circle fails: the line through its middle hits it twice.
How do linear, quadratic and exponential functions differ?
Three families come up again and again, and the most useful thing to know about them is how fast they grow. A linear function adds the same amount at each step, like 2x. A quadratic function squares the input, like x², so it adds a bit more each time. An exponential function multiplies by the same factor at each step, like 2^x, which doubles.
| Input x | Linear, 2x | Quadratic, x² | Exponential, 2^x |
|---|---|---|---|
| 1 | 2 | 1 | 2 |
| 2 | 4 | 4 | 4 |
| 3 | 6 | 9 | 8 |
| 5 | 10 | 25 | 32 |
| 10 | 20 | 100 | 1,024 |
| 20 | 40 | 400 | 1,048,576 |
At an input of 2, all three give exactly 4, and by 20 they are worlds apart. Their graphs show the same thing: a straight line, a U-shaped curve called a parabola, and a curve that hugs the axis and then shoots up. Mistaking one kind for another is behind many bad forecasts, which is why exponential growth gets a note of its own.
Where do functions show up outside math class?
In a spreadsheet, a formula is a function. Typing =3+2*A2 into cell B2 makes B2's value a function of A2's: change the miles in A2 and the fare in B2 follows. Fill the formula down a column and you have built the taxi table above.
In code, functions are named and reused. In Python, def fare(miles): return 3 + 2 * miles defines the taxi rule once, and fare(10) returns 23 wherever it is called. Most programming languages work this way, and a function that calls itself to solve a smaller copy of its own problem is the idea behind recursion.
Here the simple picture needs a warning. A programming "function" is not always a function in the mathematical sense. One that returns a random number, or the current time, can give different outputs for the same input, and one that also prints, saves or deletes something does more than turn inputs into outputs. Programmers call the kind that behaves like a mathematical function a pure function, and value it because it is easy to test.
Science uses functions to state laws. The distance a dropped stone falls is a function of time, about 4.9t² meters after t seconds. In machine learning, training a model means searching for a function, from an image to a label or from a sentence to the next word, that fits millions of examples.
What do people most often get wrong?
The most common mistake is to think a function must be a formula. Many aren't: a table of the high temperature for each day of 2025 is a function of the date, though no tidy formula produces it. The rule only has to give one answer per input.
The second is to read f(x) as "f times x". The brackets mean "applied to", not multiplication, so f(2 + 3) is f(5), and it is not f(2) + f(3) unless the function happens to behave that way. For the fare, f(2) + f(3) is 7 + 9 = 16, while f(5) is 13, because the 3 dollar start is counted twice.
What comes after functions?
Once a quantity is a function of another, the next question is how fast it changes. The taxi fare rises at a steady 2 dollars a mile, the slope of its line. For curved graphs the rate changes from point to point, and measuring it exactly is the job of the derivative, the first idea of calculus. Undoing a function, getting from the output back to the input, leads to inverse functions, and the inverse of an exponential function is the logarithm. The working tool for all of it is algebra.
Check yourself
- Without looking back, explain why "the square of a number" is a function but "the number whose square is 9" is not.
- What do the 3 and the 2 in fare(m) = 3 + 2m each look like on the graph?
- Why can a function in a computer program fail to be a function in the mathematical sense?
Sources
- The function concept — MacTutor History of Mathematics, University of St Andrews
- Functions and function notation — OpenStax, College Algebra 2e, Rice University, 2021
- Defining functions, in the Python tutorial — Python Software Foundation
- Function (mathematics) — Wikipedia