What Is a Function?
Learning objectives
- Define what a function is and use proper function notation
- Identify the domain and range of a function
- Evaluate a function at a given input
- Determine whether a rule defines a function
A function is a machine, not a formula. You feed it an input, it produces exactly one output, and it does the same thing every time you give it the same input. The formula on the inside is just one way to describe the machine, the machine itself is the rule "this input goes to that output." Once you internalise that picture, almost every confusion about functions dissolves.
The formal definition
A function from a set to a set , written , is a rule that assigns to each element exactly one element . The set is the domain (the legal inputs). The set is the codomain. The range (or image) is the subset of that actually hits: .
The phrase "exactly one" is the rule that makes a function a function. Two different inputs may share an output, that is fine, but a single input cannot fork into two outputs. If the rule "square this number" sent to both and , it would not be a function.
Notation: name, input, output
The expression has three parts. The name identifies the machine. The variable is a placeholder for the input. The expression is the recipe applied to that input. Some books write to emphasise the mapping picture, goes to .
Domain by formula
For real-valued functions, the domain is often whatever inputs the formula actually accepts. The square root refuses negative numbers in the reals, so its domain is . The reciprocal refuses because dividing by zero is undefined, so its domain is . Reading the formula and asking "what would break?" is the standard technique.
- Programming: A function in any programming language is exactly a function in this sense: a rule that takes an input and produces a unique output. The function's signature is the formal domain-range declaration.
- Economics: A demand function returns "quantity demanded" for any price; the domain is non-negative prices, and the range is non-negative quantities, economics is built on functions throughout.
- Machine Learning: A trained neural network IS a function from input vectors (images, text tokens) to output vectors (class scores, embeddings); the entire field is about finding the right function within a parameterised family.
(Pick a family in the dropdown, drag the coefficient sliders, and click anywhere on the curve to read off a specific pair. The readout names the domain and range for the family you have selected.)
Try it
- Predict first: for with negative, what does the range become? Choose the quadratic family, drag to a negative value, and verify.
- Predict first: for with , which value of must be excluded from the domain, and why? Switch to the reciprocal family, drag to , and explain in your own words.
- Pick the square-root family with . Click the curve at and read off ; verify by hand.
Pause: a rule sends , , and . Is this a function? Why or why not?
A trap to watch for
Beginners often see and read it as . It is not. The superscript on a function name denotes the inverse mapping, not the reciprocal value. If , then , not . The notation is unfortunate because on a number really does mean , but on a function it means "the rule that undoes ." Read the symbol in context: if there is a function name to its left, it is an inverse, not a reciprocal.
What you now know
You can recognise a rule as a function (or reject it because some input has two outputs), identify domain and codomain, evaluate a function at a chosen input, and find the natural domain implied by a formula by asking what would make the formula break. The next section narrows the focus to a single very well-behaved family, the polynomials, where the domain question never arises because every real input is legal.
Quick check
Mark section complete →
References
- Lang, S. (1971). Basic Mathematics. Springer. Chapter 13: the function-as-machine viewpoint Lang uses to bridge from algebra to analysis.
- Spivak, M. (2008). Calculus, 4th ed. Publish or Perish. Chapter 3: rigorous treatment of functions, domains, and graphs.
- Stewart, J. (2015). Calculus: Early Transcendentals, 8th ed. Cengage. Sections 1.1–1.2, standard pedagogical treatment with many worked examples.