- What is a function
- Expanding double brackets
- Percentage increase and decrease · coming soon
- Inverse functions
- Combined transformations — order matters · coming soon
- The chain rule · coming soon
Two discounts, two different prices
A shop is selling a jacket for $80. This week it takes 25% off every price. You also have a coupon worth $10. The shop will apply both. The only question is the order.
The cashier, Mei Ling, takes the 25% off first. A quarter of 80 is 20, so the price falls to $60. Then she takes off the $10 coupon. You pay $50.
At the next till, Kwame uses the coupon first. The price falls to $70. Then he takes 25% off. A quarter of 70 is 17.50, so you pay $52.50.
Same jacket. Same discount. Same coupon. Two different prices. Nobody made an arithmetic mistake. The only thing that changed was the order of the two steps.
Now try a different jacket, at $120. Discount first: $90, then $80. Coupon first: $110, then $82.50. The gap is $2.50 again. It is $2.50 for every price. By the end of this lecture you will be able to prove that, in two lines. You will also know exactly why the order matters, and how to write it so that nobody can confuse the two.
Feeding one machine into another
The last lecture ended with a promise. Because a function gives each input exactly one output, you can feed that output straight into a second function. This lecture keeps that promise.
Each step at the shop is a function. Call the discount and the coupon :
Here is the price going in. The discount keeps three quarters of the price. The coupon subtracts 10.
Mei Ling put the price into first. Then she put the answer into . In function notation, the output became the input of :
Read this from the inside out. The innermost brackets hold . The function closest to is , so acts first. Its output then sits inside the brackets of , so acts second.
A function built like this, by feeding the output of one function into another, is called a composite function. The two steps are joined, or composed, into one.
The notation: fg(x) means "do g first"
Writing two sets of brackets every time is slow. So we shorten to . We read it as "f of g of x", or "f g of x".
. The function acts on first. Then acts on the output of .
In the same way, : first, then .
This is the hard part of the notation, so spend time here. In , the letter is written first, but it acts second. We read from left to right, but the work happens from right to left. That feels backwards, and it causes more mistakes in this topic than anything else.
The way to make it feel natural is to see where the short form comes from. Write the long form, . Now remove the inner brackets. What is left is . So the letter next to is the function that touches first. The letter further away waits for its turn. Do not learn "right to left" as a rule. Look at which function is next to the input.
Some books write , read "f circle g of x". It means exactly the same as . We will use in these lectures.
Let us work out the two pipelines in the figure, using and .
The two answers are very different, as they were at the shop.
With the same and , a student says: " means times , so it is ." What has gone wrong?
Show the answer
Writing two function names side by side does not mean multiplying them. In , the letters and are names of machines, not numbers. Nothing is multiplied. The 3 goes into , and 's output goes into . So , not 63. This is the same idea as in the last lecture: is not "f times 3". If a question wants the product, it writes , with the times sign.
From numbers to a formula
With one number, you can work step by step. But you can also find a formula for the whole pipeline. Then any input can go in at once.
Use the method from the last lecture: put the input into the function in brackets. For , the input of is , which is :
For , the input of is , which is . The function squares its input, so the whole of is squared:
Check both with . First, . Second, . Both agree with the pipelines.
The formulas show clearly that and are two different functions. One is . The other is . So in general:
Now return to the shop. Discount first is . Coupon first is . Compare the two formulas. For every price , the second is 2.5 more than the first. That is the proof promised at the start. It also shows why. When the coupon goes first, the discount then shrinks the coupon too. You only get three quarters of its value, $7.50 instead of $10. So the best order for the customer is discount first, then coupon.
Try many pairs of functions below and look for the rare pairs where the order does not matter.
Choose a function for f and a function for g. Then move the input. The top pipeline runs g first; the bottom one runs f first. Look at the outputs and the two formulas. Can you find a pair where the two orders always agree?
Five pairs of functions, each composed in both orders.
| f(x) | g(x) | fg(x) | gf(x) | Same? |
|---|---|---|---|---|
| 2x + 1 | x² | 2x² + 1 | 4x² + 4x + 1 | No |
| 2x | x + 3 | 2x + 6 | 2x + 3 | No |
| x² | x + 3 | x² + 6x + 9 | x² + 3 | No |
| x + 3 | x − 4 | x − 1 | x − 1 | Yes |
| 2x | 3x | 6x | 6x | Yes |
Two "add" functions always agree in either order, and so do two "multiply" functions. Mixing kinds of step usually breaks the agreement. With f(x) = x² and g(x) = 2x + 1, the orders give the same output at x = 0 and x = −2, but different outputs everywhere else.
What should you have seen? For most pairs, the two pipelines give different outputs and different formulas. A few pairs always agree: two functions that both add, such as and , or two that both multiply, such as and . Adding 3 and then subtracting 4 is the same as subtracting 4 and then adding 3. When the two kinds of step are mixed, the agreement breaks, as it did at the shop. You may also have found an input where two different formulas happen to give the same number, such as for and . One matching number does not make two functions the same. The formulas must agree for every input.
A function inside itself
Nothing stops you from feeding a function into itself. The output of goes back into . We write this as :
With , the input of the outer is . So
Some books write as . Be careful with this. Here the small 2 means "apply twice". It does not mean "square the output", which is . The two are very different: at , , but . In these lectures we write , so there is no doubt.
When the pipeline jams
There is one more thing to check. A composite only works if the output of the first function is an allowed input of the second. Look at these two functions:
The function only accepts inputs that are 0 or more, because a negative number has no real square root.
Now try . First . Then . That works.
Now try . First . Then receives , and is not a real number. The pipeline jams. So only works when , which means .
The other order is different. . This works, because accepts any number. So works whenever .
The rule behind this is short. The outputs of the inner function must be allowed inputs of the outer function. The lecture on domain and range, later in this topic, uses this rule to find exactly which inputs a composite can accept.
Worked examples
and . Find and .
For : is next to , so acts first. The input of is , in brackets: .
For : acts first. The input of is : .
The two differ by 10 for every . This is the shop again. In , the 5 is added before multiplying by 3, so it becomes 15. In , it is added after, so it stays 5.
Check with : and , and . ✓ Also and , and . ✓
and . Find .
When the input is a number, the safest method is to work with the number. is next to the input, so it acts first: . Then . So .
Check with the formula: . At , this is . ✓ Notice the brackets around . Without them you might write , which gives 29.
For comparison, . The order matters again.
. Solve .
First find the formula. We found it above: .
Now solve . Then , so .
Check by running the pipeline: , and . ✓
There is a second way to think about it, working backwards through the pipeline. The last step gave 23, so its input was the number that turns into 23. That number is 11. The first step gave 11, so its input was 5. Running a pipeline backwards is the idea of the next lecture.
. Write as a composite of two simpler functions.
Ask: if I put a number into , what do I do first? First I work out . Then I raise the result to the power 5. So there are two steps. Let the first step be and the second .
The first step is next to , so .
Check: . ✓ With : and , and . ✓
Taking functions apart like this looks like a puzzle for its own sake. It is not. In calculus, the chain rule finds the rate of change of a composite from the rates of change of its parts. You must first see the parts.
Below is a piece of working with one mistake in it. Find it.
A student was asked to find gf(x), where f(x) = x + 3 and g(x) = x² − 1. Tap the line where the working first goes wrong.
A student's working for gf(x), where f(x) = x + 3 and g(x) = x² − 1, with the wrong line marked.
- gf(x) = g(f(x)), so f acts first. (Correct.)
- f(x) = x + 3, so the input of g is x + 3. (Correct.)
- The error: g(x + 3) = x² + 3 − 1. The whole input x + 3 must replace x, in brackets: g(x + 3) = (x + 3)² − 1.
- = x² + 2 (the arithmetic is right, but it follows from the wrong line).
- So gf(x) = x² + 2.
The correct answer is gf(x) = (x + 3)² − 1 = x² + 6x + 8. Check with x = 1: f(1) = 4 and g(4) = 15, and 1 + 6 + 8 = 15. The wrong answer, x² + 2, is in fact fg(x): the student squared x first and added 3 last.
The mistake is worth a second look. Forgetting the brackets did not just give a wrong answer. It quietly swapped the order of the two steps. The student squared first and added 3 last, which is , not . Brackets are how the notation keeps the order. Lose them, and you lose the order.
Three classic mistakes
In , the letter comes first on the page, but acts first. Look at which function is next to . If you are unsure, write the long form and work from the innermost brackets outwards.
Writing two function names side by side means "one after the other", not "multiply". With and , , while .
The whole output of the inner function goes into the outer one. For and , , not . The same care applies to , which is not .
Work each one on paper first. Open a hint only when you are stuck.
-
and . Find and .
Hint 1
For , the function next to the input acts first. Which one is it?
Hint 2
. Now put 3 into .
Full answer
: , then . So . : , then . So . Check with formulas: , and at this is . ✓ , and at this is . ✓
-
and . Find and . Then find the input for which .
Hint 1
. The whole of is squared.
Hint 2
Set . The terms cancel.
Full answer
. . Setting them equal: , so and . Check: and . ✓ The two functions agree at one input only, so they are still different functions.
-
. Find two functions and such that . Then find for the same two functions, and show that .
Hint 1
What do you do first to a number when you work out ? That step is the inner function.
Hint 2
Inner: . Outer: . For , cube first and then double and subtract 7.
Full answer
and , so . In the other order, . At : , but . ✓ They are different, as expected.
-
A science thermometer reads in kelvin (K). The function changes kelvin into degrees Celsius. The function changes degrees Celsius into degrees Fahrenheit. Find the composite that changes kelvin straight into Fahrenheit, and use it to convert 300 K. Which order, or , makes sense here, and why?
Hint 1
The kelvin reading must go into first. Which composite has next to the input?
Hint 2
. Expand the bracket.
Full answer
. For 300 K: , so about 80.3 °F. Check step by step: °C, and . ✓ Only makes sense. expects a temperature in kelvin, and expects one in Celsius. In , the kelvin reading would go into , which treats it as Celsius, and then the answer in Fahrenheit would go into , which treats it as kelvin. The arithmetic would work, but the meaning would not. A composite needs each output to be the right kind of input for the next step. As a final check, : absolute zero is −459.67 °F.
Composition is how mathematics builds complicated things out of simple ones. Almost every formula you meet is a chain of simple steps: add, multiply, square, take a root. Seeing the chain lets you take any formula apart and put it back together.
The order of the steps matters in many places, not only in algebra. Put on socks and then shoes, and you are ready to go out. Do it the other way round, and you are not. In the topic on graph transformations, a stretch followed by a shift gives a different graph from a shift followed by a stretch. In calculus, the chain rule is the method for composites, and it starts by asking which function is inside.
Sometimes the second function exactly undoes the first. Then the pipeline sends every input back to where it started: . That pair is special enough to have its own lecture, and it is the next one.
- A composite function feeds the output of one function into another function.
- means , so the function next to , here , acts first.
- In general , because the order of the steps changes the result.
- To find a composite formula, put the whole inner function into the outer one, in brackets.
- means applying twice, which is different from squaring .
- A composite works only when the outputs of the inner function are allowed inputs of the outer function.