Algebra of functions and composition · Mathematics Class 11–12 | StemPy Lab
Course 1.3·Lesson 1 of 3
Algebra of functions and composition
We add, subtract, multiply and divide functions point by point, on the part of the domain that both share (and with a nonzero denominator for the quotient). The composite function (g∘f)(x) = g(f(x)) applies f first and then g. The order matters, and its domain is the set of x in the domain of f for which f(x) is in the domain of g.
about 25 min1 simulation2 practice questions
Lesson 1 of 3Show all lessonsHide
Try the code and the simulations beside the lesson.
Doing arithmetic with functions
Two functions can be combined in the same way as two numbers. We do it point by point: at each x we find f(x) and g(x), and then we add, subtract, multiply or divide the two numbers.
New function
Rule
Domain
f+g
(f+g)(x)=f(x)+g(x)
x in both domains
f−g
(f−g)(x)=f(x)−g(x)
x in both domains
fg
(fg)(x)=f(x)g(x)
x in both domains
gf
(gf)(x)=g(x)f(x)
x in both domains, and g(x)=0
cf
(cf)(x)=cf(x)
the domain of f
Example. Let f(x)=x and g(x)=x−4. The domain of f is [0,∞) and the domain of g is R. So the shared domain is [0,∞).
(f+g)(x)=x+x−4, with domain [0,∞).
(fg)(x)=x(x−4), with domain [0,∞).
(gf)(x)=x−4x. Also g(x)=0, so x=4. The domain is [0,4)∪(4,∞).
Doing one function after another
Think of converting a length. A machine f changes metres to centimetres: f(x)=100x. A second machine g changes centimetres to millimetres: g(x)=10x. Put them one after the other, and a length in metres becomes a length in millimetres. We can replace the two machines by one: x↦1000x.
This is a composite function. The composite of f and g, with f first, is written g∘f (read "g after f"):
(g∘f)(x)=g(f(x))
Two machines in a row. The number x equal to 3 enters the first machine f, which multiplies by 2 and adds 1, and it gives f of 3 equal to 7. The number 7 enters the second machine g, which squares, and it gives g of f of 3 equal to 49. A note says that one machine after the other is the composite function g after f, which is 2x plus 1, squared.
In the picture, f(x)=2x+1 and g(x)=x2. For x=3, we get f(3)=7, and then g(7)=49. So (g∘f)(3)=49.
The order matters. For the same functions,
(g∘f)(x)=(2x+1)2but(f∘g)(x)=2x2+1
At x=3 the first is 49 and the second is 19. In general, g∘f=f∘g. Putting on your socks and then your shoes is not the same as shoes and then socks.
Set b=1: the two lines meet everywhere, because multiplying by 1 does nothing. For other b, the order of the two machines changes the answer.
The domain of a composite function
For g(f(x)) to make sense, two things must hold: x must be in the domain of f, and then f(x) must be in the domain of g.
Example. Let f(x)=x−4 and g(x)=x.
(g∘f)(x)=x−4. We need x−4≥0, so the domain is [4,∞).
(f∘g)(x)=x−4. We need only x≥0, so the domain is [0,∞).
The two functions are different in the rule and in the domain.
Three facts
Composition is associative:h∘(g∘f)=(h∘g)∘f. So we can write h∘g∘f without brackets.
The identity functionI(x)=x changes nothing: f∘I=I∘f=f.
It is usually not commutative:g∘f=f∘g.
Taking a function apart
A complicated function is often a composite of simple ones. To take it apart, ask: what do I do first to x, and what do I do last?
Example.h(x)=x2+1. First we square x and add 1, so f(x)=x2+1. Last we take the root, so g(x)=x. Then h=g∘f.
Practise with new numbers
Try it in Python
Python can build a composite function from two functions. This program makes g∘f and f∘g and compares them.
Remember these
(f+g)(x), (fg)(x) and so on are found point by point, on the domain that both functions share.
For a quotient, remove the x where the denominator function is zero.
(g∘f)(x)=g(f(x)): the function inside works first.
In general, g∘f=f∘g.
The domain of g∘f: x in the domain of f, with f(x) in the domain of g.
Check yourself
Try each one on your own first. If you are stuck, open a hint. Then check with Show the answer.
If f(x)=3x and g(x)=x−2, find (g∘f)(x) and (f∘g)(x).
Find the domain of gf when f(x)=x+1 and g(x)=x2−1.
Write h(x)=(x−5)3 as g∘f.
f(x)=x2 and g(x)=x. Is (f∘g)(x)=x for every real x?
Enroll free in Combining and Reversing Functions
Every lesson is open to read. Enrolling also lets you:
Mark lessons done and carry on where you stopped.
Take the tests of this lesson and its course.
Count the course towards the certificate for its chapter.