Evaluating Functions
Textbook Reference
| Primary source | OpenStax Calculus Volume 1, Section 1.1: “Review of Functions” |
| Direct link | https://openstax.org/books/calculus-volume-1/pages/1-1-review-of-functions |
| Supplementary | OpenStax Calculus Volume 1, Section 1.2: “Basic Classes of Functions” |
| Supplementary link | https://openstax.org/books/calculus-volume-1/pages/1-2-basic-classes-of-functions |
| Textbook used in class | Stewart, Calculus, Section 1.1: “Four Ways to Represent a Function” (Examples 2, 3, 6, 7) |
Both OpenStax sources are free and openly licensed.
Key idea
A function is a machine with one rule: one input goes in, exactly one output comes out. Function notation is just a name for that machine and a slot to drop the input into.
When you read $f(x) = 2x^2 - 5x + 1$, the letter $f$ is the name of the machine and the $x$ is a placeholder. It marks every spot where the input will go. To evaluate the function, you replace that placeholder with whatever you are given, every single time it appears, and then simplify.
This means evaluating a function is not a new skill. It is substitution, the same move you have used since you first plugged a number into a formula. The only new idea is that the thing you substitute does not have to be a number. It can be another expression, like $a$, or $a + h$, or even $-x$. The machine does not care what you feed it. It applies the same rule to the whole input.
Hold onto that picture. The single most valuable thing in this lesson, the difference quotient $\dfrac{f(a+h) - f(a)}{h}$, is nothing more than feeding the machine two nearby inputs and comparing the outputs. In Chapter 2 that exact expression becomes the derivative. You are not learning a trick you will throw away. You are learning the first half of calculus.
Prerequisite Check
Before this lesson, make sure you can do all of the following:
If substitution or expanding $(a+h)^2$ is shaky, that is the part to warm up first. Almost every error in this lesson traces back to one of those two moves.
Quick Reference
Function notation. The symbol $f(x)$ is read “$f$ of $x$.” It is one object: the output of the function $f$ at the input $x$. It does not mean $f$ times $x$.
Evaluation rule. To compute $f(\text{anything})$, replace every $x$ in the formula for $f$ with that whole input, then simplify.
| You are asked for... | You substitute... | Watch for |
|---|---|---|
| $f(3)$ | the number $3$ for every $x$ | arithmetic only |
| $f(a)$ | the symbol $a$ for every $x$ | answer stays in terms of $a$ |
| $f(a+h)$ | the whole expression $(a+h)$ for every $x$ | use parentheses; expand carefully |
| $f(-x)$ | $(-x)$ for every $x$ | sign changes; powers of $-x$ |
The difference quotient. \[ \frac{f(a+h) - f(a)}{h} \] This measures the average rate of change of $f$ between $x = a$ and $x = a + h$. It is the central computation of this section and the seed of the derivative.
Domain reminder. When a function is given by a formula with no stated domain, its domain is every input for which the formula gives a real number. The two things to exclude: inputs that make a denominator zero, and inputs that put a negative number under an even root.
Key Concepts
1. What Function Notation Means
The equation $y = 2x - 1$ defines $y$ as a function of $x$: each value of $x$ produces exactly one value of $y$. We give the rule a name and write it as $f(x) = 2x - 1$.
The notation packs three ideas into a few symbols:
- $f$ is the name of the function (the machine).
- $x$ is the input (also called the argument, or the independent variable).
- $f(x)$ is the output (the value, the dependent variable).
So $f(x) = 2x - 1$ says: “the machine named $f$ takes an input, doubles it, and subtracts one.”
The most common misreading is to treat $f(x)$ as multiplication, as if it were $f \cdot x$. It is not. The parentheses hold the input, the way the parentheses in $\sqrt{\phantom{x}}$ hold what you take the root of.
2. Evaluating at a Number
This is the base case. Replace the placeholder with the number and do the arithmetic.
Example 1. For $g(x) = x^2$, find $g(2)$ and $g(-1)$.
Goal. Substitute each number for $x$ and simplify. (This is Stewart 1.1, Example 2(b).)
\[ g(2) = 2^2 = 4 \qquad g(-1) = (-1)^2 = 1 \]
Boxed answer: $g(2) = 4$ and $g(-1) = 1$.
Recap. The output of a function at a number is just a number. Notice $g(-1) = 1$, not $-1$: the square of a negative input is positive. Writing $(-1)^2$ with the parentheses is what keeps that sign correct.
3. Evaluating at a Symbol
Nothing changes when the input is a letter instead of a number. The machine applies its rule to the symbol, and the answer stays in terms of that symbol.
Example 2. For $f(x) = 3x^2 - x + 2$, find $f(a)$ and $f(a - 6)$.
Goal. Substitute the given expression for every $x$, using parentheses, then simplify.
For $f(a)$, replace $x$ with $a$: \[ f(a) = 3a^2 - a + 2 \]
For $f(a - 6)$, replace every $x$ with the whole expression $(a - 6)$: \[ f(a - 6) = 3(a-6)^2 - (a-6) + 2 \] Expand $(a-6)^2 = a^2 - 12a + 36$: \[ = 3(a^2 - 12a + 36) - (a - 6) + 2 \] \[ = 3a^2 - 36a + 108 - a + 6 + 2 \] \[ = 3a^2 - 37a + 116 \]
Boxed answer: $f(a) = 3a^2 - a + 2$ and $f(a-6) = 3a^2 - 37a + 116$.
Recap. The two traps are both about parentheses. First, the $3$ multiplies the entire $(a-6)^2$, so expand the square before distributing the $3$. Second, the minus sign in $-(a-6)$ distributes to both terms, giving $-a + 6$, not $-a - 6$.
Important: substitute the whole input, in parentheses, everywhere. When you replace $x$ with $a - 6$, the parentheses are not optional. Writing $3a - 6^2$ instead of $3(a-6)^2$ changes the problem completely. Drop the input into a set of parentheses first, then simplify.
4. The Difference Quotient
This is the reason Section 1.1 matters for calculus. The difference quotient compares the output at $a + h$ with the output at $a$, divided by the gap $h$ between the inputs.
Example 3. If $f(x) = 2x^2 - 5x + 1$ and $h \neq 0$, evaluate $\dfrac{f(a+h) - f(a)}{h}$.
Goal. Build $f(a+h)$ by substitution, subtract $f(a)$, and simplify until the $h$ in the denominator cancels. (This is Stewart 1.1, Example 3, worked in full.)
Step 1: evaluate $f(a+h)$. Replace every $x$ with $(a+h)$: \[ f(a+h) = 2(a+h)^2 - 5(a+h) + 1 \] Expand $(a+h)^2 = a^2 + 2ah + h^2$: \[ = 2(a^2 + 2ah + h^2) - 5(a + h) + 1 \] \[ = 2a^2 + 4ah + 2h^2 - 5a - 5h + 1 \]
Step 2: subtract $f(a)$. Here $f(a) = 2a^2 - 5a + 1$. Substitute into the difference quotient: \[ \frac{f(a+h) - f(a)}{h} = \frac{2a^2 + 4ah + 2h^2 - 5a - 5h + 1 - (2a^2 - 5a + 1)}{h} \] Distribute the minus sign across the second group: \[ = \frac{2a^2 + 4ah + 2h^2 - 5a - 5h + 1 - 2a^2 + 5a - 1}{h} \]
Step 3: cancel. The $2a^2$ terms cancel, the $-5a$ and $+5a$ cancel, and the $+1$ and $-1$ cancel. Every term that survives has a factor of $h$: \[ = \frac{4ah + 2h^2 - 5h}{h} = \frac{h(4a + 2h - 5)}{h} = 4a + 2h - 5 \]
Boxed answer: $\dfrac{f(a+h) - f(a)}{h} = 4a + 2h - 5$.
Recap. The point of the algebra is to make the $h$ in the denominator disappear. As long as you keep $h \neq 0$, you can cancel it. In Chapter 2 you will then let $h$ shrink toward $0$, which sends $4a + 2h - 5$ to $4a - 5$. That limit is the derivative $f'(a)$. The difference quotient is the derivative before you take the limit.
Important: the difference quotient should simplify to remove $h$ from the denominator. If you finish and still have an $h$ on the bottom, recheck the subtraction. The constant terms and the pure-$a$ terms must cancel; only terms containing $h$ should remain in the numerator before you factor.
5. Finding the Domain of a Function
A formula is only a function on the inputs where it produces a real number. Finding the domain is finding which inputs are allowed.
The domain convention: if no domain is stated, the domain is every real input for which the formula makes sense. The two things that break a formula are dividing by zero and taking an even root of a negative.
Example 4. Find the domain of each function. (This is Stewart 1.1, Example 6.)
(a) $\;f(x) = \sqrt{x + 2}$
The square root of a negative number is not real, so we need $x + 2 \geq 0$, which means $x \geq -2$.
Domain: $[-2, \infty)$.
(b) $\;g(x) = \dfrac{1}{x^2 - x}$
Division by zero is not allowed, so we exclude inputs that make the denominator zero. Factor it: \[ x^2 - x = x(x - 1) = 0 \implies x = 0 \text{ or } x = 1 \]
Domain: all real numbers except $0$ and $1$, written \[ (-\infty, 0) \cup (0, 1) \cup (1, \infty). \]
Recap. Factor the denominator completely so you find every forbidden input, not just the obvious one. For roots, set the inside greater than or equal to zero and solve. These two checks cover almost every domain question in Calculus 1.
6. Evaluating Piecewise Functions
A piecewise function uses different rules on different parts of its domain. To evaluate it, first decide which piece the input lands in, then apply that piece’s rule.
Example 5. A function is defined by \[ f(x) = \begin{cases} 1 - x & \text{if } x \leq -1 \\ x^2 & \text{if } x > -1 \end{cases} \] Evaluate $f(-2)$, $f(-1)$, and $f(0)$. (This is Stewart 1.1, Example 7.)
Goal. For each input, check the condition first, then use the matching rule.
- $f(-2)$: since $-2 \leq -1$, use the top rule: $f(-2) = 1 - (-2) = 3$.
- $f(-1)$: since $-1 \leq -1$ (the boundary belongs to the top piece), use the top rule: $f(-1) = 1 - (-1) = 2$.
- $f(0)$: since $0 > -1$, use the bottom rule: $f(0) = 0^2 = 0$.
Boxed answer: $f(-2) = 3$, $f(-1) = 2$, $f(0) = 0$.
Recap. The boundary input is the one to slow down on. Read the inequalities carefully: $x \leq -1$ includes $-1$, so $f(-1)$ uses the top rule. Even though two formulas appear, $f$ is one function, not two.
$f(x)$ means $f$ times $x$.
This is the action-view-of-function error. The notation $f(x)$ is read “the output of the process $f$ when the input is $x$.” The letter $f$ is the name of the function -- the rule -- not a number that can be multiplied. Treating $f(x) = f \cdot x$ would mean that $f(3) = 3f$, so evaluating at $3$ and then at $6$ would give twice as much, which is false for most functions: $f(x) = x^2$ gives $f(3) = 9$ and $f(6) = 36$, not $2 \cdot 9 = 18$. The parentheses in $f(x)$ hold the input the way the symbol $\sqrt{\phantom{x}}$ holds what you take the root of -- they are structural notation, not a multiplication sign.
$f(a) = a$ so the input and output are the same thing.
This is the input-output-confusion error. The input is the number you put in; the output is what the function produces. For $f(x) = x^2$, the input $a = 3$ gives the output $f(3) = 9$. The output depends on $a$ but is not equal to $a$ unless the specific function and value happen to make them match (e.g., $f(1) = 1$ for $f(x) = x^2$, but this is a coincidence). When evaluating $f(a+h)$, the entire expression $a+h$ is the input; the output is $f(a+h)$, which means apply the rule to the whole input $a+h$. The input $a+h$ and the output $f(a+h)$ are two different objects.
Common Errors Summary
| Error | Example | Correction |
|---|---|---|
| Reading $f(x)$ as multiplication | $f(x) = f \cdot x$ | $f(x)$ is one output value; $f$ is a name, not a factor |
| Dropping parentheses on the input | $f(a-6) = 3a - 6^2 - \ldots$ | Substitute the whole input: $3(a-6)^2 - (a-6) + 2$ |
| Sign error squaring a negative | $g(-1) = -1$ | $(-1)^2 = 1$; keep the parentheses |
| Mishandling the subtracted group | $-(2a^2 - 5a + 1) = -2a^2 - 5a - 1$ | Distribute the minus to every term: $-2a^2 + 5a - 1$ |
| Leaving $h$ in the denominator | stopping at $\frac{4ah + 2h^2 - 5h}{h}$ | Factor $h$ from the numerator and cancel: $4a + 2h - 5$ |
| Forgetting to exclude domain values | domain of $\frac{1}{x^2 - x}$ stated as all reals | Exclude $x = 0$ and $x = 1$, where the denominator is zero |
Leveled Practice
Level 1 -- Direct Application
Problem 1. For $f(x) = 3x^2 - x + 2$, find $f(2)$ and $f(-2)$.
Show answer
$f(2) = 3(2)^2 - (2) + 2 = 12 - 2 + 2 = 12$.
$f(-2) = 3(-2)^2 - (-2) + 2 = 12 + 2 + 2 = 16$.
Check the signs: $(-2)^2 = 4$ (positive), and $-(-2) = +2$.
Boxed answer: $f(2) = 12$, $f(-2) = 16$.
Problem 2. For $g(x) = \dfrac{x}{x + 1}$, find $g(0)$ and $g(3)$.
Show answer
$g(0) = \dfrac{0}{0 + 1} = \dfrac{0}{1} = 0$.
$g(3) = \dfrac{3}{3 + 1} = \dfrac{3}{4}$.
Boxed answer: $g(0) = 0$, $g(3) = \dfrac{3}{4}$.
Problem 3. Find the domain of $f(x) = \dfrac{x + 4}{x^2 - 9}$.
Show answer
The only restriction is division by zero. Factor the denominator: \[ x^2 - 9 = (x - 3)(x + 3) = 0 \implies x = 3 \text{ or } x = -3 \]
Boxed answer: all real numbers except $3$ and $-3$: \[ (-\infty, -3) \cup (-3, 3) \cup (3, \infty). \]
Level 2 -- Multiple Steps
Problem 4. For $f(x) = x^2$, evaluate the difference quotient $\dfrac{f(a+h) - f(a)}{h}$ and simplify.
Show answer
$f(a+h) = (a+h)^2 = a^2 + 2ah + h^2$, and $f(a) = a^2$.
\[ \frac{f(a+h) - f(a)}{h} = \frac{a^2 + 2ah + h^2 - a^2}{h} = \frac{2ah + h^2}{h} = \frac{h(2a + h)}{h} = 2a + h \]
Boxed answer: $2a + h$.
(As $h \to 0$ this becomes $2a$, which is the derivative of $x^2$. You will prove that in Chapter 2.)
Problem 5. For the piecewise function \[ f(x) = \begin{cases} x^2 + 2 & \text{if } x < 0 \\ x & \text{if } x \geq 0 \end{cases} \] evaluate $f(-3)$, $f(0)$, and $f(2)$.
Show answer
- $f(-3)$: since $-3 < 0$, use the top rule: $f(-3) = (-3)^2 + 2 = 9 + 2 = 11$.
- $f(0)$: since $0 \geq 0$, use the bottom rule: $f(0) = 0$.
- $f(2)$: since $2 \geq 0$, use the bottom rule: $f(2) = 2$.
Boxed answer: $f(-3) = 11$, $f(0) = 0$, $f(2) = 2$.
Problem 6. For $f(x) = \dfrac{1}{x}$, evaluate the difference quotient $\dfrac{f(x) - f(a)}{x - a}$ and simplify.
Show answer
\[ \frac{f(x) - f(a)}{x - a} = \frac{\frac{1}{x} - \frac{1}{a}}{x - a} \]
Combine the top fractions over the common denominator $xa$: \[ \frac{1}{x} - \frac{1}{a} = \frac{a - x}{xa} \]
So the difference quotient is \[ \frac{\frac{a - x}{xa}}{x - a} = \frac{a - x}{xa(x - a)}. \]
Notice $a - x = -(x - a)$, so the $(x - a)$ cancels: \[ = \frac{-(x - a)}{xa(x - a)} = -\frac{1}{xa}. \]
Boxed answer: $-\dfrac{1}{xa}$.
Level 3 -- Deeper Problems
Problem 7. For $f(x) = 4 + 3x - x^2$, evaluate the difference quotient $\dfrac{f(3+h) - f(3)}{h}$ and simplify.
Show answer
First $f(3) = 4 + 3(3) - 3^2 = 4 + 9 - 9 = 4$.
Now $f(3+h) = 4 + 3(3+h) - (3+h)^2$. Expand $(3+h)^2 = 9 + 6h + h^2$: \[ f(3+h) = 4 + 9 + 3h - (9 + 6h + h^2) = 13 + 3h - 9 - 6h - h^2 = 4 - 3h - h^2 \]
Then \[ \frac{f(3+h) - f(3)}{h} = \frac{(4 - 3h - h^2) - 4}{h} = \frac{-3h - h^2}{h} = \frac{h(-3 - h)}{h} = -3 - h. \]
Boxed answer: $-3 - h$.
(As $h \to 0$, this gives $-3$, the slope of $f$ at $x = 3$.)
Problem 8. A function $f$ is even if $f(-x) = f(x)$ for every input, and odd if $f(-x) = -f(x)$. Use evaluation at $-x$ to decide whether $f(x) = x^5 + x$ is even, odd, or neither.
Show answer
Substitute $-x$ for $x$, using parentheses on every power: \[ f(-x) = (-x)^5 + (-x) = -x^5 - x = -(x^5 + x) = -f(x). \]
Since $f(-x) = -f(x)$, the function is odd.
(This is Stewart 1.1, Example 11(a). The key step is $(-x)^5 = -x^5$, because an odd power keeps the sign of the input.)
Problem 9. A rectangular storage container with an open top has a volume of $10$ cubic meters. The length of its base is twice its width. Material for the base costs \$10 per square meter and material for the sides costs \$6 per square meter. Express the cost of materials as a function of the width $w$ of the base.
Show answer
Let the width be $w$, so the length is $2w$, and let $h$ be the height. (This is Stewart 1.1, Example 5.)
The base has area $(2w)(w) = 2w^2$, so the base material costs $10(2w^2) = 20w^2$.
Two sides have area $wh$ and two have area $2wh$, so the side material costs $6\,[\,2(wh) + 2(2wh)\,] = 36wh$.
Total cost: $C = 20w^2 + 36wh$.
To remove $h$, use the volume: $w(2w)h = 10$, so $h = \dfrac{10}{2w^2} = \dfrac{5}{w^2}$. Substitute: \[ C = 20w^2 + 36w\left(\frac{5}{w^2}\right) = 20w^2 + \frac{180}{w}. \]
Boxed answer: $C(w) = 20w^2 + \dfrac{180}{w}$, for $w > 0$.
The domain is $w > 0$ because a width must be positive. This is exactly the kind of function whose minimum you will find with calculus in Chapter 3.
Mastery Checklist
You have mastered this skill when you can do all of the following without referring to notes:
Mental Model
Think of a function as a vending machine with one rule.
You drop something into the input slot (a number, a symbol, even a whole expression). The machine applies its fixed rule and hands you back exactly one output. The label on the machine, $f$, is just its name. The slot is the $x$ in $f(x)$.
Evaluation is the act of dropping something in and reading what comes out. Three things follow from the picture:
- The machine treats the whole input as one object. When you feed it $a + h$, it does not see an $a$ and an $h$ separately; it sees the single input $(a+h)$ and applies its rule to that. This is why the parentheses are mandatory.
- The domain is the set of inputs the machine accepts. A coin slot rejects a coin that is too big; a formula rejects an input that would divide by zero or take an even root of a negative. The domain is everything the machine will take.
- The difference quotient is the machine compared with itself. You feed it two nearby inputs, $a$ and $a + h$, look at how much the output changed, and divide by how much the input changed. That ratio is the average rate of change. Shrink the gap $h$ to zero and the ratio becomes the instantaneous rate of change, which is the derivative. The whole of differential calculus grows from this one comparison.
Connections
Within Functions and Limits (Chapter 1)
- Function definition and representations: Evaluation rests on knowing what a function is (exactly one output per input) and being able to read a function from a formula. Evaluation is the act of using that rule.
- Domain and range: Finding the domain, started here, is the front half of describing a function’s behavior. The range (the set of outputs the machine can produce) is the back half.
- Piecewise functions: A piecewise function is several rules under one name. Evaluating it is the same skill plus one extra step: decide which rule applies to the input first.
Toward Calculus (MATH161)
- The difference quotient becomes the derivative: The expression $\dfrac{f(a+h) - f(a)}{h}$ you simplified here is the average rate of change of $f$. In Chapter 2 you take the limit as $h \to 0$ and that ratio becomes the derivative $f'(a)$, the instantaneous rate of change and the slope of the tangent line. Every derivative formula in the course starts from a difference quotient you know how to build.
- Tangent-line slope: The slope of the line through two points on a graph is a difference quotient. As the two points slide together, the secant line becomes the tangent line, and the slope becomes $f'(a)$.
- Optimization: The container-cost problem (Problem 9) produces a function whose smallest value you will find using calculus. Setting up the function correctly, by careful substitution, is half the work of every applied max-min problem in Chapter 3.
Audience Notes
For students who find math intimidating: You already know how to do the core move. Plugging $x = 4$ into $3x - 1$ to get $11$ is evaluating a function. Every example here is that same step, sometimes with a letter instead of a number. When the input is an expression, write it inside parentheses first, then simplify slowly. The parentheses do most of the work of keeping you correct.
For career-focused students: Function notation is how every spreadsheet formula, every line of code, and every engineering model is written. f(x) in math is the same idea as a function call in Python or Java: a named rule, an input, one returned output. Reading it fluently is a skill you will use daily.
For gifted and curious students: The difference quotient is not just a calculation; it is the definition of the derivative waiting for a limit. Try computing it symbolically for $f(x) = x^n$ and watch the binomial expansion of $(a+h)^n$ produce $na^{n-1}$ as the surviving term after you let $h \to 0$. That is the power rule, derived rather than memorized.
For PhD-track students: The domain convention quietly assumes the codomain is $\mathbb{R}$. Change the codomain and the same formula can define a different function. The careful distinction between a function (rule plus domain plus codomain) and its formula is the foundation of real analysis, where two formulas can agree on every input yet a domain difference makes them different functions.
Back to Functions and Limits | Previous: Function Representations | Next: Difference Quotient