---
title: Functions and their graphs
heading: One quantity that depends on another
eyebrow: A2 · Lesson 1 · Functions and their graphs
xp: 40
---

::: hook
A capacitor's voltage depends on time. A filter's gain depends on frequency. The current through an LED depends on the voltage across it. Most of electrical engineering is one quantity depending on another, drawn as a graph. What can you read off a graph at a glance, and what does it take to answer a question like "when does the voltage reach 1 V?"

::: play
- The curve is $f(x) = x^3 - 3x$. Move the x slider: the dot sits at the point $(x, f(x))$, and its height is the output.
- Move the c slider to raise and lower the dashed line $y = c$. Every place it meets the curve is an x where $f(x) = c$.
- Find a value of c where the line meets the curve three times, and one where it meets it only once.
:::
:::

```sim plot
view: graph
x: x = -3..3
y: y = -4..4
slider: X = -3..3 step 0.05 = 1.5
slider: c = -4..4 step 0.1 = 1
plot: x^3 - 3*x | label: f(x)
plot: c | dashed | color: ch2 | label: y = c
point: X, X^3 - 3*X | label: (x, f(x))
readout: x = X
readout: f(x) = X^3 - 3*X
```

::: predict
## How many values of x make $x^3 - 3x = 1$?

- [ ] None
- [ ] One
- [ ] Two
- [x] Three

::: reveal
Three. Set c to 1 and the dashed line crosses the curve three times: once near $x = -1.5$, once near $x = -0.3$ and once near $x = 1.9$. The curve rises, turns down at $x = -1$, turns up again at $x = 1$, and that switchback lets a single level be reached three times. Above $c = 2$ or below $c = -2$ the line misses both turns and meets the curve only once.
:::
:::

::: nameit
## A function gives one output for each input

A **function** is a rule that takes an input and gives back exactly one output. Writing $f(x) = x^3 - 3x$ names the rule $f$, the input $x$ and the output $f(x)$, read "f of x". In electrical engineering the names usually say what the quantities are: $v(t)$ is a voltage at time $t$, $i(v)$ a current at voltage $v$, $H(f)$ a gain at frequency $f$.

The **graph** of a function is every point $(x, f(x))$, so:

- **Evaluating** $f(a)$ means going to $x = a$ and reading the height of the curve.
- **Solving** $f(x) = c$ means drawing the level $y = c$ and finding where it meets the curve. There may be no solutions, one or several.
- **Zeros** (or roots) are where the curve crosses the horizontal axis, the solutions of $f(x) = 0$. Here they are $x = 0$ and $x = \pm\sqrt{3}$.
- Where the curve climbs to the right, the function is **increasing**; where it falls, **decreasing**. Where it turns, it has a local maximum or minimum, like $f(-1) = 2$ and $f(1) = -2$ here.

Because a function gives only one output for each input, any vertical line meets its graph at most once. A circle fails that test, so $y$ isn't a function of $x$ on a circle, though each half of it is.

The **domain** is the set of inputs the rule accepts, and the **range** is the set of outputs it can give. $\sqrt{x}$ accepts only $x \ge 0$ and gives only outputs $\ge 0$. A function with a physical meaning often has a narrower domain than the formula: time after a switch closes starts at 0.

Functions can be chained: $f(g(x))$ means apply $g$ first, then feed its output into $f$. With $f(x) = 2x + 1$ and $g(x) = x^2$, $f(g(3)) = f(9) = 19$, while $g(f(3)) = g(7) = 49$. The order matters.

The **average rate of change** between two inputs is how much the output changed divided by how much the input changed:

$$\frac{f(b) - f(a)}{b - a}$$

It's the slope of the straight line joining the two points on the graph, and it's where calculus starts.
:::

::: example
## For $f(x) = x^3 - 3x$, find $f(2)$, then every $x$ with $f(x) = 2$.

::: solution
1. **Evaluate f(2).**
   $$\begin{aligned} f(2) &= 8 - 6 \\ &= 2 \end{aligned}$$
   so $x = 2$ is one solution of $x^3 - 3x = 2$.
2. **Rearrange.**
   $$x^3 - 3x - 2 = 0$$
3. **Factor out the known root.** Knowing the root $x = 2$ gives the factor $(x - 2)$:
   $$\begin{aligned} & x^3 - 3x - 2 \\ &= (x - 2)(x^2 + 2x + 1) \\ &= (x - 2)(x + 1)^2 \end{aligned}$$
   so the solutions are $x = 2$ and $x = -1$.
4. **Check on the graph.** The level $y = 2$ crosses the curve at $x = 2$ and just touches it at its local maximum, $(-1, 2)$.

**Answer:** $f(2) = 2$, and $f(x) = 2$ at $x = 2$ and at $x = -1$.
:::
:::

::: example
## A Pt100 temperature sensor has resistance $R(T) = 100(1 + 0.00385\,T)$ Ω, with $T$ in °C. An oven warms as $T(t) = 20 + 3t$, with $t$ in minutes. What does the sensor read after 10 minutes?

::: solution
1. **Spot the composition.** This is $R(T(t))$: find the temperature first, then the resistance.
2. **Temperature after 10 minutes.**
   $$\begin{aligned} T(10) &= 20 + 30 \\ &= 50\ \text{°C} \end{aligned}$$
3. **Resistance at 50 °C.**
   $$\begin{aligned} R(50) &= 100(1 + 0.1925) \\ &= 119.25\ \Omega \end{aligned}$$
4. **Check with a single function of time.**
   $$\begin{aligned} & R(T(t)) \\ &= 100(1 + 0.00385(20 + 3t)) \\ &= 107.7 + 1.155t\ \Omega \end{aligned}$$
   which also gives 119.25 Ω at $t = 10$.

**Answer:** after 10 minutes the oven is at 50 °C, and the sensor reads 119.25 Ω.
:::
:::

::: example
## A temperature sensor puts out $V(T) = 0.5 + 0.01\,T$ volts, with $T$ in °C. A 12-bit converter turns a voltage into a code $N(V) = 4095\,V / 3.3$, rounded. What code does 25 °C give, and what temperature does code 2000 mean?

::: solution
1. **Voltage at 25 °C.** The code is the composition $N(V(T))$, so find the voltage first:
   $$\begin{aligned} V &= 0.5 + 0.25 \\ &= 0.75\ \text{V} \end{aligned}$$
2. **Code for that voltage.**
   $$\begin{aligned} N &= \frac{4095 \times 0.75}{3.3} \\ &= 930.7 \end{aligned}$$
   which rounds to 931.
3. **Undo the converter.** Going backward, code 2000 means
   $$\begin{aligned} V &= \frac{2000 \times 3.3}{4095} \\ &= 1.612\ \text{V} \end{aligned}$$
4. **Undo the sensor.**
   $$0.5 + 0.01\,T = 1.612$$
   gives $T = 111.2$ °C. Each function is undone in turn, the last one first.

**Answer:** 25 °C gives code 931, and code 2000 means 111.2 °C.
:::
:::

::: check
given: a = 2..5 int; b = 1..9 int; x0 = -3 | -2 | -1 | 1 | 2 | 3
answer: a*x0^2 - b

## $f(x) = \given{a}x^2 - \given{b}$. What is $f(\given{x0})$?

::: right
Right. Square {x0} first, multiply by {a}, then subtract {b}: {answer}.
:::

::: misses
- [(a*x0)^2 - b] The square applies to x only. Square {x0}, then multiply by {a}.
- [a*x0^2 + b] The constant is subtracted.
- [-a*x0^2 - b] A negative number squared is positive.
- [any] Not yet. Put {x0} in place of x and work it out: square first, then multiply, then subtract.
:::
:::

::: check
given: m = 2..6 int; k = 1..9 int; y = 10..30 int
answer: (y - k)/m
tolerance: 0.5%

## $f(x) = \given{m}x + \given{k}$. For which $x$ is $f(x) = \given{y}$?

::: right
Right. Subtract {k} from both sides, then divide by {m}: x = {answer}.
:::

::: misses
- [(y + k)/m] Undo the + {k} by subtracting it.
- [y/m - k] Undo the steps in reverse order: subtract {k} first, then divide by {m}.
- [m*y + k] That's $f(\given{y})$. The question asks for the input that gives {y}.
- [any] Not yet. Solve $\given{m}x + \given{k} = \given{y}$ for x.
:::
:::

::: check
kind: expression
answer: 2*x^2 + 1
vars: x = -3..3

## $f(x) = 2x + 1$ and $g(x) = x^2$. Write $f(g(x))$.

::: right
Right. $g$ goes first and gives $x^2$, and $f$ doubles it and adds one.
:::

::: misses
- [(2*x + 1)^2] That's $g(f(x))$: $f$ first, then square. In $f(g(x))$, $g$ acts first.
- [2*x^2 + 2*x + 1] That adds the two functions together. Chaining them means putting $g(x)$ in place of x inside $f$.
- [any] Not yet. Replace every x in $f(x) = 2x + 1$ with $g(x) = x^2$.
:::
:::

::: check
kind: choice

## Which of these is $y$ as a function of $x$?

- [ ] The points on a circle, $x^2 + y^2 = 4$
- [x] The points on the curve $y = x^2$
- [ ] The points on a sideways parabola, $x = y^2$
- [ ] Every point where $x = 3$

::: right
Right. Each x gives one $x^2$, so every vertical line meets the curve once at most.
:::

::: misses
- [1] A vertical line through a circle meets it twice, at $y = \pm\sqrt{4 - x^2}$. One input, two outputs.
- [3] At $x = 4$, both $y = 2$ and $y = -2$ work. That's two outputs for one input.
- [4] That's a vertical line: one input, x = 3, with every y as an output.
:::
:::

::: check
given: a = -2 | -1 | 0 | 1; b = 3
answer: ((b^3 - 3*b) - (a^3 - 3*a))/(b - a)
tolerance: 0.5%

## For $f(x) = x^3 - 3x$, what is the average rate of change from $x = \given{a}$ to $x = \given{b}$?

::: right
Right. The output changed by $f(\given{b}) - f(\given{a})$ while the input changed by {b} − ({a}), and the ratio is {answer}.
:::

::: misses
- [((b^3 - 3*b) - (a^3 - 3*a))] That's the change in output. Divide it by the change in input.
- [(b - a)/((b^3 - 3*b) - (a^3 - 3*a))] That's upside down: output change over input change.
- [any] Not yet. Work out $f(\given{b})$ and $f(\given{a})$, subtract, and divide by $\given{b} - (\given{a})$.
:::
:::

::: check
kind: parts
given: a = 0.5 | 1 | 2; b = 2 | 3 | 5; c = 1 | 2; x0 = 3 | 4 | 5

## Let $f(x) = \given{a}x^2 + \given{b}$ and $g(x) = x - \given{c}$.

::: part
answer: a*(x0 - c)^2 + b
tolerance: 0.5%

### What is $f(g(\given{x0}))$?

::: misses
- [a*x0^2 + b - c] That's $g(f(\given{x0}))$. Apply $g$ first, then $f$.
- [any] Work from the inside out: find $g(\given{x0})$, then put it into $f$.
:::
:::

::: part
answer: a*x0^2 + b - c
tolerance: 0.5%

### What is $g(f(\given{x0}))$?

::: misses
- [a*(x0 - c)^2 + b] That's $f(g(\given{x0}))$. Here $f$ goes first.
- [any] Find $f(\given{x0})$, then subtract {c}.
:::
:::
:::

::: check
kind: derivation
vars: a = 0.5..3, b = -2..2, x = -3..3

## With $f(x) = ax + b$ and $g(x) = x^2$, build both compositions.

::: step
answer: a*x^2 + b

### Write $f(g(x))$.

::: misses
- [(a*x + b)^2] That's $g(f(x))$: $f$ went first. Here $g$ goes first.
:::
:::

::: step
answer: (a*x + b)^2

### Write $g(f(x))$.
:::

::: step
answer: a^2*x^2 + 2*a*b*x + b^2
form: simplified

### Multiply out $g(f(x))$.

::: misses
- [a^2*x^2 + b^2] Don't forget the middle term, $2abx$.
:::
:::

::: right
Right. The two orders give different functions, $ax^2 + b$ and $a^2x^2 + 2abx + b^2$, so composition isn't like multiplication: order matters.
:::
:::

::: explain
## Explain what the graph of a function shows, and how you'd use it to solve $f(x) = 5$.

::: model
The graph is every point whose height is the function's output at that input, so the curve's height above any x is $f(x)$. To solve $f(x) = 5$, draw the horizontal line at height 5 and find where it meets the curve. Each meeting point is an x whose output is 5. There can be none, one or several, depending on how the curve rises and falls.
:::
:::

::: practice

::: check
given: a = 2..9 int; b = 1..9 int; c = -9..9 int; x0 = -4 | -3 | -2 | -1 | 1 | 2 | 3 | 4
answer: a*x0^2 + b*x0 + c

## $f(x) = \given{a}x^2 + \given{b}x + \given{c}$. What is $f(\given{x0})$?

::: misses
- [a*x0^2 - b*x0 + c] Watch the sign of the middle term: $\given{b} \times \given{x0}$.
- [(a*x0)^2 + b*x0 + c] Square {x0} first, then multiply by {a}.
- [any] Put {x0} in place of every x, then work it out.
:::
:::

::: check
given: m = 2..9 int; k = 1..9 int; y = 10..40 int
answer: (y - k)/m
tolerance: 0.5%

## For $f(x) = \given{m}x + \given{k}$, find the $x$ where $f(x) = \given{y}$.

::: misses
- [(y + k)/m] Undo the constant by subtracting it.
- [m*y + k] That's $f(\given{y})$. Solve for the input instead.
- [any] Subtract {k}, then divide by {m}.
:::
:::

::: check
given: p = 2..4 int; q = 2..5 int; a = -3..3 int
answer: p*(a^2) + q

## $f(x) = \given{p}x + \given{q}$ and $g(x) = x^2$. What is $f(g(\given{a}))$?

::: misses
- [(p*a + q)^2] That's $g(f(\given{a}))$. Apply $g$ first.
- [any] Work from the inside out: find $g(\given{a})$, then put it into $f$.
:::
:::

::: check
given: p = 2..4 int; q = 2..5 int; a = -3..3 int
answer: (p*a + q)^2

## $f(x) = \given{p}x + \given{q}$ and $g(x) = x^2$. What is $g(f(\given{a}))$?

::: misses
- [p*(a^2) + q] That's $f(g(\given{a}))$. Here $f$ acts first.
- [any] Work from the inside out: find $f(\given{a})$, then square it.
:::
:::

::: check
given: a = 0..3 int; d = 2..4 int; k = 2..5 int
answer: k*((a + d)^2 - a^2)/d
tolerance: 0.5%

## For $f(x) = \given{k}x^2$, what is the average rate of change from $x = \given{a}$ to $x = \given{a} + \given{d}$?

::: misses
- [k*((a + d)^2 - a^2)] That's the change in output. Divide by the change in input, {d}.
- [any] Find $f$ at both ends, subtract, and divide by {d}.
:::
:::

::: check
kind: choice

## What is the domain of $f(x) = \sqrt{x - 2}$?

- [ ] All real numbers
- [x] $x \ge 2$
- [ ] $x \ge 0$
- [ ] $x > 2$ only

::: right
Right. The square root needs $x - 2 \ge 0$, and at $x = 2$ it gives $\sqrt{0} = 0$, which is fine.
:::

::: misses
- [1] Below $x = 2$ the square root would be of a negative number.
- [3] The square root is of $x - 2$, so it's $x - 2$ that has to be at least 0.
- [4] At $x = 2$ the square root is of 0, which is allowed.
:::
:::

::: check
kind: choice

## $f(x) = x^3 - 3x$ has a local maximum at $x = -1$. What is its value there?

- [x] 2
- [ ] −2
- [ ] −4
- [ ] 4

::: right
Right. $(-1)^3 - 3(-1) = -1 + 3 = 2$.
:::

::: misses
- [2] That's the local minimum, at $x = 1$.
- [any] Put $x = -1$ in carefully: $(-1)^3 = -1$ and $-3 \times (-1) = +3$.
:::
:::
:::
