---
title: Transforming graphs
heading: Shift, stretch and flip
eyebrow: A2 · Lesson 11 · Transforming graphs
xp: 40
---

::: hook
A signal arrives at an amplifier. The output is the same shape, but taller, a little later, and sitting on top of a DC level. Engineers describe that with one formula built from the input's formula. If the input is $f(t)$, what is the output?

::: play
- The dashed curve is the original shape $f(x)$: a big bump at 0 and a small one to its right. The solid curve is $A\,f(b(x - h)) + k$.
- Move one slider at a time and say what it does: $h$, then $k$, then $A$, then $b$.
- Make $A$ negative, then make $b$ negative. Each one flips the shape. Which way?
:::
:::

```sim plot
view: graph
x: x = -6..6
y: y = -3..3
slider: A = -2..2 step 0.1 = 1
slider: b = -2..2 step 0.1 = 1
slider: h = -3..3 step 0.1 = 0
slider: k = -2..2 step 0.1 = 0
plot: exp(-x^2) + 0.5*exp(-4*(x - 1.5)^2) | dashed | color: ch2 | label: f(x)
plot: A*(exp(-(b*(x - h))^2) + 0.5*exp(-4*(b*(x - h) - 1.5)^2)) + k | label: A f(b(x − h)) + k
readout: big bump at x = h
```

::: predict
## The formula has $(x - h)$. When you set $h = 2$, which way does the curve move?

- [ ] 2 to the left
- [x] 2 to the right
- [ ] 2 up
- [ ] It gets twice as wide

::: reveal
2 to the right. The new curve at $x$ shows what the old one showed at $x - 2$, so every feature turns up 2 later: the big bump that was at 0 is now at 2. It feels backward because of the minus sign, but it's what a delay looks like: a signal delayed by $t_0$ is $f(t - t_0)$.
:::
:::

::: nameit
## Four changes, and what each one does

Starting from any function $f(x)$, the general transformed version is

$$y = A\, f\big(b\,(x - h)\big) + k$$

| Change | What it does |
|---|---|
| $h$ | shifts the curve right by $h$ (left if $h$ is negative) |
| $k$ | shifts it up by $k$ |
| $A$ | stretches it vertically by $A$; a negative $A$ flips it upside down |
| $b$ | squeezes it horizontally by $b$ (it gets $b$ times narrower); a negative $b$ flips it left to right |

Changes inside the function's brackets act on $x$, and they act backward: $- h$ moves the curve toward $+h$, and multiplying $x$ by $b = 2$ makes the curve half as wide. Changes outside the brackets act on $y$ the way they look.

In signals these have names you'll use constantly:

- $v(t - t_0)$ is $v$ **delayed** by $t_0$.
- $A\,v(t)$ is $v$ **amplified** by a gain of $A$; a negative gain **inverts** it.
- $v(t) + V_\text{DC}$ is $v$ with a **DC offset** added.
- $v(bt)$ is $v$ **sped up** by a factor $b$: everything happens $b$ times sooner, so its frequencies are $b$ times higher.

Order matters when you undo them. To find where a point of the original lands, apply them in the order inside to outside: shift by $h$ and squeeze by $b$ first, then stretch by $A$ and lift by $k$. A point at $(x_0, y_0)$ on the original moves to $(h + x_0/b,\ A y_0 + k)$.
:::

::: example
## Describe how $g(x) = -2(x + 1)^2 + 3$ is built from $x^2$, and find its vertex.

::: solution
1. **Shift.** Reading from the inside out, $x + 1$ shifts the graph 1 to the **left**.
2. **Stretch.** The factor 2 stretches it vertically by 2.
3. **Flip.** The minus sign flips it upside down.
4. **Lift.** The $+3$ lifts it up by 3.
5. **Move the vertex.** The vertex of $x^2$ at $(0, 0)$ moves to $(-1, 3)$, and since the parabola is flipped, it's now the highest point.

**Answer:** $g$ is $x^2$ shifted 1 left, stretched vertically by 2, flipped and lifted 3, and its vertex is the highest point, $(-1, 3)$.
:::
:::

::: example
## A sensor's signal is $\sin(2\pi \cdot 50\,t)$. Write the version that arrives 2 ms late, five times bigger, sitting on a 1 V offset.

::: solution
1. **Delay by 2 ms.** Replace $t$ with $t - 0.002$:
   $$\sin\big(2\pi \cdot 50\,(t - 0.002)\big)$$
2. **Scale by 5 and add 1.**
   $$v(t) = 1 + 5\sin\big(2\pi \cdot 50\,(t - 0.002)\big)$$
3. **Turn the delay into a phase.** Expanded, the delay is a phase of
   $$\begin{aligned} 2\pi \cdot 50 \times 0.002 &= 0.628\ \text{rad} \\ &= 36° \end{aligned}$$
4. **Write it with the phase.**
   $$v(t) = 1 + 5\sin(2\pi \cdot 50\,t - 36°)$$

**Answer:** $v(t) = 1 + 5\sin\big(2\pi \cdot 50\,(t - 0.002)\big)$, which is the same as $1 + 5\sin(2\pi \cdot 50\,t - 36°)$.
:::
:::

::: example
## Fahrenheit is a stretch and a shift of Celsius: $F = 1.8\,C + 32$. Describe it as transformations, find its inverse, and find the temperature that reads the same on both scales.

::: solution
1. **Describe the transformations.** Starting from $C$, stretch by 1.8 (a Fahrenheit degree is smaller), then shift up by 32.
2. **Undo them.** Reverse the steps in the opposite order: subtract 32, then divide by 1.8:
   $$C = \frac{F - 32}{1.8}$$
3. **Find where the scales agree.** Set $F = C$:
   $$\begin{aligned} C &= 1.8C + 32 \\ -0.8C &= 32 \\ C &= -40 \end{aligned}$$
   At −40 the scales read the same.

**Answer:** Fahrenheit is Celsius stretched by 1.8 and shifted up 32. The inverse is $C = (F - 32)/1.8$, and the two scales read the same at −40.
:::
:::

::: check
kind: expression
given: t0 = 2..5 int
answer: (x - t0)^2
vars: x = -5..5

## Write $f(x) = x^2$ shifted {t0} to the right.

::: right
Right. $(x - \given{t0})^2$ is zero at $x = \given{t0}$, where the original was zero at 0.
:::

::: misses
- [(x + t0)^2] That moves it left. To shift right by {t0}, subtract {t0} from x.
- [x^2 - t0] That moves it down. A horizontal shift goes inside the function, with x.
- [x^2 + t0] That moves it up. A horizontal shift goes inside the function, with x.
- [any] Not yet. Replace x with $(x - \given{t0})$.
:::
:::

::: check
kind: choice

## A signal $v(t)$ goes through an amplifier with a gain of −3. Which describes the output?

- [x] Three times as tall, and upside down
- [ ] Three times as tall, and reversed in time
- [ ] A third as tall, and upside down
- [ ] Three times as long

::: right
Right. The output is $-3\,v(t)$: the factor outside the function stretches it vertically, and the minus sign flips it top to bottom.
:::

::: misses
- [2] Reversing in time would be $v(-t)$, a minus sign inside the brackets. This one is outside, so it acts on the height.
- [3] The size of the gain is 3, so the height triples.
- [4] A factor outside the function stretches it vertically.
:::
:::

::: check
given: x0 = 1..3 int; y0 = 1..4 int; h = -3 | -2 | -1 | 1 | 2 | 3; b = 2 | 0.5; A = 2 | 3 | -1 | -2; k = -2..2 int
answer: h + x0/b
tolerance: 0.5%

## The point $(\given{x0}, \given{y0})$ is on the graph of $f$. Where does it land, horizontally, on the graph of $\given{A}\,f\big(\given{b}(x - (\given{h}))\big) + (\given{k})$? Give the new x.

::: right
Right. The squeeze divides the distance from the shift point by {b}, and the shift moves it by {h}: $x = \given{h} + \given{x0}/\given{b}$ = {answer}.
:::

::: misses
- [b*x0 + h] Multiplying x by {b} inside squeezes the curve: points move closer, so divide by {b}.
- [x0/b - h] The shift moves the curve toward $+h$, so add {h}.
- [any] Not yet. Solve $\given{b}(x - (\given{h})) = \given{x0}$ for x.
:::
:::

::: check
kind: expression
answer: -(x/2)^3
vars: x = -3..3

## Take $f(x) = x^3$, stretch it horizontally to twice its width, then flip it upside down. Write the result.

::: right
Right. Twice as wide means $f(x/2)$, and upside down means a minus sign outside.
:::

::: misses
- [-(2*x)^3] $f(2x)$ is half as wide. To stretch it, divide x by 2.
- [-2*x^3] That stretches it vertically. A horizontal stretch goes inside, with x.
- [any] Not yet. Stretch with $f(x/2)$, then put a minus sign in front.
:::
:::

::: check
kind: parts
given: a = -1 | -2 | -0.5; h = 2 | 3; k = 3 | 7

## $g(x) = \given{a}(x - \given{h})^2 + \given{k}$.

::: part
answer: a*h^2 + k
tolerance: 0.5%

### What is $g(0)$, where the graph crosses the vertical axis?

::: misses
- [a*h + k] The shift is squared: $(0 - \given{h})^2$.
- [any] Put $x = 0$ in.
:::
:::

::: part
answer: h + sqrt(-k/a)
tolerance: 0.5%

### What is the larger $x$ where the graph crosses the horizontal axis?

::: misses
- [h - sqrt(-k/a)] That's the smaller one.
- [sqrt(-k/a)] Shift it over by {h}.
- [any] Solve $(x - \given{h})^2 = -\given{k}/\given{a}$.
:::
:::
:::

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

## Put $ax^2 + bx + c$ into vertex form $a(x - h)^2 + k$ by completing the square.

::: step
answer: -b/(2*a)

### What is $h$?

::: misses
- [b/(2*a)] Check the sign: $a(x - h)^2$ has $-2ah$ as its $x$ coefficient.
:::
:::

::: step
answer: c - b^2/(4*a)

### What is $k$?
:::

::: step
answer: a*(x + b/(2*a))^2 + c - b^2/(4*a)

### Write the whole vertex form.
:::

::: right
Right. The parabola is $x^2$ stretched by $a$, shifted by $h = -b/2a$ sideways and $k = c - b^2/4a$ up.
:::
:::

::: explain
## Why does subtracting $h$ inside the function move the graph to the right?

::: model
The new curve's value at $x$ is the old curve's value at $x - h$. So whatever the old curve did at some point $x_0$, the new curve does where $x - h = x_0$, which is at $x = x_0 + h$. Every feature happens $h$ later along the axis, so the whole graph moves right by $h$. It's the same idea as a delay: the delayed signal shows now what the original showed $h$ seconds ago.
:::
:::

::: practice

::: check
kind: expression
given: k = 2..6 int
answer: (x + k)^2
vars: x = -5..5

## Write $f(x) = x^2$ shifted {k} to the left.

::: misses
- [(x - k)^2] That moves it right. To shift left, add {k} to x.
- [x^2 + k] That moves it up. A horizontal shift goes inside, with x.
- [any] Replace x with $(x + \given{k})$.
:::
:::

::: check
kind: expression
given: A = 2..5 int; k = 1..4 int
answer: A*exp(-x) + k
vars: x = 0..3

## Start from $e^{-x}$. Stretch it vertically by {A}, then move it up by {k}. Write the result.

::: misses
- [A*(exp(-x) + k)] That lifts first and then stretches, which stretches the lift too.
- [exp(-x*A) + k] A vertical stretch multiplies the whole function, outside.
- [any] Multiply the function by {A}, then add {k}.
:::
:::

::: check
given: w = 2..8 int; b = 2 | 4 | 0.5
answer: w/b
unit: ms
tolerance: 0.5%

## A pulse $p(t)$ is {w} ms wide. How wide is $p(\given{b}\,t)$, in ms?

::: misses
- [w*b] Multiplying t by {b} inside speeds the signal up, so it's narrower when {b} is above 1.
- [any] $p(bt)$ is $b$ times narrower: divide the width by {b}.
:::
:::

::: check
given: t1 = 1..9 int; t0 = 2..9 int
answer: t1 + t0
tolerance: 0.5%

## A signal $v(t)$ peaks at $t$ = {t1} ms. When does $v(t - \given{t0}\ \text{ms})$ peak?

::: misses
- [t1 - t0] Subtracting inside the brackets is a delay: the peak comes later.
- [any] A delay of {t0} ms moves every feature {t0} ms later.
:::
:::

::: check
kind: choice

## Which formula describes $f(x)$ reflected left to right?

- [ ] $-f(x)$
- [x] $f(-x)$
- [ ] $-f(-x)$
- [ ] $1/f(x)$

::: right
Right. The new curve at $x$ shows the old one at $-x$, so left and right swap.
:::

::: misses
- [1] A minus outside flips the curve upside down.
- [3] That flips it both ways: left to right and upside down.
- [4] That's the reciprocal, a different shape altogether.
:::
:::
:::
