f(x) · Function
Put something in, one thing comes out — a function.
We've been using 'boxes' that turn one thing into another for a very long time.
Distinguish one output for each input from a one-to-one correspondence.
Start with a simple calculation rule and a number table.
The single box on which half of all mathematics is built.
Open the immersive version →A reading path containing this lesson: From input to output · 1/3
What comes out for the same input?
Imagine a rule that doubles an input and adds 1. Input 1 gives 3; input 2 gives 5. We can write the rule as f(x)=2x+1.
The letter f names the rule and x is the input. f(x) is the resulting output, not f multiplied by x. We can also represent the rule in a table or as points on a graph.
A function assigns exactly one output to each allowed input. Different inputs may share an output: for f(x)=x², both 2 and −2 give 4.
If the same input is assigned two different outputs, it fails the function rule for that input. A unique output for each input is different from requiring distinct inputs to have distinct outputs.
We must also specify which inputs are allowed. In the real-valued rule f(x)=1/x, zero is not allowed. Read the input domain together with the expression.
Read these symbols together
- f(x)
- The output obtained by applying function f to input x.
- x ∈ D
- D is the set of allowed inputs, called the domain.
Pause and try it yourself
Make a prediction first. Change one input at a time and compare what happens with what you expected.
A box that always turns an apple into apple juice, even if you don't know what happens inside — we can call a device like this a box. Could there be a box that eats numbers too?
Experiment 1 — The mystery box
Experiment 2 — The broken box
This box always gets fed the same number, 5. Feed it a few times.
Experiment 3 — Build your own Function
Pick two parts and drop them into the box. A function that never existed before is born.
A table, graph and expression can describe the same rule
A function isn't a symbol — it's a promise.
The notation f(x) may look intimidating, but its meaning is just a promise: 'put something in, and something determined comes out.' Science and engineering stand on functions precisely because that promise makes prediction possible.
A graph is a single photograph of a rule.
Plot every possible input–output pair as a point and you get a graph. Reading a graph means seeing infinitely many calculated results at a single glance.
The promise of one output for each input
Write the promise you saw in the vending-machine experiment — 'one input, one output' — in the language of mathematics, and you get the following.
Function notation
Feed in an element x of X (the domain) and out comes an element f(x) of Y. f is the machine's name, x is the input, f(x) is the output.
The condition for being a function
Equal inputs must give equal outputs. The 'broken vending machine' in the experiment violated exactly this condition.
Definition of a graph
The collection of every (input, output) pair, plotted on the coordinate plane. If a single vertical line hits the graph twice, it isn't a function (the vertical line test).
The linked example concerns real-valued random variables.
References
- OpenStax · Principles of Data Science · 3.5 Random variables
Make one more distinction
A function needs a formula, like y = f(x).
A formula is just one way to write down a function. A price table, a dictionary (word → meaning), a vending machine's buttons — all of these are functions too. What matters is the promise 'one input, one output', not the formula.
If the output is always the same, it isn't a function (e.g. a machine that always spits out 7).
It's the opposite. Different inputs are allowed to produce the same output (a constant function is still a function). What's forbidden is a single input having multiple outputs.
Where else can this idea help?
Price tables and policy
Taxi fares, income tax, shipping fees — most of society's rules are designed as functions where the output (amount) is determined by the input (distance, income, weight).
The 'function' in programming
A function in code borrows its name from the mathematical function. The more a function behaves like a pure function — same input, same output — the fewer bugs it tends to have.
AI models
Even ChatGPT is, at bottom, a giant function from 'input sentence' to 'output probabilities'. Learning AI means learning how to find a good function.
Unit conversion
Celsius to Fahrenheit, won to dollars — every converter is a function. You trust it because the same input always gives the same output.
Explain it in your own words
Compare with one possible explanation
Under x², 2 and −2 share output 4, but each input has one output. That satisfies the function rule.
Try another question
Q1Suppose f(3) = 9 and f(−3) = 9. One output (9) has two inputs — is this still a function?Show answer ▾
Yes, it's still a function (f(x) = x² works exactly like this). What's forbidden is 'one input, multiple outputs'; 'multiple inputs, one output' is allowed. Mixing up the direction is the most common mistake here.
Q2Is 'student → assigned seat' a function? What about 'seat → student'?Show answer ▾
With assigned seating, both are functions (one seat per student, one student per seat). When a relationship is a function in both directions, an 'inverse function' exists — meaning the relationship can be reversed.
Q3A shipping price table: up to 5kg costs $4, up to 10kg costs $6. Is the fee for a 7.3kg box uniquely determined? Is this a function?Show answer ▾
Yes — it's determined: $6. It's defined by a table rather than a formula, but each input (weight) maps to exactly one output (fee), so it's a complete function. The essence of a function is reliability of the rule, not a formula.
Try answering yourself before revealing it — getting it wrong is where learning starts.
The idea to take with you
A function assigns one output to each allowed input; different inputs may share it.
What question comes next?
A reading path containing this lesson: From input to output · 1/3
Previous concept
Equations
Where an equation finds 'the single moment things balance', a function looks at 'the entire relationship across every input'. It's the moment your view widens from a point to a relationship.
← Equations labLeads to next
Linear Functions
Now that you have the language of functions, meet the simplest and most powerful one. A relationship that changes at a constant rate — half the pricing plans in the world are this function.
Go to the Linear Functions lab →Related lab
Take-home Pay
Salary → take-home pay is a function too. See how a 'piecewise function', where the rule changes across ranges, actually works in real life.
Go to the Take-home Pay lab →Related lab
Probability
A real-valued random variable X maps an outcome ω to a number. For a die, set X(ω)=ω. The event A={2,4,6} is a set of outcomes; assigning P(A)=1/2 is the role of the probability measure P, not X.
Go to the Probability lab →