Graphing an Inverse Function (by Hand and by Python)

Video Series: Functions and Their Graphs (Step-by-Step Tutorials for Precalculus)

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

00:00
in this episode we’ll practice sketching
the graph of a function and its inverse on the same set of axes the symmetry is
amazing you got to see this let’s do some math [Music]
hi everyone welcome back i’m dave we’re going to start off by uh asking
the question what does the inverse look like
now by inverse i mean inverse function and before we before we get started i
want to say that this episode is a part of the series
uh functions and their graphs step-by-step tutorials for beginners
so find the link below to the full playlist
below in the description and so in the last episode we talked about what
inverse functions are and so we want to continue
on um with that discussion so so far we talked about you know what inverses are

00:01
and how to verify if two functions are inverses or not
and so this episode we’re going to talk about uh graphing functions
um and their inverses on the same set of axes and we’re going to do that by hand
and also by looking at python and seeing how to do that
so yeah let’s get started um so i’m going to start us off by looking at
a function here and i’m going to use f of x equals 2x plus 3 and the inverse is
the function x minus 3 over 2. now in the previous episode we talked about
an informal way of finding the inverse just by
sort of guessing and then verifying um and so we did lots of examples of
that and so this is what i would guess would be the inverse
and the reason why is because if we input an x here the first thing we’re
going to do is multiply by two and then we’re going to add a three so how do you

00:02
undo all that if you’ve multiplied by two first and then you added that to a
three so i’m going to first undo the three and and do that first right so the
reverse order and then divide by two so i’m reversing the order and i’m
reversing the operations all right and so we could check that
these are inverses and we did lots of practice of that last video so we would
check that both of these compositions are the identity this right here
and this right here and so we practiced that
uh in with lots of examples in the last video so we we could check that
but i’m of course in this video i’m going to concentrate on more of what
they look like so let’s graph both of these on the same
set of axes and so we can see what’s happening here so let’s graph
2x plus 3 um and here we go so let’s look at that
so here we’re going to have 2x plus 3 and i’m going to plot some points like

00:03
um you know what happens when x is 0 so then we’re going to get a 3 right here
and then what happens when x is one then we’re going to get out here a five
and so let’s put that up here so this looks this looks like a three
and then at one we’re at a five so we got this these two points there and then
what happens when we’re at minus one at minus one we’re going to be um
at a height of one so that should go through um 2x plus 3 and you know
let’s just put here the 0 down here it’s about what minus 1.5
right there and then how about one more over here how about
when we’re at minus four that will give us um a minus eight plus

00:04
three so that gives us like a a minus four right here right um
add a minus five so let’s say minus five is about right there
so that will give us a um or let’s go to minus four right here
that will give us a minus eight and then
plus three so that would be like a minus five right there yeah minus five so
let’s leave a minus four on here and say minus five right here
and so basically what we have here is this line going through here 2x plus 3
and let’s put this in blue all right and so then we got this line
going right through here at this point and this point and this point
and this point right there and so this is the graph of
um f of x equals 2x plus 3. let’s put that in blue there
all right and so now let’s graph this inverse right here let’s plot a couple
points and see how it’s different so first off

00:05
we’re going to have this zero right here which is what -1.5
zero so now it’s one point minus one point five in and zero so so this point
right here becomes on the inverse becomes about right there let’s say
and so then we have the point here uh 0 3 and now that becomes the point here
3 0 so let’s put it about right there so we’ve got two points on our inverse so
far in fact let’s go ahead and see if we can make those red so there’s
the in two points there and then what about this point right here so so the um
on the y-axis we got five we got one five right so now we’re going to go up
here and get it 5 1. so this was a 3 and then this was about a 5 right here so
say there’s about a 5 right there and then about a 1 right there
and so looks like we’re coming through there like that
um and so let’s see if we can just put a line through there

00:06
and then it’s going to come down and and uh let’s see here about -5 right here
um let’s see minus 5 right here we’re going to have the minus 4 right there so
let’s put it in about right there okay so yeah so that would be minus 5
minus 8 over 2 so minus 4 right there all right so this would be the inverse
function right here inverse function which should be x minus 3 over 2
okay so yeah so if we try to understand this graph and are these two graphs and
how they’re related what happens is is these graphs are symmetric about the line
y equals x which just passes right through here
so i’ll just say y equals x right there that’s the line here in orange and
yeah so it’s just going to pass right through there and there’s where it
intersects right there y equals x there’s that line right there and so
it’s just symmetric about this line right here these two graphs

00:07
the graph of a function and its inverse is always symmetric about the line y
equals x and so yeah just here’s a couple of um you know we have x and f of x
and we got the points here 1 5 zero three minus three over two zero
and minus four minus five just to give us a couple points and then we have the
table for the f inverse which is of course just the you know five one
three zero zero minus three over two minus five minus four right so you get
this table immediately once you know the function and once you know
that it has an inverse function um yeah and so that’s actually
something we’re going to do on the next episode is we’re going to
look to see how to determine if a function in fact has an inverse and
we’re going to do that graphically we talked about that a little bit in the

00:08
previous video but yeah so now let’s look at one more example here so let’s
do this let’s do one more by hand so there’s our first one let me get rid
of this for us all right and so in the next one here
we’re going to be looking at the function here uh f of x is equal to
uh let’s go with um square root of x plus 2
and its inverse function is going to be x squared minus 2. with the caveat that
x is [Music] you know got some restriction right here because
this right here is not going to be the exact inverse right here
so what’s going to be the restriction right here
upon this right here so this right here is going to be like something like um

00:09
[Music] you know what’s the range of this function right here will be
0 and greater and so that’s the domain over here so this is
x squared minus two but then x has to be greater than or equal to zero
so these are functions these are inverse functions
um but don’t don’t forget that uh domain right there if you if you leave off the
domain and just say x squared minus 2 that these are not inverse functions in
so this this domain right here that is is the natural domain which is just x is
greater than or equal to minus 2. you can substitute in minus 2 and greater
that’s the natural domain you don’t need to mention that but if you leave this
off the natural domain of this function is all real numbers so for them to be
inverses we would have to make sure and specify the domain for this right here
all right so let’s see how these uh functions right here look so
this right here we know from previous episodes it just looks like the square

00:10
root function but it’s been shifted uh to the left by
two units so it’s going to look something like this it’s just going to
be a square root looking function square
root there we go it’s just going to keep increasing
but it increases slower and slower maybe i’ll just uh you know put it something
like that right there right so it’s just always increasing and right here is a
minus 2 right here so now how does this function right here look like
so this looks like a parabola right it’s just y equals x squared right but it’s
been shifted down 2 units so i’m gonna go one two and so then now it’s just been
it’s just going to look like a parabola right here like this just
like that but it’s only x is greater than or equal to two
uh sorry x greater than equal to zero so we’re only going to take the right
branch of it so i’m gonna have this just coming up here like that right there
so this is the graph of f of x x plus two and this is the graph of f inverse

00:11
which is x squared minus two x greater than or equal to zero so
yeah we can put this one here in red we can shade it red if we want and
it just keeps wanting to roll in the way and we can shade this one here in blue
if we want and notice that what the range and domain are for these right here
so this point um minus 2 0 now becomes 0 minus 2
those and you pick any point on here x y and then you get the other point right
here if this one’s x y then this one will be y x so if we look
through the y equals x line i’ll pass right
through there y equals x line so these two graphs are symmetric
about the line y equals x any two functions if they’re inverses of
each other they’re symmetric about the line y equals x

00:12
and we can plot a lot more points and you could see for example what would
this point right here be where would this one right here cross
the y axis so that’s when x is 0 so that’s the square root of 2 right there
so the height is square root of 2. and so what would this point right here
be so that’s this is the point here 0 square root of 2 so now this would be
square root of 2 0 right there so that tick mark right there is square root of
2 right there all right and so yeah so graphing them by hand it can be fun
especially when you start looking at the trig functions the trig and the inverse
trig functions then it gets to be a lot of fun or if you’re sketching
exponentials and then the inverses will turn out to be logarithm functions
so graphing them uh on the same set of axes is also fun
so yeah there we go so let’s take a look at how to
also do this using python so let’s see how to do that now so let’s go to python

00:13
here and uh let’s get rid of this stuff right here real quick so using python
now if you’ve never used python before we’re using a python notebook and
there’s a link below in the description if you’ve never used a python notebook
before and how you can open up and start using your first python notebook it’s
it’s free and you can do that and you can just follow along in this
video or if you’ve been following along on the whole series maybe by now you
have already got your python notebook set up in any case here’s our setup that
we’re going to use for this video right here we’re going to import the matte
plot library splt and we’re going to import the numpy as np
and so let’s go ahead and execute that cell right there shift enter to execute
so i just got to type that up exactly as you see it
now if you’ve watched the uh series so far you know this function right here by
now it’s how i customize my axes i call this the precalculus axes definition

00:14
right here and it’s because the python axes by default i don’t like them
and so i just want to customize my axes right here all right and so now i’m
going to make up a definition that’s going to help us plot some
functions and their inverses on the same set of axes right here so i’m going to
this function right here was is going to be defined right here and it’s going to
be called plot functions with an s so in the previous episode i used one
that was called plot function and so i added an s right here and then we’re
going to input two functions right here function one function two
and when we plot them we’re gonna have for our x values we’re gonna have a min
and a max and so i’m gonna call this x minimum x maximum and then i’m gonna
have an increment value right here and you can make this finer if you want like
0.00 if you’d like it to be less choppy all right and so yeah let’s just type up
this definition right here which is basically going to plot two
functions right here and then it’s going to show them right here so we’re going

00:15
to plot with the x’s the same x values y one and same values for x y two
all right there we go we executed that uh input four
and so now let’s look at some examples so let’s go over here and
so now we’ve done our definition we’ve done our setup now let’s go look at some
examples real quick so in these examples right here we’re going to show that f
and g are inverse functions and here’s the first example right here
and so this right here makes sense from what we said before let’s see if we can
get bigger right here this makes sense from what we said
before right um in a previous episode we said you know what’s the inverse of 2x
how do you undo multiplying something by 2 well you divide it by two right so it
seems like these would be inverse functions right so um let’s uh execute
this definition right here so i’m going to define f uh function f1 which will be
my 2x 2 times x and then i’ll um execute my definition for g1 so this is g

00:16
example one so i call it function g1 and basically it’s just take an x in and
then divide it by two and and send it out in any case there’s my definitions
of my functions and i’m going to go ahead and plot it and i’m doing this all
in one cell and so there’s the plot functions
there’s there’s the f1 there’s the g1 right the f1 has slope 2
and it’s the steeper one so that one going through right through there is is uh
y equals two x and then this right here is y equals one half x and it has a much
slower slope right there so there we go there’s the plot of f and g
and you can see how they’re symmetric through the line y equals zero sorry y
equals x which is just basically going right through the middle there
all right so now let’s look at our next example
so here we got two functions right here this function is going to take an input

00:17
and it’s going to multiply by -4 and then it’s going to add three
so to undo that we’re then we’re going to first multiply by x
uh negative one add three and then divide by four right there so
um that’s one way to write it another way to write this is um do x plus three
and then divide by minus four so that those two things are the same right there
so because if you’re wondering like informally like how did you do that you
first multiply by minus four and over here i’m last going to divide by minus
four and then over here at last i add three
right because when you input an x you first do this and then you add the three
and then over here i’m first going to uh actually it would be minus three
wouldn’t it i’m going to first subtract three
um and then i’m going to divide by minus four so yeah these two things are the

00:18
same here and we can just see that by just simply in the numerator just
factoring out a minus sign right there so that’d be x minus 3
over 4 and then just move the minus sign to the bottom right there so if you’re
looking at this and just learning this the first time this would probably be a
better way to think about this but either way these are the same
and so yeah i’m just going to define this function f2
and it’ll be 3 times -4 x and then g2 will be 3 minus x and then
actually let’s move the parenthesis right there it won’t matter but i’m just
going to do it anyways here and then now let’s just shift enter that
so here we’re plotting f2 and g2 and so we can see
that’s just going to be symmetric right there through the y equals x line now
you can see right here this point right here

00:19
is zero something and then you got the exact uh opposite point over here in
yellow which is going to be some intersection right there
yeah so this looks good and okay so let’s go on to
so this one has got negative slope going right through there
and this one right here um also has negative slope but it’s just not as steep
all right so now let’s look at uh something like this right here so this
one i didn’t use the plot functions and the reason why is
because the problem with the plot functions definition that we used earlier
the problem with it of doing something simple like this
is that it uses the same inputs for both functions
but in fact you don’t have the same domain generally speaking
so to have the most flexibility i just took out the insides of the function and
i put it right here so and also i want to set the aspect ratio of the

00:20
plot and so this will make it seem more the aspect ratio be the same so a circle
will look like a circle in other words instead of an ellipse but in any case
yeah i’m still going to customize my axes i’m going to set the aspect rate
ratio to be the same so in other words this distance to get to 30
is the same distance to get the 30 over here
in any case i’m going to for the x1s for this function right here the domain
is you know we’re going to start at 4 and go large
and for this function right here right so for this one right here i need four
and great i need greater than or equal to four for this function right here
with this function right here i need greater than or equal to zero now the
reason why is because remember the domain of this function is
the range of this function and the range of this function is the
domain of this function so that’s why you switch them like that

00:21
and so i’m yeah i’m going to say the x’s for the
for the first function right here um will will be on this domain right here
and the x’s for this one right here will start at zero so that’s why i have a
zero here and a four here um and so and i also incremented the increment uh
all right so i also changed the increment right there to be a little bit
finer right there all right so we’re going to graph yeah x
x 2 squared so in other words x squared plus 4 so we got that right there
and i said x2 because those are my inputs
and here i said x1 because those are my inputs right there
all right and then we’re going to plot x2 y2 and we’re going to plot x1 y1 so
we’ve got two functions basically all right and then i’m also going to plot um
[Music] the identity but i don’t see it actually
plotted right here so let’s execute this and see what happens here

00:22
so i don’t see the identity function showing up here so that’s okay so
i’ve told it to plot uh x3 is going from 0 to 30 and
so maybe it’s just some color that i can’t see
but it certainly doesn’t look like the y equals x for this for these x’s are
showing up here on the plot uh any case there is the function here
the first function right here is square root it’s been shifted to the right four
units so there we go it starts at four and
goes right there and then the y equals x
line should be coming right through here and if i do the inverse right here
then that will look like the parabola shifted up four units but we’re only
going to look at the right branch of it so there we go right there so there’s uh

00:23
y uh x equals uh x square plus four but only
the right branch of it and so that these are inverses right here you can see how
they’re symmetric about the y equals x axis in other words four
zeros here and then zero fours right here
all right so very good so let’s look at one more maybe
so here we have square root also so 2x minus 3
and then again the outputs have to be 0 or greater which means the inputs over
here are 0 or greater so i’m going to restrict the domain so
i’m going to have two different domains so i’m going to use this stuff again
here which we just did right here right so i’m going to customize my axes so
they have nice arrows and the aspect ratio is going to be
equal and this time we’re going to go on the axes here um so to 10 and then
to five um yeah and so it’s going to go to 10

00:24
and then this one goes up a little bit higher right there so so they both so
this distance right here to 10 is the same distance right there to 10
right there but this but this goes all the way up to 14 right there
all right so we got the x ones for the first function right here
and they go from 1.5 so i got 1.5 by looking at 2x minus 3
is greater equal to 0 because we have to take the square root of it yeah and so
just moving the 3 over and dividing by 2 1.5 right so that domain right here is
1.5 and we’re going to 10 and that just looks like the square root
function right there but it’s been shifted a little bit
and so there we are right there and so yeah you can see the line y equals x and
how these two functions are symmetric about the y equals x line right there so
for the second function we’re just going to do x squared
so that’ll be x 2 square because i’m using x 2s for my domain so x 2 squared

00:25
and then plus 3 and then all that divided by 2 right there
and so then we’ll plot x2 y2 and then again here it didn’t show the x3 y3
it didn’t show it but i drew it in right here so that’s good right there
all right so there we go yeah so you know there’s how easy it is to use python
to sketch the function and its inverses or its inverse function also on the same
set of axes so yeah i hope you enjoyed this video hope you had a lot of fun in
the next episode we’re going to talk about how do you know if a function or
not has an inverse function and then the episode after that we’re
going to talk about how to actually find the inverse function and not just
informally by just sort of guessing and verifying i’ll show you a method that
you can use but first in the next episode i’ll show you how that you

00:26
absolutely know whether or not a function has an inverse
all right so i want to say thank you for watching until i see you next time 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

About The Author
Dave White Background Blue Shirt Squiggles Smile

David A. Smith (Dave)

Mathematics Educator

David A. Smith is the CEO and founder of Dave4Math. His background is in mathematics (B.S. & M.S. in Mathematics), computer science, and undergraduate teaching (15+ years). With extensive experience in higher education and a passion for learning, his professional and academic careers revolve around advancing knowledge for himself and others. His work helps others learn about subjects that can help them in their personal and professional lives.

Let's do some math together, today!

Contact us today.

Account

Affiliates

About Us

Blog

© 2022 DAVE4MATH.com

Privacy Policy | Terms of Service