โ๏ธ Function Kingdom ยท Functions
Piecewise Functions & Modelling
Build the function a situation needs: evaluate and write piecewise and step functions, find the average rate of change on an interval, turn a box, a fence or a price into a polynomial model, choose the right family, and use direct, inverse and joint variation.
In short
- A piecewise function is one function with several rules: choose the piece from the condition first, then substitute into that rule alone.
- At a boundary, only the condition written with <= or >= claims the point โ a filled dot on the graph, against a hollow one for the piece that stops just short.
- The average rate of change on [a, b] is (f(b) - f(a)) / (b - a): the slope of the straight line joining the two ends of the interval.
- To build a model, name one variable, write every other quantity in terms of it, multiply, and then state the domain that makes physical sense.
- Choose a family by what stays constant: an added amount is linear, a second difference is quadratic, a multiplier is exponential, a product xy is rational.
One function wearing two coats
Cartographer Iris draws the shoreline of Graph Lake in two strokes, because the shore does two different things. Up to the boathouse it runs straight; past the boathouse it curves away. One line would be a lie about half the lake.
A piecewise function is written the same way: one function, several rules, each with the stretch of the number line it applies to.
f(x) = 2x + 1 if x < 3 f(x) = x2 - 4 if x >= 3
To evaluate it, do the two jobs in this order โ and never the other way round.
- Choose the piece. Test the input against each condition until one holds.
- Then calculate. Substitute into that rule alone.
So f(1) uses the first line, because 1 < 3, giving 3. And f(5) uses the second, because 5 >= 3, giving 21.
The interesting input is always the boundary. Exactly one condition may claim it, and you can see which by the inequality signs: <= and >= include the endpoint, < and > exclude it. Here x = 3 satisfies x >= 3, so f(3) = 32 - 4 = 5 โ the first rule stops just short of 3 and never gets a say.
On a graph this shows as two kinds of dot at each boundary: a filled dot where the piece includes its endpoint, and a hollow dot where it stops just short. A well-drawn piecewise graph never has two filled dots stacked above the same x, because a function is allowed only one output per input.
A step function is a piecewise function whose pieces are all constants โ the graph is a flight of stairs. Step pricing is everywhere: a locker at $4 for each hour or part of an hour, postage by 100-gram band, a car park that rounds up. "Or part of an hour" means the count is rounded up, never to the nearest, so 2 hours 5 minutes is charged as 3 hours.
Average rate of change is a slope in disguise
A straight line has one slope everywhere. A curve does not โ it steepens and flattens as it goes. The average rate of change measures the curve the honest way: draw the straight line between the two ends of an interval and take *its* slope.
average rate of change on [a, b] = (f(b) - f(a)) / (b - a)
That is exactly rise over run, with the rise measured in whatever the output measures and the run in whatever the input measures. Which is why the answer always carries a meaning: metres per second, dollars per kilogram, degrees per hour.
Three sources give the same calculation.
- From a rule. Work out f(a) and f(b), then subtract and divide.
- From a table. Only the two rows at the ends of the interval matter. The rows in between tell you the function is curving, but they play no part.
- From two readings in a story. "At 2 seconds it had gone 5 metres; at 6 seconds it had gone 23 metres" is a table with two rows.
Two things go wrong, and both are worth naming before you meet them. The first is stopping after the subtraction: f(b) - f(a) is a *change*, not a *rate*, and it only becomes a rate once it is divided. The second is dividing by b instead of b - a. The denominator is the width of the interval, so on [2, 6] you divide by 4, never by 6.
The sign carries information too. A negative average rate of change means the quantity fell across that interval, and a rate of zero means it ended where it started โ which does not mean it stayed there in between.
Building a model from a picture
Most of Grade 12 modelling is one recipe, applied to a drawing.
1. Name the variable. Pick the one length, price or time everything else depends on, and call it x. 2. Write every other quantity in terms of x, using the constraint the question gives you. 3. Combine them the way the quantity you want is defined โ multiply for an area or a volume, multiply price by quantity for revenue. 4. State the domain that makes sense, which is rarely all of the real numbers.
Three models come up again and again.
A rectangle with a fixed perimeter. If the perimeter is 40 cm, then width + length = 20, because a perimeter counts each side twice. With width x the length is 20 - x, so
A(x) = x(20 - x)
A garden fenced on three sides. With a wall along the fourth side and 50 metres of fencing, the two sides running out from the wall use 2x metres, leaving 50 - 2x for the side parallel to the wall:
A(x) = x(50 - 2x)
An open box cut from a sheet. Cut a square of side x from each corner of a 20 by 12 sheet and fold the flaps up. The flaps have height x, so x is the depth. Each dimension loses a corner square at both ends, which is 2x off each:
V(x) = x(20 - 2x)(12 - 2x)
Revenue is the same recipe with money. If a price of p dollars sells 400 - 30p lanterns, then revenue is price times quantity: R(p) = p(400 - 30p).
The domain is part of the model, not an afterthought. A width cannot be negative and cannot use up the whole half-perimeter, so the rectangle above only makes sense for 0 < x < 20. In the box, 12 - 2x must stay positive too, so 0 < x < 6. An answer outside the sensible domain is a signal that something was set up wrongly, not a discovery.
Using the model, and choosing the family
Once a model exists there are only four things anyone ever asks of it.
- A value. Substitute. N(3) for N(t) = 500(1.08)t means raising 1.08 to the power 3 first, then multiplying by 500.
- A largest or smallest value. For a quadratic, that is the vertex, which sits exactly halfway between the two zeros. A(x) = x(20 - x) is zero at x = 0 and x = 20, so the vertex is at x = 10 โ and the largest area is A(10) = 100. Notice that "which width" and "what area" are different questions with different answers.
- A return to zero. Factor and set each factor to zero. Then read the roots in context: for a thrown stone the useful root is the positive one.
- The meaning of a parameter. In N(t) = 500(1.08)t the 500 is the starting population, because N(0) = 500. The 1.08 is what one year *does* โ it multiplies. Multiplying by 1 would change nothing, so the growth is the 0.08 above 1, that is 8 % a year.
Choosing a family is the same question asked backwards: what stays constant as the input steps forward?
- constant first differences โ an equal amount added each step โ is linear
- constant second differences is quadratic
- a constant ratio between neighbouring values is exponential
- values that repeat on a fixed cycle are sinusoidal
- a constant product xy, so the output is a fixed number divided by the input, is rational
- two rules in two regions is piecewise
Given a table, take the first differences. If they are equal, stop โ it is linear. If not, try the second differences and the ratios. If neither settles, multiply the two columns together and see whether that is constant.
Variation: the smallest models of all
Variation language is a compact way of saying which letters sit above the line and which sit below it. The constant k, called the constant of variation, always multiplies.
- y varies directly as x: y = kx
- y varies inversely as x: y = k/x
- z varies jointly as x and y: z = kxy
- y varies directly as x and inversely as z (combined): y = kx/z
- y varies inversely as the square of x: y = k/x2
Every variation problem has the same two stages. Find k from the pair of values you are given, then use that k with the new values. For direct variation with y = 12 when x = 3, substituting gives 12 = 3k, so k = 4, and the model is y = 4x.
Inverse variation is where the sign of your instincts has to flip. Because y = k/x rearranges to xy = k, the product of the two quantities is the same for every pair โ so when x doubles, y halves. Finding k means multiplying the given pair, not dividing it.
An inverse square is fiercer still. In y = k/x2, doubling x divides y by four, and trebling it divides y by nine. That is why light and sound fade so quickly with distance.
Worked examples
Example 1
f(x) = 4x - 1 if x < 2, and f(x) = x2 + 3 if x >= 2. Work out f(2).
- Choose the piece before calculating anything. The input is x = 2.
- Test the first condition: is 2 < 2? No. The first rule stops just short of 2.
- Test the second: is 2 >= 2? Yes. So the second rule is the one in force.
- Substitute into that rule alone: f(2) = 22 + 3 = 7.
- A check on the graph: the first piece ends at 2 with a hollow dot at height 7 as well, and the second begins at 2 with a filled dot at 7 โ but only the filled dot is the value of the function.
Example 2
A table gives f(1) = 5, f(2) = 8, f(3) = 13, f(4) = 20, f(5) = 29. Find the average rate of change of f from x = 2 to x = 5.
- Only two rows matter: the ends of the interval. Read f(2) = 8 and f(5) = 29.
- Change in f: 29 - 8 = 21.
- Change in x: 5 - 2 = 3. This is the width of the interval, not the endpoint 5.
- Average rate of change = 21/3 = 7.
- In context that reads: across those three steps, f rose by 7 per unit of x on average โ even though it rose by 3 on the first step and by 9 on the last.
Example 3
A rectangular paddock is fenced on three sides, with a river along the fourth. There are 60 metres of fencing. Write the area as a function of the width x, and find the width that gives the largest area.
- Name the variable: x is the length of each of the two sides running out from the river.
- Write the other side in terms of x. Those two sides use 2x metres, so the side parallel to the river is 60 - 2x.
- Combine: A(x) = x(60 - 2x), which multiplies out to 60x - 2x2.
- State the domain: x must be positive and 60 - 2x must be positive, so 0 < x < 30.
- For the maximum, find the zeros of A: x = 0 and 60 - 2x = 0, that is x = 30. The vertex sits halfway between them, at x = 15.
- So a width of 15 metres gives the largest area, and that area is A(15) = 15 times 30 = 450 square metres.
Example 4
y varies inversely as the square of x, and y = 9 when x = 2. Find y when x = 3.
- Write the model from the words: y = k/x2.
- Find k from the pair given. Rearranging, k = y times x2 = 9 times 4 = 36.
- Use that k with the new value: y = 36/32 = 36/9 = 4.
- Sense check: x rose from 2 to 3, a factor of 1.5, so y should fall by a factor of 1.52 = 2.25. And 9 divided by 2.25 is indeed 4.
Practice problems, with solutions
Three problems of increasing difficulty, each with the full working. In the game these are generated fresh every time; these three are fixed so this page always shows the same ones.
Problem 1
Difficulty 1 of 5f(x) = -x - 1 if x < 3 f(x) = -4x + 1 if x >= 3 Work out f(4).
Answer: -15
- Check the conditions: the rule in force at x = 4 is the one written for x >= 3.
- So the rule in force is f(x) = -4x + 1.
- f(4) = -15.
Problem 2
Difficulty 3 of 5A guild takes no fee on the first $800 of a sale, and 10% of anything above $800. Which piecewise rule gives the fee T on a sale of s dollars?
- T(s) = 0 for 0 <= s <= 800; T(s) = 0.1(s - 800) for s > 800
- T(s) = 0 for 0 <= s <= 800; T(s) = 0.1s - 800 for s > 800
- T(s) = 0 for 0 <= s <= 800; T(s) = 0.1s for s > 800
- T(s) = 800 for 0 <= s <= 800; T(s) = 800 + 0.1(s - 800) for s > 800
Answer: A. T(s) = 0 for 0 <= s <= 800; T(s) = 0.1(s - 800) for s > 800
- Below the threshold nothing is charged, so T(s) = 0 for 0 <= s <= 800.
- Above it, the taxed amount is the excess s - 800, and 10% of that is 0.1(s - 800).
- So T(s) = 0.1(s - 800) for s > 800.
Problem 3
Difficulty 4 of 5f(x) = x3 - 6 Find the average rate of change of f from x = 0 to x = 4. Give an exact value: a whole number, or a fraction in lowest terms.
Answer: 16
- f(0) = -6 and f(4) = 58.
- Change in f: 58 - -6 = 64, over an interval of width 4.
- Average rate of change = 64/4 = 16.
Common mistakes
- Evaluating both pieces of a piecewise function, or handing a boundary to the rule that stops just short of it โ the inequality signs decide, and only one rule ever applies to a given input.
- Writing the average rate of change as f(b)/b, or stopping at f(b) - f(a) without dividing by the width of the interval.
- Forgetting that a corner square of side x is cut from both ends of each side, so the base of an open box is (L - 2x) by (W - 2x), not (L - x) by (W - x).
- Writing inverse variation as y = kx, so the answer rises when it should fall โ inverse variation is y = k/x, and it is the product xy that stays constant.
- Leaving the domain as all real numbers, so the model happily reports a negative width or a box with a negative side.
What you should be able to do
- Evaluate a piecewise or step function and match a description to its rule.
- Find the average rate of change of a function over an interval from a rule, a table or a graph.
- Build a polynomial or rational model from a described situation and use it to answer a question.
- Choose the function family a situation calls for, interpret its parameters, and solve direct, inverse and joint variation problems.
Where this fits in the curriculum
Common Core
- HSF-IF.B.6
High school โ Calculate and interpret the average rate of change of a function (presented symbolically or as a table) over a specified interval; estimate the rate of change from a graph.
- HSF-BF.A.1.A
High school โ Determine an explicit expression, a recursive process, or steps for calculation from a context.
- HSF-BF.A.1.B
High school โ Combine standard function types using arithmetic operations; for example, build a function that models the temperature of a cooling body by adding a constant function to a decaying exponential.
- HSF-IF.C.7.B
High school โ Graph square root, cube root and piecewise-defined functions, including step functions and absolute value functions.
- HSF-LE.B.5
High school โ Interpret the parameters in a linear or exponential function in terms of a context.
- HSA-CED.A.2
High school โ Create equations in two or more variables to represent relationships between quantities; graph equations on coordinate axes with labels and scales.
SAT
- Passport to Advanced Math
Building a function from a described situation and interpreting its parameters.