1. What a function is
Picture a machine. You put in a number; the machine does something to it; another number comes out. The rule the machine follows is the function.
A rule that assigns to each input from one set (the domain) exactly one output from another set (the codomain). The defining requirement: each input has exactly one output. No more, no less.
Examples of functions:
- "Multiply by $3$ and add $2$." Input $1$ gives $5$; input $-4$ gives $-10$; input $\pi$ gives $3\pi + 2$.
- "Take the square." Input $5$ gives $25$; input $-5$ also gives $25$. Two different inputs producing the same output is fine — what's not allowed is one input producing two outputs.
- The rule "give me the temperature at this time of day." For each time, there's one temperature.
And a non-example: "give me a number whose square is $x$." That rule fails because, for $x = 9$, there are two answers ($3$ and $-3$). For the rule to be a function, you have to commit to one of them — say, always the positive root. That's exactly what $\sqrt{x}$ does.
Almost every calculation in math and science assumes that the rule it's using is well-defined: feed it the same input, get the same output. A "rule" that gives different answers depending on mood isn't usable in a calculation. Functions are the formalization of "well-defined rule."
2. Function notation: $f(x)$
The standard way of writing a function is to name it (typically $f$, $g$, $h$) and write its input in parentheses. If $f$ is the function "multiply by $3$ and add $2$," then:
$$ f(x) = 3x + 2. $$The notation $f(x)$ is read "$f$ of $x$." It does not mean "$f$ times $x$." The parentheses here group an input to the function, not a factor in a product.
To evaluate a function at a particular input, substitute it in:
$$ f(1) = 3 \cdot 1 + 2 = 5, \qquad f(-4) = 3 \cdot (-4) + 2 = -10, \qquad f(\pi) = 3\pi + 2. $$The input can itself be an expression:
$$ f(a + 1) = 3(a + 1) + 2 = 3a + 5. $$Wherever the formula had an $x$, write $(a + 1)$ instead. Parentheses are crucial — they keep the substituted expression intact under the order of operations.
Mathematicians switch between names freely. You'll see $g(t)$, $h(x)$, $\varphi(\theta)$, $\sigma(n)$ — all functions, all with the same notation. The letters are conventional shorthand for which kind of function or input is at play, not anything structural.
3. Domain and range
Two sets come with every function:
- The domain is the set of valid inputs — every number for which the rule produces a sensible output.
- The range is the set of actual outputs — every value the function ever takes for some input in the domain.
For most algebraic functions on real numbers, the domain is "all real numbers" unless something would force a problem. The two main problems:
- Division by zero. $f(x) = \tfrac{1}{x - 2}$ has domain "all real numbers except $2$," because at $x = 2$ the denominator is zero.
- Square root of a negative. $f(x) = \sqrt{x - 5}$ has domain $x \geq 5$, because for $x < 5$ the inside is negative.
Finding the range from a formula can be harder. For $f(x) = x^2$, the range is "all non-negative reals" — because $x^2 \geq 0$ always, and every non-negative number is the square of something. For $f(x) = x^2 + 3$, the range is $[3, \infty)$ — every output is at least $3$.
4. Graphs and the vertical line test
The graph of a function $f$ is the set of points $(x, f(x))$ in the plane. For each $x$ in the domain, there's exactly one point on the graph.
This gives an easy visual check, the vertical line test:
A curve in the plane is the graph of a function if and only if every vertical line crosses it at most once.
A vertical line at $x = a$ corresponds to "the value of the function at $x = a$." Hitting the curve twice means the function would give two outputs for the same input — which isn't allowed. Hitting it once is fine. Hitting it not at all just means $a$ isn't in the domain.
5. Composition and inverses
Composition
If $f$ and $g$ are both functions, you can apply them one after the other. Apply $g$ first, then $f$ on the result. This is written $f \circ g$, read "$f$ of $g$":
$$ (f \circ g)(x) = f(g(x)). $$Example: $f(x) = x^2$ and $g(x) = x + 1$. Then:
$$ (f \circ g)(x) = f(g(x)) = f(x + 1) = (x + 1)^2. $$Composition is generally not commutative: $f \circ g$ and $g \circ f$ are usually different functions. With the same $f$ and $g$, $(g \circ f)(x) = g(f(x)) = x^2 + 1$, which is not $(x + 1)^2$.
Inverses
The inverse of a function $f$, written $f^{-1}$, undoes whatever $f$ did. If $f(3) = 7$, then $f^{-1}(7) = 3$. Composing a function with its inverse gives back the input:
$$ f^{-1}(f(x)) = x, \qquad f(f^{-1}(x)) = x. $$For $f(x) = 3x + 2$, the inverse is found by reversing the steps: subtract $2$, then divide by $3$. So $f^{-1}(x) = \tfrac{x - 2}{3}$.
One subtlety: not every function has an inverse. The squaring function $f(x) = x^2$ doesn't have a single inverse on all real numbers, because $f(3) = f(-3) = 9$ — given output $9$, the inverse can't decide whether the answer is $3$ or $-3$. We fix this either by restricting the domain (just non-negative numbers, say) or by accepting that the "inverse" is a multivalued thing.
The notation $f^{-1}$ is a serious source of confusion. It is not $\tfrac{1}{f(x)}$. The superscript $-1$ here means "inverse function," not "reciprocal." Trig functions get the same treatment: $\sin^{-1}(x)$ is the inverse sine, not $\tfrac{1}{\sin(x)}$. The clash is unfortunate but universal.