Introduction to Functions
A function is one of the most fundamental ideas in all of mathematics. Once you understand what a function is, an enormous amount of algebra, calculus, and beyond starts to make sense.
Here's the core idea: a function takes an input, does something to it, and produces exactly one output. That "exactly one" part is crucial — we'll come back to it.
What Is a Function?
Think of a function like a machine. You feed something in, it processes it according to a fixed rule, and spits exactly one result back out. Every time you feed in the same input, you get the same output — no randomness, no ambiguity.
A simple function might say: "take the input and add 3." Feed in 5, get 8. Feed in 10, get 13. Feed in -2, get 1.
Written as an equation that looks like:
$$y = x + 3$$
Here, \(x\) is the input and \(y\) is the output. You choose \(x\); the function determines \(y\).
What makes something not a function? If one input could produce more than one output. For example, the equation \(x^2 + y^2 = 25\) (a circle) is not a function — if you plug in \(x = 3\), you get \(y = 4\) and \(y = -4\). Two outputs for one input means it's not a function.
The f(x) Notation
Instead of writing \(y = x + 3\), mathematicians often write:
$$f(x) = x + 3$$
This is read as "f of x equals x plus 3." The \(f\) is just the name of the function — it could be any letter, though \(f\), \(g\), and \(h\) are most common. The \((x)\) in \(f(x)\) is not multiplication; it's telling you that \(x\) is the input variable.
This notation is useful because it lets you communicate clearly. Writing \(f(5)\) means "evaluate the function when the input is 5." Writing \(f(a)\) means "use \(a\) as the input." You'll see this everywhere in algebra and calculus.
Here are a few functions written in this notation:
$$f(x) = 2x - 7$$ $$g(x) = x^2 + 4x - 1$$ $$h(x) = \frac{1}{x}$$
Each one is a rule. Give it an input, it gives you an output.
Evaluating a Function
Evaluating a function means plugging in a specific input and finding the output. Wherever you see the variable, replace it with the given value.
Example 1
Given \(f(x) = 4x - 7\), find \(f(2)\).
Replace every \(x\) with \(2\):
$$f(2) = 4(2) - 7 = 8 - 7 = 1$$
Example 2
Given \(g(x) = x^2 + 3x\), find \(g(-2)\).
$$g(-2) = (-2)^2 + 3(-2) = 4 - 6 = -2$$
Watch the signs carefully when substituting negative numbers — that's where most errors happen.
Example 3
Given \(f(x) = x^2 - 1\), find \(f(a + 1)\).
Replace every \(x\) with \((a + 1)\):
$$f(a+1) = (a+1)^2 - 1 = a^2 + 2a + 1 - 1 = a^2 + 2a$$
This type of substitution — putting an expression in for \(x\) rather than a number — comes up often in calculus.
Domain and Range
Every function has two important sets associated with it:
- The domain is the set of all valid inputs — all the values of \(x\) you're allowed to plug in.
- The range is the set of all possible outputs — all the values the function can produce.
For \(f(x) = x + 3\), any real number is a valid input, so the domain is all real numbers. The output is always 3 more than the input, so the range is also all real numbers.
But consider \(h(x) = \frac{1}{x}\). You can't divide by zero, so \(x = 0\) is excluded. The domain is all real numbers except zero. And the output \(\frac{1}{x}\) can get arbitrarily large or small but can never actually equal zero, so the range is also all real numbers except zero.
For a deeper look, see the lesson on domain and range.
The Vertical Line Test
When a function is drawn on a graph, there's a quick visual way to check whether it really is a function: the vertical line test.
Draw (or imagine) vertical lines passing through the graph. If any vertical line crosses the graph at more than one point, the graph does not represent a function — because that would mean one input (x-value) produces two outputs (y-values).
A straight line passes the test. A parabola \(y = x^2\) passes the test. A sideways parabola \(x = y^2\) fails it — at most x-values, there are two corresponding y-values.
Independent and Dependent Variables
You'll often hear functions described in terms of independent and dependent variables.
The independent variable is the input — you get to choose it freely. In \(f(x) = 3x - 2\), \(x\) is the independent variable.
The dependent variable is the output — it depends on whatever you chose for the input. In \(f(x) = 3x - 2\), \(f(x)\) (or \(y\)) is the dependent variable.
These terms are more intuitive in real-world settings. If you're calculating how much you'll earn based on hours worked, the hours are the independent variable (you choose them) and the pay is the dependent variable (it depends on the hours). The function connects the two.
Practice Problems
Given \(f(x) = 3x + 5\), find \(f(4)\).
Show answer\(f(4) = 3(4) + 5 = 12 + 5 = 17\)
Given \(g(x) = x^2 - 2x + 1\), find \(g(3)\).
Show answer\(g(3) = 9 - 6 + 1 = 4\)
Given \(f(x) = 2x^2 - 1\), find \(f(-3)\).
Show answer\(f(-3) = 2(-3)^2 - 1 = 2(9) - 1 = 18 - 1 = 17\)
Is \(y^2 = x\) a function of \(x\)? Explain.
Show answerNo. For any positive \(x\), there are two values of \(y\) that satisfy the equation (one positive, one negative). For example, \(x = 9\) gives \(y = 3\) and \(y = -3\). One input, two outputs — not a function.
Given \(f(x) = x^2 + x\), find and simplify \(f(x + 1)\).
Show answerReplace \(x\) with \((x+1)\): \(f(x+1) = (x+1)^2 + (x+1) = x^2 + 2x + 1 + x + 1 = x^2 + 3x + 2\)
Want to see a function in action? Try plugging one into our Equation Grapher to visualize it.