A function is a rule that takes an input, does something to it, and produces exactly one output. Functions are the single most important concept in all of mathematics — virtually every advanced math topic, from calculus to statistics to machine learning, is built on them.
A function is a relationship between inputs and outputs where each input produces exactly one output. That "exactly one" part is the key — it's what distinguishes a function from a more general relationship.
Think of a function like a vending machine. You press a button (the input), and exactly one item comes out (the output). The same button always produces the same item. If pressing button B3 sometimes gave you chips and sometimes gave you a sandwich depending on mood, it wouldn't be a reliable function — it's unpredictable.
A function is a rule that assigns to each element in the domain (set of inputs) exactly one element in the range (set of outputs). Every input has one output. One input cannot produce two different outputs.
Notice what is allowed: two different inputs can produce the same output. Both pressing B3 and pressing C2 could give you the same brand of chips. That's fine. What's not allowed is one input giving two different outputs.
Instead of writing "the function that takes x and returns 2x + 3," mathematicians write f(x) = 2x + 3. This is read as "f of x equals 2x plus 3."
The letter f is the name of the function (you could also use g, h, or any letter). The x in parentheses is the input variable. The right side of the equation is the rule — what the function does to the input.
5) + 3139 (a negative squared is positive)5You can evaluate a function at any value — a number, another expression, or even another function. f(a + 1) = 2(a + 1) + 3 = 2a + 2 + 3 = 2a + 5.
The domain is the set of all valid inputs for a function — every x value the function can accept. The range is the set of all possible outputs — every value f(x) can produce.
Domain = all allowed inputs (x values). Range = all possible outputs (f(x) values). The domain is what you can put in; the range is what can come out.
Finding the domain: Look for values of x that would cause mathematical problems. Two main causes of restricted domain:
If there are no restrictions, the domain is "all real numbers," often written as (−∞, ∞) or ℝ.
If you have a graph and want to know whether it represents a function, use the vertical line test: draw (or imagine) vertical lines across the graph. If any vertical line crosses the graph at more than one point, the graph does not represent a function.
Why? A vertical line represents a single x value. If that vertical line crosses the graph twice, it means the same x value maps to two different y values — violating the "exactly one output" requirement.
A graph represents a function if and only if every vertical line crosses the graph at most once. A circle fails this test (the vertical line through the center crosses at two points). A parabola opening up passes it.
Functions are everywhere. The price of a taxi ride is a function of the distance traveled — each distance maps to exactly one price. Your weight on a scale is a function of the actual mass of your body. The temperature outside is (approximately) a function of the time of day.
In programming, functions work the same way: a function takes inputs (called arguments or parameters) and returns an output. The entire concept of functional programming is built on mathematical functions.
In economics, demand curves express quantity demanded as a function of price. In physics, position is a function of time. In data science, machine learning models are literally functions — they take features as input and output a prediction. The concept of a function is perhaps the single most broadly applicable idea in all of mathematics.
Quadratic equations define quadratic functions — parabolas. See the formula in action and explore how changing a, b, and c changes the roots.
Ready to go deeper? These are the best free resources for exploring this topic further.