Int 3 for Programmers

Functions, transformations, composition and inverses

9 / 396
Contents

Contents

Int 3 for Programmers

0 of 396 complete

11 min read

Moving and stretching a graph

The four changes you can make to a formula, and what each does to the picture.

There are only four things you can do to a function that change its graph without changing its family: slide it up or down, slide it left or right, stretch it vertically, and stretch it horizontally. Reflections come free, as stretches by a negative amount.

Rather than being told which does what, produce a table and read it. The middle column is the parent and the others are the same rule with one change each.

Try CodePython

Change f(x - 2) to f(x + 2) and run it again. Which way along the row does the zero move now?

Four observations, one per column. Adding 3 outside raised every output by 3, so the graph moved up 3. The column f(x−2)f(x-2) has the value 0 at x=2x = 2 rather than at x=0x = 0, so the graph moved right 2. Multiplying by 3 outside made every output three times as tall. And f(2x)f(2x) reaches at x=1x = 1 what the parent reached at x=2x = 2, so it has been squashed towards the vertical axis.

The four rules

Now the names. In each rule below, ff is any function and the number is a constant.

New ruleEffect on the graphCalled
f(x)+kf(x) + kUp kk if k>0k > 0, down if k<0k < 0Vertical translation
f(x−h)f(x - h)Right hh if h>0h > 0, left if h<0h < 0Horizontal translation
a f(x)a\,f(x)Stretched vertically by a factor aaVertical stretch
f(bx)f(bx)Every horizontal distance from the vertical axis is divided by bbHorizontal stretch
−f(x)-f(x)Flipped over the horizontal axisReflection in the x-axis
f(−x)f(-x)Flipped over the vertical axisReflection in the y-axis
Where the change is written decides which direction it acts in.

The horizontal row of that table needs one extra sentence, because the single word squash is only half the story. Dividing the horizontal distances by bb pulls the graph in when bb is bigger than 1 and pushes it out when bb is between 0 and 1.

Numbers make that concrete. With b=2b = 2, the height the parent reached at x=4x = 4 is now reached at x=2x = 2, because 2×2=42 \times 2 = 4 is what has to be fed in. Every feature has moved half as far from the vertical axis, so the graph is squashed towards it.

With b=0.5b = 0.5 the same arithmetic runs the other way. To feed the parent the input 2 you now need 0.5×x=20.5 \times x = 2, so x=4x = 4. What happened at x=2x = 2 now happens at x=4x = 4, twice as far out, so the graph is stretched away from the vertical axis rather than squashed towards it.

Anything written outside the function acts on the output, which is the vertical direction, and it acts exactly as you would expect. Anything written inside acts on the input, which is the horizontal direction, and it acts backwards.

That backwards behaviour is worth understanding rather than memorising. To make f(x−2)f(x-2) produce the value that ff produced at 0, you need x−2=0x - 2 = 0, so you need x=2x = 2. Every feature of the graph therefore needs a larger input than before, which is a move to the right. Run the argument.

Try CodePython

Change f(x - 2) to f(x - 5), and change the printed x - 2 to x - 5. The corner moves to wherever the fed value hits 0.

All four at once, on a V
y=1 ∣ x−0 ∣+0y = 1\,\bigl|\,x - 0\,\bigr| + 0
-8-4048-6-3036
Corner is at x=x =
0
Corner is at y=y =
0
Height at x=0x = 0
0

Drag h and watch the corner track it exactly. Then set a negative and see the V turn over.

Reading a transformation off a graph

The exam question usually runs the other way: here is a graph, here is the parent, describe the change or write the equation. Work in a fixed order.

  1. Identify the parent family from the shape: a V, a U, a line, and so on.
  2. Find the feature you can locate exactly. For a V it is the corner, for a parabola the turning point, for a cubic the flat spot.
  3. Compare that feature with where the parent has it, at the origin. The horizontal move is hh and the vertical move is kk.
  4. Take one more point off the graph and solve for the stretch aa.

One worked example in full. A V-shaped graph has its corner at (3,−1)(3, -1) and passes through (5,3)(5, 3). Find its equation.

  1. The shape is a V, so the parent is f(x)=∣x∣f(x) = |x| and the equation has the form y=a∣x−h∣+ky = a|x - h| + k.
  2. The corner sits at (3,−1)(3, -1), so h=3h = 3 and k=−1k = -1, giving y=a∣x−3∣−1y = a|x - 3| - 1.
  3. Substitute the extra point, x=5x = 5 and y=3y = 3: 3=a∣5−3∣−13 = a|5 - 3| - 1.
  4. So 3=2a−13 = 2a - 1, giving 2a=42a = 4 and a=2a = 2.
  5. The equation is y=2∣x−3∣−1y = 2|x - 3| - 1. Check it against the corner: 2∣3−3∣−1=−12|3-3| - 1 = -1, as required.
The graph of y=x2y = x^2 is moved 4 left and 6 down. What is the new equation?

y=(x+4)2−6y = (x + 4)^2 - 6. Left is the negative direction, so h=−4h = -4, and x−hx - h becomes x−(−4)=x+4x - (-4) = x + 4. Down 6 is k=−6k = -6, written outside as a subtraction. The turning point is now at (−4,−6)(-4, -6).

Check yourself

Compared with y=f(x)y = f(x), what does the graph of y=f(x+5)y = f(x + 5) look like?

All lessons in Int 3 for Programmers