AlgebraBeginner

What Are Functions?

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.

1 What Is a Function?

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.

The Formal Definition

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.

2 Function Notation: f(x)

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.

Evaluating a Function
Given f(x) = 2x + 3, find f(5)
1f(5) means: replace every x with 5
2f(5) = 2(5) + 3
3f(5) = 10 + 3
4f(5) = 13
Answer: f(5) = 13
Evaluating with a Negative Input
Given f(x) = x² − 4, find f(−3)
1Replace x with −3: f(−3) = (−3)² − 4
2Evaluate the exponent: (−3)² = 9 (a negative squared is positive)
3f(−3) = 9 − 4 = 5
Answer: f(−3) = 5

You 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.

3 Domain and Range

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 vs Range

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:

Domain restrictions to watch for
÷Division by zero: In f(x) = 1/(x − 3), the value x = 3 makes the denominator zero — undefined. Domain: all real numbers except x = 3.
Square roots of negatives: In f(x) = √(x − 2), we need x − 2 ≥ 0, so x ≥ 2. Domain: all real numbers where x ≥ 2.

If there are no restrictions, the domain is "all real numbers," often written as (−∞, ∞) or ℝ.

4 Common Types of Functions

Function types and their shapes
Linear: f(x) = mx + b. Produces a straight line. Constant rate of change.
Quadratic: f(x) = ax² + bx + c. Produces a parabola (U-shape). Rate of change itself changes.
Square root: f(x) = √x. Produces a half-curve starting at the origin. Domain: x ≥ 0.
Exponential: f(x) = aˣ. Produces explosive growth or decay. Appears in compound interest, population models, radioactive decay.
|x|Absolute value: f(x) = |x|. Always returns a non-negative value. Produces a V-shape.

5 The Vertical Line Test

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.

Vertical Line Test

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.

6 Functions in the Real World

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.

Try the Quadratic Formula Calculator

Quadratic equations define quadratic functions — parabolas. See the formula in action and explore how changing a, b, and c changes the roots.

Open Calculator →

Practice Problems

Given g(x) = 3x − 7, find g(4)
g(4) = 3(4) − 7 = 12 − 7 = 5
Given h(x) = x² + 2x, find h(−2)
h(−2) = (−2)² + 2(−2) = 4 − 4 = 0
What is the domain of f(x) = √(x + 5)?
Need x + 5 ≥ 0, so x ≥ −5. Domain: all real numbers x ≥ −5, or [−5, ∞)
Is a circle a function? Why or why not?
No. A circle fails the vertical line test. For most x values in the circle, there are two corresponding y values (top and bottom of the circle). One input, two outputs — not a function.
Given f(x) = 2x + 1, find f(a + 3)
Replace x with (a + 3): f(a+3) = 2(a + 3) + 1 = 2a + 6 + 1 = 2a + 7