# Composition of Functions With Examples (and Why It’s Important)

(D4M) — Here is the video transcript for this video.

00:00
in this episode you’ll practice using the composition of functions
and you’ll learn why the composition operation is so important let’s do some
[Music] math hi everyone welcome back and this episode we’re going to talk about
the uh definition of composition first um and so here we go so this is f
composed of g so g is the inner function g of x so in
other words when you give this function an x an input
we apply g to the input first and then that output right there the g of x
is sent into the function f and then from there we get an output so
this is the composition of two functions right here
and the way that this works is the domain of f composed of g
is all x in the domain of g right so you have to put g into x so x

00:01
has to be in the domain of g but then also you have to know that
the output the g of x is in the domain of f
and so this is how the composition is defined here
and um so you know let’s look at um actually uh this graphically and kind of
make sense of all these words here let’s make a diagram right so
we’re going to start off by uh looking at a function f
and to do a function f let’s say we use some um
color here let’s let’s let’s use some blue so i’m going to make right here up
here this domain of f so let’s call this domain of
f good and we’re going to map this and so let’s build some range over here
so let’s say we have some it’s a range of f and
we have some function right here that’s going to map

00:02
and let’s call this function f so this is the range of f
so domain of f range of f and we have a mapping or we have a function going from
one to the other and now to make the composition though we’re going to need a
another i’m going to use red here for the g function
and so i’m going to say over here is the domain of g so this is a domain of g
good and in order to make this work the g of x has to go into the function f
so that means g is going to map some some things over here into the domain of f
potentially won’t be empty and so let’s have some like overlap right here
so let’s call this say right here and let’s just you know make it like that

00:03
and so this would be the range of g so let’s call this the range of g
and so we have a function that maps g right here and so here’s the domain of g
and we’re going to get the range of g it’s everything in red right here that’s
the range so this is all the outputs right here and this is all the inputs of g
and for f this is all the inputs and then f maps
and to the outputs this is the range of f right here now this
part right here may be not empty um now you know we may have a part of the
domain of g which takes an input let’s call it say x1
it takes an input and it maps to an output so let’s say g goes to g of x1
right here let’s call that g of x1 here and it may happen that g of x1 is not in
the domain of f which means f cannot take that as an input and give any output

00:04
but it may happen that you have some let’s call this one here in x2
and g is going to map it and so now let’s say
g is going to map this x2 over here into this element right here
which is in the domain of f so then f will be able to map it and so f will map
and i’ll make this in in blue i guess so let’s put this here in blue
so f will map this because it’s in the domain of f so f is going to map it
and it’s going to map this g of x 2 right here and it’s going to give us
some output right here and that output will be f of g of x two
so here’s one that was a starting place but it was a dead end g maps it you know
g can map anything in this domain but for some things in the domain it may lay
it may lay outside of the domain of f but for some things g may map

00:05
to something in the domain of f which f then could just map it right there
so you know arbitrary function f arbitrary function g
this is the scenarios that could happen this overlap right here
which you know we could shade at say an orange or something like here so this
overlap right here is the domain of so this is the domain
of the composition right here i’ll just you know say that i guess
so we have this function right here the composition function and so i’ll
just map here to here here to here and my black went out on me my black pen
there it goes so this will be the composition right here
the composition function right here f composed of g

00:06
it will take this input right here and it goes straight to the output right
there um and so this part right here um this part right here is the intersection
of the range of g in the domain of f um and this part right here which i’ll
just shade in black this is the domain right here um
of f of of this function right here i guess i’ll put it right here
so here’s f composed of g it’s taking things right here all of these things
right here in this in this block right here get mapped into the domain right
here of f and so f can map it so so this so this right here doesn’t
have to cover all of the domain of f there may be some things over here like a y
let’s call this a y1 and f will map it but that won’t have anything to do with
the composition function that won’t have anything to do with the composition

00:07
function because so f can map that right there into the range
but that’s not the composition the composition starts over here
and it gets us an output with g that’s in the domain of f but it may not
be all of the domain of f there may be something outside of here all right so
that’s the composition function and the diagram there
and yeah let’s work out some let’s work out some examples there let’s see if we
can understand this even better so let’s move the definition over here now and
let’s work out some examples so let’s let’s get let me get rid of this real
quick so in our first example right here we’re going to um
take these two functions right here f and g so here’s our function f and
here’s the function g and we’re gonna find these two compositions right here so
let’s make sure that we understand these right here so let’s find this first one
right here the definition that we just uh saw right here was written with this

00:08
order here so let’s you know or here it goes over here yeah so um f
composed of g so the the function that’s
sitting to the right of this composition symbol that’s the function that goes
inside first so order here matters so let’s look at f composed of g of x
what is it well by definition it’s f of g of x
and we know what all this means so let’s just work it out
so this says g of x right here so this is f of g of x what is g of x so
this inner part right here is 3x plus 2 according to what we’re given right here
in this example and now we have to put 3x plus 2
into the function f so i need to put a 3x plus 2 here and a 3x plus 2 here so
this is going to be square root of the input minus 4
and the input is all of this so this would be 3x plus 2 that’s the input minus 4
and this this simplifies to the tiny bit 3x minus 2 right there

00:09
all right very good so what we can see is that the domain of g
is all real numbers and the um the the domain of uh this one right here is
x is greater than or equal to four so we can start talking about you know
what is the domain of this function right here
so we cannot say it’s all real numbers because
we need an input in which we get an output so if you were to just look right
here this formula right here you would say the domain is all real numbers
all real numbers greater than or equal to what three over two
but um did this really take into consideration um f and g
because we need to be able to say uh the domain is all x’s right and
there’s no restriction upon g because g is just three x plus two so we just need

00:10
to make sure that the outputs whatever outputs we get can come in here
and is in the domain of f right and so what is the domain of f it’s x is
greater than or equal to four so i need to make sure that three x plus two
is greater than or equal to four and then if we just move the two over
then we can say uh you know subtract 2 so we get a 2 and so
x is greater than or equal to 2 3. actually which is what i should have put
right there i don’t know why i put 3 halves but 2 3. all right so anyways
uh so we can look right here but we can also look at the functions right here
we need the output right here which is three x plus two needs to be greater than
um you know four because you know we need to make sure we get zero or greater in
order to take the root of it so three x is greater than or equal to two move the
two over and then simply divide by three right so there’s the domain of this one

00:11
right here so now let’s look at the other composition now let’s look at g
composed of f and so this will be g of f of x and so this will be g so f of x is
a square root and so that’s what f of x is and so now i’m
going to take this f of x and substitute it into g so whatever you give g i need
to multiply it by 3. so i’m going to give all of this to g
so multiply it by three and then i’m going to add two so plus two right here
so there we go there’s the g composed of f of x function right here
and we can see that the domain of this right here
is greater than or equal to 4 so the domain is all real numbers x such that x is
greater than or equal to 4. if we try to put a 4 in here it has to go into f
and so going into f means we need to be greater than or equal to four and

00:12
whatever that output is well it doesn’t matter what that output
is because g can take any input in the the domain of g is all real numbers
so the only restriction we’re going to have is to make sure that the x is
greater than or equal to 4 right here so we got two different functions right
here here’s this function right here we have a nice rule for it and we have the
domain and here’s this nice composition right here we have a rule for it and we
have the domain right here all right very good so now let’s look at finding
the composition and so let’s let’s do some more examples here
so now i’m going to give us say this function right here is going to be x plus 2
and the g of x is going to be 4 minus x squared
now the idea behind the composition is we can use simpler basic functions to
build up more complex functions right there by by

00:13
doing this operation composition so for part a we’re going to find f
composed of g of x for part b we’re going to find g composed of f of x
we’re going to see that they’re different again
and then c for part c we’re going to find g composed of f and we’re going to
substitute in minus 2. so let’s find these two things right
here so by definition this means f is composed of the function g of x and so f
is composed of the function g of x we have a rule for that so we can
substitute it in and then now we can take all of this right here
and substitute so what does the function f do
you give input you add 2. so if i give it all of this as the input and then
it’s going to add 2 and so for that right there we’re just
going to get 6 minus x squared now let’s look at this one right here so

00:14
this is g of f of x so f is applied first to the x
so this will be g of and so here we have f of x so x plus 2
and now x plus 2 goes into g so what does g do it does 4 minus the input
and then squared and then now we can simplify this if we wish
since we’re going to plug something into
it maybe we should go ahead and simplify it so this would be 4 minus
and then we’re going to have an x squared plus 2
right so that’s going to be so if we just look at x squared plus 2 that’s x
squared plus 4x plus 4 but i’m going to have a minus
in front of all of that square right so we’re going to get a minus x squared
a minus 4x and a minus 4. and so if we just simplify this
this comes out to be 4 minus 4 so what we’re really getting is minus x squared

00:15
minus four so now we can substitute in minus two into this function
it’s going to be minus and then we’re going to substitute in a minus two
and substitute into minus two all right and so what does all this
become minus 4 and then plus 8. so all together we get out 4.
all right so there we go there’s a b and c part a b and c there’s those two
functions right there so we’re just practicing finding the composition here
all right so now let’s do some more but this time let’s work with some
complex fractions a little bit those are always fun to work with right so let’s
do another example here so here’s the definition again and so let’s do
another example let’s say our function f of x is three x over x minus one

00:16
and our function g of x is two over x so we’re gonna find
f composed of g and then we’ll find the other one g composed of f so let’s do
that right now let’s find f composed of g first and so this is just f of g of x
so what is the g of x that we’re going to substitute in here’s the g of x right
here so this will be f of the g of x which is 2 over x okay good so far
now i’m going to work down right so 2 over x i need to put that into f
so instead of an x i’m going to have 3 and then 2 over x and then another 2
over x down here so here we go 3 times x over 2
oops sorry not x over 2 2 over x 2 over x and then all divided by x or this case

00:17
2 over x minus 1. okay so let’s see what we get here we’re going to get 6 over x
on the numerator and times well maybe let’s don’t do times yet
depending upon my audience let’s call this one as an x over an x so
we’re going to get 2 minus x over x and then now we’ll just say this is 6 over x
times x over 2 minus x all right and so we can write this a
little bit better as saying 6x over x times 2 minus x
so there’s the function right there 6x over x times 2 minus x now here’s the
here’s the crucial part here whenever you’re writing a function rule out
you don’t really want to cancel these x’s here if you’re just working with an
algebraic expression like you didn’t know anything about
anything you weren’t given you weren’t given any of this and all

00:18
you were given is this right here all by itself with no context you would
just say oh that’s an algebraic expression and i would just cancel the x’s
problem is is that this is not an algebraic expression
all by itself it’s it’s being used with any equal sign
it’s being used to represent a function and so what we don’t want to do is
cancel those x’s because what that means is we’re changing the domain
so um to give you an illustration of that let me let me just give you a quick
illustration what’s the difference between these two functions here
this is x over x and this function i’m going to call capital f
as compared to lowercase f but this function is just 1.
do you see the difference between these two functions
well if you don’t let me show you a graph this function right here is just
the line y equals 1. this graph of this function right here lowercase f

00:19
is a graph y equals one also however it’s missing a point it’s missing
a point right there which we denote with a tiny little circle
it’s missing a point so the point is missing now the point is
the point is these two functions are not the same they’re almost the same it’s
just that the domain is different this one has a little bit of a hole in it if
i cancel those x’s then that’s changing the domain so that’s not the same so in
other words if i was to say equals here and then cancel the x’s and say this
well no that’s not right these two representing functions are not
the same function this one has a hole in
it at zero this one does not have a hole in it at zero so we’re not going to do
that at all in terms of the composition right here we’re done that’s the
composition right there don’t cancel those x’s
because we’re using this right here to represent a function and associated with

00:20
the function is your domain all right so here we go now if you
wanted to cancel the zero sorry i almost forgot if you were like dead set on
cancelling the zeros you could say something like this f composed of g of x
is equal to and cancel the zeros but with the caveat is saying x is not zero
so if you put this as a side condition as a restriction or you could even say
with domain if you want to write it like an interval notation
0 but don’t include it union and then 0 to positive infinity if you specify
that we have restricted the domain has changed then you could use this right
here so um yeah if you don’t want to say any of
all that then just just leave the x’s there that’s it then you’re done just
that’s the composition right there all right so anyways let’s find the second

00:21
one right here g composed of f of x now f is going to go first so g of f of x
and so this is our f right here which we’re going to substitute in all of this
is f of x so we’re going to substitute it in right there
so this is g of and then 3x over x minus 1.
and then now let’s take all of this wrap it up as a present and just call it an
input so what does g do when you give an input
it does 2 over the input so this is going to be 2 over whatever all this is
there we go and so again we have a complex fraction so let’s simplify
let’s think of this 2 in the numerator as 2 over 1 times
the reciprocal x minus 1 over 3x and so we can just write it as 2 times x
minus 1 [Music] over 3x right there so there we go
that looks great so there’s the composition right there

00:22
in the you know the domain of the composition right here is
all real numbers except x equals zero and the domain right here of f composed
of g is all real numbers except zero and except two now when
we try to substitute in one into this we cannot substitute in one here also
right because if we substitute in one into f of x you see that we cannot do that
right so we cannot substitute in 1 here so i’m going to say the domain here is
all real numbers except x is not 1 and x is not zero
so we cannot have zero as an output because of g
we cannot have one as an input sorry we cannot have one and zero as inputs
because of what f and g are all right so there we go so here we would say

00:23
our real numbers except 0 and 2 and you know we cannot have a 2 here
right because because y if we substitute in a 2 here that 2 could go into g
but that 2 would give us an output of 1 which we then would have to send into f
but we cannot put in 1 here so you see why we cannot have 0 here
and we cannot have a zero in here because if you try to put zero into g
then you’re going to get two over zero so we cannot have that either
all right so i hope that helps you uh you got to be a little bit careful when
you’re working with um a composition when you have complex
fractions and yeah i’ve seen a lot of people cancel that x right there
and it’s just not just not right all right so uh now let’s look at
a different type of problem let me get this out of our way just really really
quick oh and by the way while i’m doing that i just wanted to say that this
episode is part of the series functions and their graphs step-by-step tutorials

00:24
for um pre-calculus i hope you check out the link below in the description
all right so now we have a problem here we’re actually trying to
reverse the situation here so now i’m given a complex function and i
want to break it down into its pieces so its simpler pieces
and if we do that if we understand the simpler pieces and then we put the
function back together then we can understand this function right here better
so it’s really the powerful part of looking at the composition operation you
can decompose things into smaller pieces which are much easier to understand so
let’s look at this right here identify two functions
and so it looks like we have a squaring function right here
and we also looks like we also have a cube root function right here so
we and g has to be the inside function right here so

00:25
what happens if we say let’s just guess g of x is the inside function right here
because it’s right next to the x so what’s the inside function
that’s sitting inside of the squaring function so i’m going to say
g of x is cube root of x is that a good guess and then f of x is the x squared
so will this function right here the h will that be equal to f composed of g
of x meaning g goes first so if i put g into here then i’ll get f
of cube root of x and then i put cube root of x into f
which means i do cube root of x but f what does f do it squares
so that’s not exactly the same is it right we’re missing the ones and the
fives so actually i’m going to say g of x is cube root of 1

00:26
cube root of x plus 1 and the outside function is going to
square it and then subtract 5. so let’s try it again with those two guesses so
let’s try and see if we can get what they tell us to get
h of x is the composition and here’s the definition of composition
g is on the inside so g of x is cube root of x plus one
all right so that’s all of g of x right there
and then now uh into f i’m going to take all of this and plug it in right there
so cube root of x plus one and then square that
and then f says do all that squaring and then minus five
and so that’s the original function right there
now if you’ve watched previous episodes then we know how to actually sketch the
graph of this right here by doing transformations to that and that’s kind
of the idea behind composition of operation composition operations is to

00:27
take simpler functions we know what the graph of this right here looks like
we know what the graph of this right here looks like and so we can do these
operations uh moving left and right and um moving up and down and so we can do
operations like that to try to figure out how the graph of this looks without
actually trying to plot points and do things like that
so that’s kind of the idea and the importance of let’s do one more real quick
what if we just look at h of x is 1 over x minus 2 squared so what would be the
two functions that we’re trying to make up so we’ll say f composed of g of x
which by definition is g goes first so g is the inside function

00:28
so what’s the function sitting on the inside it looks like x minus 2
that’s sitting inside of the square so i’m going to say g of x is x minus 2
and my outside function the function that’s doing outside the work is 1 over
x squared and so if i substitute in this right here now i get f of x minus 2
and i’m going to put that into f so i’m going to put x minus 2 down here and
voila we get the h of x now is it possible to take a different route
what if i say g of x is how about x minus 2 squared and f of x is just 1 over x
so now h of x will be still the composition won’t it
let’s see so this is f of g of x and g of x is this inside one here

00:29
x minus 2 squared and that is for g of x so that’s going
to go inside of the f that’s that’s the inner function
i got too many parentheses there so f of x minus 2 squared
i guess that’s the same but anyways i take all of that so what does f do it
does one over the input so 1 over this input here and so
that f and g right here also work to give us the composition
in fact you might imagine that we might be able to do three what if we try that
so this time i’m going to say so we got g f and [Music] i’ll call it
little h so i’m going to say g of x is my inside function right here
which is going to be x minus 2 my f of x is going to be squaring something

00:30
and my h of x is going to be 1 over x and now i’m going to do my capital h is
the composition of three functions right here
what’s my innermost function what’s the what’s the change right next to the
input if you if you input something into
this right here what do you do first you minus two so that function is going to
be on the inside and then what do we do next we’re going to square it
so that function will come next but then the outside function will be 1
over doing that so i’m going to say h is my last and then f was the middle one
and then g here was the outside one here so we can do three now
so this by definition is h composed of f composed of g of x
if we apply the composition of operations uh twice
um i left off parentheses in here um so because you don’t we don’t know that

00:31
it’s associative yet or or whatever i’ll just say h composed of f composed of g
this function right here of x and so this is h of f composed of g of x
which is exactly what i had just a second ago i just want to leave room to
put parentheses in there all right so this is h of f of what’s the inside one
x minus two so now i’m going to take x minus 2 into f
so this will be h of x minus 2 into f so that’ll be x minus 2 squared
and then for the last step here we’ll take x minus 2 squared take all of
that and send it into h and it does one over that
and there we go so there’s three different ways of doing that that sounds

00:32
like a lot of fun all right so um now let’s see here let’s go back to this
right here and let’s use a graph to evaluate now so
yeah let’s see how to do that real quick okay so i’m going to give us a graph
here and then we’ll evaluate so the graph will look like um
we’re going to have two graphs we’re going to have an f and a g
so i’m going to have a point right here and it’s going to come down
and then it down a little bit more and then it’s going to go up and then down
and down a little bit more this is a height here of minus one
and then it’s going to go down a little bit more at a different angle
and then it’s going to go up and be real steep

00:33
and it’s going to go up all the way to six so let’s say this height here is six
and this height right here is five and this over here is minus two and
so let’s see here we’re going to go right through here at zero
let’s let’s put the second one here in red so
but i want to have tick marks here so this is going to be a 2
and this is going to be a 3. and i’m going to have this point right here
and i’m going to connect it with the red red’s going to be for the function g
and so i’m at 1 2 so let’s go here with a tick mark for one
and a tick mark for two so at two i’m going to be up here at four
let’s say about right there and so g is going to come down here like that

00:34
and then we’re going to go right here at this peak which is going to be one two
three four five so that’s a five and i’m going to fall all the way
down here to 1 2 3 so let’s say that’s a minus 3 right there
all right so we’re going to fall down really steep
and then we’re going to come back up here at six so [Music]
let’s say i put that at a five but that’s actually out of four
and so five will be about there and then let’s say this is about a 6 right here
and at 6 it’s going to cross about right there
and it’s going to come up to a height of three four
so we got about a four right there so there we go so it’s going to come up

00:35
to about right there and then right there and then we’re going to fall down here
and this is a 10 over here where it hits that ma or it hits the height right
there it’s a 10. all right so we’re going to fall down all the way to
um minus three right here there we go so this is f and this is g so the one in
red is g of x and the one in black is f of x
so let’s see if we can use this graph to evaluate what would f composed of g of
a 5 6 7 7 be let’s make sure i mark seven really good so there’s five and
let’s say six is about here and then seven is about here

00:36
so the height is seven here this is going to be a [Music] height right here
so this will be f of g of seven so we need to know what g of seven is so
g of seven is the three so we’re gonna find the inside part here
first g of seven so i go over here to seven and i input into g
and that’s where i get out the three going across here that’s a three
and i’m gonna send three into f so now if i look over here at 3
3 is about right here and i need to look at f if this one in
black so the height is a 2 right here so i’m looking right here at 3
and then the height [Music] is supposed to be about a 2 right there

00:37
so we’ll call that a point right there so i’m going to go with uh f of 3 is
height of 2 right there all right so let’s find another one what
about f composed of let’s say here we have um three
what is this one right here so this will be f of g of three
so what is g of three so that’s one in red so g of three is zero right there
so now we’re going to send zero into f and f is one black so it goes through
zero zero right there so we’re going to get out zero right there
all right and let’s do two of the reverse in fact let’s just go ahead and do the
same ones so how about g of f of seven that will be g of f of seven
and so what is f of seven so here’s seven right here and i’m going to go to

00:38
f of seven so it’s a minus two right there so this is g of minus two
and is minus two is g of minus two in the domain yes so
g is one in red and so we’re saying it’s a three right there so we got it so
that’s a three and then let’s also do g composed of f of three
so this will be g of f of three and so what is f of three here
so here’s three right here but let’s go back back and look at f right here
so at 3 we get a 2 so this would be g of 2. so here we did g of 3 and g of three
one two three and we went to okay yeah okay so they overlapped there that’s
what confused me all right so g of two right here so we’re gonna take two into

00:39
g now so where’s two and then where is the g right here so g is one in red
so at two we’re going to get a height about a three right there
so g of two is three and so there we go there we go so if you enjoyed this video
like i did uh go ahead and let me know in the comments below um i look forward
to seeing you in the next episode have a great day
if you enjoyed this video please like and subscribe to my channel
and click the bell icon to get new video updates