Learn · 4 min read
What Is a Function? Domain, Range, and Notation
A function is a rule with a promise
A function is a rule that takes each input value and assigns it exactly one output value. That word "exactly" does all the work: a function can never hand the same input two different outputs. If you feed in x = 2, the function gives you back one answer, and if you feed in 2 again tomorrow, you get the same answer. Mathematicians call this requirement "well-defined," and it is what separates functions from looser kinds of relationships between quantities.
Consider f(x) = x^2. The input 3 produces the output 9, and the input −3 also produces 9. That is fine — two different inputs may share an output. What would not be fine is if the rule assigned both 9 and 10 to the input 3. Then the rule would not be a function at all.
The notation f(x) and what it means
The expression f(x) is read "f of x," and it names the output of the function f when the input is x. The letter f is just a name; you might as well use g, h, or costOf. Writing f(x) = 2*x + 1 says: the function f computes its output by doubling its input and adding one. Then f(4) = 9, f(−1) = −1, and so on.
This notation becomes powerful when you compare functions. If g(x) = x^2, then f(g(2)) = f(4) = 9 — you fed the output of g into f. Chaining functions this way is called composition, and the notation makes it easy to track exactly which rule is applied to which value. It also lets you talk about the whole function at once ("f is increasing") rather than only about individual values.
Domain: the set of allowed inputs
Every function has a domain: the set of input values it accepts. For f(x) = x^2, any real number is allowed, so the domain is all real numbers. But g(x) = sqrt(x) refuses negative inputs — there is no real number whose square is negative — so its domain is x ≥ 0.
Sometimes the domain is restricted by the rule itself, and sometimes by the situation the function models. The function h(x) = 1/x excludes x = 0, because division by zero is undefined. And if a function models the price of n apples, its natural domain might be the counting numbers 1, 2, 3, …, even though the formula 2.5*n would happily accept fractional inputs. When you work with a function, always know which inputs it can actually take.
Range: the set of produced outputs
The range is the set of output values the function actually produces as the input runs over the domain. For f(x) = x^2, squaring never gives a negative number, and every non-negative number appears as some square (the square of its square root). So the range is all numbers y ≥ 0.
Domain and range answer different questions: the domain asks "what can I put in?" and the range asks "what can come out?" For f(x) = 2*x + 1 both are all real numbers, because doubling and shifting can reach any real value. For f(x) = sin(x) the domain is all real numbers but the range is only [−1, 1], since the sine wave oscillates between −1 and 1 forever. Noticing the range helps you read a graph: it is exactly the vertical extent of the curve.
Reading all of this from a graph
A graph shows a function directly: each point (x, y) on the curve says f(x) = y. The domain is the shadow of the curve on the x-axis — the horizontal span of points that actually appear. The range is the shadow on the y-axis. If the curve breaks or stops, those breaks show up as gaps in the domain.
There is a quick test, too: the vertical line test. If every vertical line you draw crosses the curve at most once, the curve represents a function — because each x has at most one y. A circle fails this test (a vertical line through its center meets it twice), which is why a full circle is not the graph of a single function. Try entering the expressions below in the graphing calculator, adjust the viewport, and read off each domain and range for yourself.
Try it in the calculator
Type any of these into the graphing calculator to see the ideas above in action:
- x^2
- sqrt(x)
- 1/x
- sin(x)
Key takeaways
- A function assigns exactly one output to each input — that single-output promise is the defining property.
- f(x) is "f of x": the output of f at input x. Composition f(g(x)) chains two rules.
- The domain is the set of allowed inputs; division by zero and square roots of negatives are the classic domain restrictions.
- The range is the set of outputs the function actually produces — the vertical extent of its graph.
- The vertical line test decides whether a curve is a function: any vertical line may cross it at most once.
Frequently asked questions
Is a circle a function?
No — a full circle is not the graph of a function, because some vertical lines cross it twice (failing the vertical line test). However, the upper half of a circle is: y = sqrt(r^2 − x^2) assigns each x exactly one y, and so is the lower half y = −sqrt(r^2 − x^2).
What is the difference between the domain and the range?
The domain is the set of inputs a function accepts; the range is the set of outputs it actually produces. For sin(x) the domain is all real numbers while the range is [−1, 1].
Can two different inputs give the same output?
Yes. A function must give each input exactly one output, but different inputs may share an output — for example, f(x) = x^2 gives f(3) = f(−3) = 9.