Changes outside move the graph up or down
Adding a number to a function's output moves its whole graph up. If , every output of is more than the output of at the same input. A negative moves the graph down.
The shift is measured in the output's units. If is a temperature in °C at hour , then is the same day's pattern, 5 °C warmer.
Changes inside move it sideways
Changing the input moves the graph sideways, and the direction surprises most people. moves the graph units to the right.
Here is why. At input , gives what gave at , which is units further left. So every feature of shows up units later in .
With the temperature, is the same pattern 2 hours later.
Rule: Shifts
A change outside the function moves the graph up or down, in the direction you expect. A change inside moves it sideways, the opposite way to the sign: moves right and moves left.
Take and , which is . A table shows the move:
| 0 | 1 | 2 | 3 | 4 | 5 | 6 | |
|---|---|---|---|---|---|---|---|
| 0 | 1 | 4 | 9 | 16 | 25 | 36 | |
| 5 | 0 | 0 | 5 |
Each value of turns up in three columns later and 4 lower: and .
Algebra says the same. is smallest at , and is smallest where , at . There is , so the lowest point moves from to .
The zeros of come from , so or : or .
moved 3 right and 4 down. Every point makes the same move: goes to , and the lowest point goes to .
The domain moves with the graph. The function from lesson 1.1.1 is moved 3 right, which is why its domain starts at 3 instead of 0.
Try it
The cell builds from exactly as the formula says: f(x - 3) - 4. The two printed rows are the table above.
Flips and stretches
A minus sign flips a graph, and a multiplier stretches it. Where you put them decides which way.
- turns every output upside down: a flip over the -axis.
- swaps left and right: a flip over the -axis.
- with stretches the graph away from the -axis; with it squashes it towards the axis. A negative stretches and flips at once.
Follow the point of through each one:
| 0 | 1 | 4 | 9 | |
|---|---|---|---|---|
| 0 | 1 | 2 | 3 | |
| 0 | ||||
| 0 | 2 | 4 | 6 | |
| 0 | 0.5 | 1 | 1.5 |
The flip needs , so its domain is : the domain flips too. It gives 0, 1, 2 and 3 at .
and three changed copies, each carrying the point somewhere new. The flips mirror the graph in an axis; the stretch doubles every height.
Three cases catch people out.
- Zeros stay put under a stretch or a flip over the -axis: and are still 0.
- A symmetric graph ignores . For , , so the flip over the -axis changes nothing.
- is not . By the order of operations (lesson 0.3.1), means , the parabola opening downwards. is again.
Multiplying the input acts sideways, again the opposite way. reaches each height at half the input, so the graph is squeezed towards the -axis. reaches 4 at , but reaches it at .
Rule: Flips and stretches
Outside the function, a change acts on heights as written. Inside, it acts on the input, and the effect runs the opposite way.
Try it
The rows are the table, computed on an array. The last row is at 0, , and .
NumPy prints as -0.. It is the same number as 0.
Several moves at once
Most formulas combine moves: shifts right by , stretches by (flipping if is negative), then shifts up by . Work from the inside out, the order you would evaluate the formula in (lesson 0.3.1).
The order matters. With , stretches and then lifts by 1: at it gives 19. But lifts first, and the stretch doubles the lift too: at it gives 20.
A second example: is moved 1 right, stretched by 2 and flipped, then lifted 3. Its highest point is . At it gives 1, 3, 1 and .
Lesson 1.2.2 writes every quadratic in this form to find its lowest or highest point.
Try the moves yourself. Set and to get the graph of the first figure, then make negative and watch the lowest point become the highest.
Explore
Move the sliders: k moves the graph up, h moves it right, a stretches it and a negative a flips it. The dashed curve is the original.
y = x²
- Compared with y = x²
- no change yet
- The lowest point
- (0, 0) moves to (0, 0)
Piecewise functions
A piecewise function uses a different rule on different parts of its domain. You met one in lesson 0.3.3: the absolute value is when and when . Here is another:
To evaluate it, first find which piece the input belongs to. , but . At the boundary, falls in the second piece, so .
Here the left piece also gives at , so the two pieces meet and the graph has no break. They need not meet. Take
Just left of 2 the output is 1, as in . At 2 it is . The graph jumps up by 1 at .
A jump, and pieces that meet. An open dot marks a point the graph comes up to but does not include; a closed dot marks the value the function takes.
Rule: Piecewise functions
Each input belongs to exactly one piece; the boundary goes to the piece whose condition has or . On a graph, a closed dot is on the graph and an open dot is not.
Two more cases matter. If two pieces both claimed with different outputs, the rule would not be a function at all. If no piece covers an input, that input is not in the domain.
Lesson 2.1.2 calls a graph with no break continuous, and studies jumps like this one.
Try it
np.where(condition, a, b) takes a where the condition holds and b elsewhere. That is a two-piece function on a whole array.
The first line is at . The second is at : the jump shows between 1.99 and 2.
The ramp
The most useful piecewise function in this course is the ramp, : "the larger of and 0". It is 0 for negative inputs and itself for positive ones. Its two pieces meet at a corner, .
Rule: The ramp
Keep a positive number; replace a negative one by 0. is the same ramp moved right by .
Every move of this lesson applies. is flat at 0 up to 3, then climbs with slope 1. The flip over the -axis gives , and moved to 3 it is : it falls to 0 at 3 and stays there.
A ramp and its mirror image add up to the absolute value: . For any , one of the two is 0 and the other is the distance from 0. Case study 1.1.5 builds every option payoff from these ramps.
Try it
np.maximum(x, 0) is the ramp on a whole array. Python's built-in max compares single numbers only, so use np.maximum for arrays.
The rows are , and at . The last two lines are the ramp plus its mirror, and : they match.
Common mistakes
- The sideways shift goes against the sign. moves the graph right, not left.
- is not . The first is never positive; the second is never negative.
- The order of moves matters. is not : the stretch also doubles any lift made before it.
- An inside multiplier squeezes. is narrower than , not wider.
- The domain moves too. starts at 3, and lives on .
- Check which piece applies, including at the boundary: a closed dot is on the graph, an open dot is not.
- Use
np.maximumon arrays, not Python'smax.
Transformations and pieces
0 of 13 correct
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
- 13.
How to type answers
- Powers with
^:x^7,2^(1/3),a^-2. - Multiply with
*or by writing side by side:3x^2,2(x+1). ln(x)is the natural log,log(x, 2)is log base 2,eis Euler's number,sqrt(x)is a square root.sin(x),cos(x)andtan(x)take radians; writepifor π andsin(x)^2for sin²x.- Your first answer to each question is saved: it counts towards your score and brings the question back for review.
- Exact answers like
ln(20)/ln(3)are best. Decimals need about 4 significant figures.
Summary card
- moves the graph up by ; moves it right by . Inside changes act the opposite way to their sign.
- flips over the -axis, over the -axis, stretches up and down, and squeezes sideways.
- In , work from the inside out: shift sideways, stretch or flip, then shift up. Order matters.
- A piecewise function uses a different rule on each part of the domain. Find the piece first; at a jump, the closed dot is the value.
- The ramp keeps positives and zeroes negatives; is the ramp moved right by , and .
- In NumPy:
np.where(condition, a, b)andnp.maximum(x, 0).