mathprecalc

functions + graphs

what a function is, how its graph moves when you change it, and how to undo one.

report a mistake
.md

a function turns each input into one output. its graph is every (x, f(x)) pair drawn at once, and an edit to the formula moves that picture in a way you can read off.

up k
f(x) + k outside the function acts on y, as written
right h
f(x − h) inside acts on x, backwards. the minus moves it right
stretch by a
a · f(x) a negative a flips it over the x axis
squeeze by 1/b
f(bx) toward the y axis. a negative b flips it over the y axis
compose
f(g(x)) g runs first, then f. the other order differs
inverse
f⁻¹(f(x)) = x not 1/f(x). only a one-to-one function has one
reach for it
  • sketching y = 2(x − 1)² − 3 without plotting points
  • reading a graph back into a formula
  • solving for the input: undo the function
  • the next pages, where exponents, logs and trig are graphs that move the same way
on this page
  1. the idea
  2. explore
  3. try it
  4. the rules
  5. worked examples
  6. the key idea up close
  7. pitfalls
  8. practice

the idea

a function is a rule that takes an input and gives back exactly one output. f(x)f(x) names it: ff is the rule, xx is what goes in, and f(x)f(x) is what comes out. f(x)=x2−1f(x) = x^2 - 1 says square the input and subtract 1, so f(3)=8f(3) = 8, and f(−3)=8f(-3) = 8 too. two inputs may share an output. one input never gets two.

the same function shows up three ways: a formula, a table of its values, and a graph, which is every point (x,f(x))(x, f(x)) drawn at once.

xx−2−1012
x2−1x^2 - 130−103

the graph is the table with the gaps filled in: a parabola with its lowest point at (0,−1)(0, -1). edit the formula and the picture moves, and the move can be read straight off the edit. the movie makes three edits to y=x2y = x^2, one at a time.

−6−4−20246−4−2024(0, 0)
start with y=x2y = x^2: every point is (x,x2)(x, x^2), and the lowest one, the vertex, sits at (0,0)(0, 0).

an animation on a plot from x = −6 to 6 and y = −4 to 5: y = x² turns into y = 2(x − 1)² − 3 one move at a time, with the vertex marked and the parent y = x² left behind, dashed. first the parabola slides right 1 and the vertex goes from (0, 0) to (1, 0). then every height doubles, stretching it up away from the x axis, and the vertex stays at (1, 0). then the whole graph drops 3 and the vertex lands at (1, −3).

functions are all over this site. the growth curves on the big o page are functions of nn, and an ease in gsap is a function from the share of the time that has passed to the share of the move that is done.

explore

pick a shape and slide the four numbers in y=a⋅f(b(x−h))+ky = a \cdot f(b(x - h)) + k. the parent shape stays behind, dashed. the readout gives the equation, where two of the parent’s points land, and the domain and range.

−6−4−20246−4−2024(2, −1)(1, −3)
x², the parent
a parabola, the same on both sides of the y axis: (−2)² and 2² are both 4
the vertex
(0, 0) → (1, −3)
the point
(1, 1) → (2, −1)
domain
all x
range
y ≥ −3
the inside, b and h, acts on x and backwards. the outside, a and k, acts on y as written

a plot from x = −6 to 6 and y = −4 to 4 with a row of buttons for seven shapes, x, x², x³, √x, |x|, 1/x and 2ˣ, and four sliders for a, b, h and k in y = a·f(b(x − h)) + k. the parent shape stays behind, dashed, and the transformed graph is drawn over it with two points marked: where the parent's anchor lands, (h, k) for every shape but 2ˣ, whose (0, 1) lands at (h, a + k), and where its point at x = 1 lands, at (h + 1/b, a·f(1) + k). a readout gives the equation, the two points, and the domain and range. it opens on x² with a = 2, b = 1, h = 1 and k = −3: y = 2(x − 1)² − 3, the vertex at (1, −3), the point (1, 1) at (2, −1), domain all x, range y ≥ −3.

switch shapes and leave the sliders where they are: the same four numbers move every parent the same way.

try it

this is |x|, moved. which equation is it?

−6−4−20246−4−2024

pick one.

0 / 0 right

a practice exercise with five kinds of question: pick the equation of a drawn graph, say where a moved shape's vertex, corner, start or center lands, work out f(g(n)) or g(f(n)) for two small functions, find f⁻¹ of a value, or give a formula's domain. it opens on the graph of y = |x + 2| − 1, then f(g(2)) for f(x) = x + 3 and g(x) = 2x, which is 7.

the rules

one output for each input

a function ff pairs each input xx in its domain with one output f(x)f(x). the domain is the set of inputs it accepts, and the range is the set of outputs it reaches.

f:x↦f(x)f(x)=x2−1  ⇒  f(3)=8,  f(−3)=8f : x \mapsto f(x) \qquad f(x) = x^2 - 1 \;\Rightarrow\; f(3) = 8,\; f(-3) = 8

why one output: f(3)f(3) has to mean one number, or f(3)+1f(3) + 1 means nothing. on a graph this is the vertical line test. a vertical line is one input, so if it crosses the graph twice, that input has two outputs and the picture isn’t a function’s graph. a circle fails it. a parabola passes.

two things take inputs out of a domain: a square root of a negative number, and a division by zero. x−2\sqrt{x - 2} needs x≥2x \ge 2, and 1x+1\frac{1}{x + 1} needs x≠−1x \ne -1. the range comes from the shape: x2−1x^2 - 1 is never below −1-1, so its range is y≥−1y \ge -1.

shapes to know by sight

seven parents, with their values at a few inputs and what each one takes and gives. the explore figure draws each one, and the next page is about the last.

f(x)f(x)x=−2x = -2−1-1001122domainrange
xx−2−1012all xxall yy
x2x^241014all xxy≥0y \ge 0
x3x^3−8−1018all xxall yy
x\sqrt{x}––011.41x≥0x \ge 0y≥0y \ge 0
∣x∣\lvert x \rvert21012all xxy≥0y \ge 0
1/x1/x−0.5−1–10.5x≠0x \ne 0y≠0y \ne 0
2x2^x0.250.5124all xxy>0y > 0

transformations

y=a⋅f(b (x−h))+ky = a \cdot f\big(b\,(x - h)\big) + k

outside the function, the changes act on yy as written. inside, they act on xx, and backwards: a minus moves right, a 2 halves the width. the order matters too. a⋅f(x)+ka \cdot f(x) + k multiplies first, then adds, so the stretch comes before the shift up: 2(x−1)2−32(x - 1)^2 - 3 doubles the heights, then drops them by 3. inside, f(b(x−h))f(b(x - h)) squeezes first, then shifts: f(2x−4)=f(2(x−2))f(2x - 4) = f(2(x - 2)) moves right 2, not 4. factor the inside before you read it.

composition

(f∘g)(x)=f(g(x))(f \circ g)(x) = f(g(x))

do gg first, then ff. the inner function runs on the input, and the outer one only ever sees its result. with f(x)=x+3f(x) = x + 3 and g(x)=2xg(x) = 2x: f(g(2))=f(4)=7f(g(2)) = f(4) = 7, but g(f(2))=g(5)=10g(f(2)) = g(5) = 10. in general f(g(x))=2x+3f(g(x)) = 2x + 3 and g(f(x))=2x+6g(f(x)) = 2x + 6, which are never equal.

the transformation rules are compositions. f(x−h)f(x - h) is ff after the shift x↦x−hx \mapsto x - h, and af(x)+ka f(x) + k is the map y↦ay+ky \mapsto ay + k after ff. that is the whole reason inside and outside behave differently: a change inside alters what ff receives, and a change outside alters what ff returned.

inverses

f−1f^{-1} undoes ff:

f−1(f(x))=xf(f−1(y))=yf^{-1}(f(x)) = x \qquad f(f^{-1}(y)) = y

to find it, write y=f(x)y = f(x), swap xx and yy, and solve for yy. the swap is why the graph of f−1f^{-1} is the graph of ff mirrored across the line y=xy = x: every point (a,b)(a, b) on ff becomes (b,a)(b, a) on f−1f^{-1}, and swapping coordinates is that mirror.

only a one-to-one function has an inverse. if two inputs share an output, the inverse would have to send that output back to both, and a function can’t. the horizontal line test checks it: a horizontal line that crosses the graph twice means two inputs with one output. x2x^2 fails, since 33 and −3-3 both give 99. restricting the domain fixes it: x2x^2 on x≥0x \ge 0 passes, and its inverse is x\sqrt{x}.

−4−2024−4−3−2−101234(2.25, 1.5)(1.5, 2.25)

drag the point along f, or tab to it and use the arrow keys

f(x) = x², for x ≥ 0
f(1.5) = 2.25
f⁻¹(x) = √x
f⁻¹(2.25) = 1.5
mirror
(1.5, 2.25) ↔ (2.25, 1.5)

the dashed left half is cut away: with it, 2.25 would come from both 1.5 and −1.5

a plot from x = −5 to 5 and y = −4 to 4 with the line y = x dashed and buttons for four functions: 2x + 1, x² on x ≥ 0, x³ and 2ˣ. the function is drawn in cyan and its inverse in amber, its mirror image across y = x. a point on the function can be dragged along it, or moved with the arrow keys, and its twin on the inverse follows with the coordinates swapped. it opens on x² on x ≥ 0 at (1.5, 2.25), with the twin at (2.25, 1.5), and the readout reads f(1.5) = 2.25 and f⁻¹(2.25) = 1.5. the left half of the parabola is drawn dashed: it is cut away so that each output comes from one input, and a dotted horizontal line shows the second input it would have given, −1.5.

a mirror across y = x swaps the coordinates, which is what swapping x and y in the formula does.

worked examples

sketch y = −|x + 2| + 1

read the formula from the inside out, starting from y=∣x∣y = \lvert x \rvert:

  1. x+2x + 2 is x−(−2)x - (-2): left 2. the corner moves from (0,0)(0, 0) to (−2,0)(-2, 0)
  2. the minus in front: every height is multiplied by −1-1, so the v flips over the x axis and opens down
  3. +1+ 1: up 1. the corner lands at (−2,1)(-2, 1)

the arms follow the same moves: (1,1)(1, 1) lands at (−1,0)(-1, 0) and (−1,1)(-1, 1) at (−3,0)(-3, 0), so the graph crosses the x axis at −1-1 and −3-3. domain: all xx. range: y≤1y \le 1, since the corner is now the top.

read a graph back

a parabola has its vertex at (3,−2)(3, -2) and passes through (4,0)(4, 0). the vertex gives hh and kk:

y=a(x−3)2−2y = a(x - 3)^2 - 2

the other point gives aa. at x=4x = 4: 0=a⋅12−20 = a \cdot 1^2 - 2, so a=2a = 2 and y=2(x−3)2−2y = 2(x - 3)^2 - 2. check: 2(4−3)2−2=02(4 - 3)^2 - 2 = 0.

compose two functions

f(x)=x+3f(x) = x + 3 and g(x)=2xg(x) = 2x. for f(g(5))f(g(5)), gg runs first: g(5)=10g(5) = 10, then f(10)=13f(10) = 13. for g(f(5))g(f(5)): f(5)=8f(5) = 8, then g(8)=16g(8) = 16. as formulas, f(g(x))=2x+3f(g(x)) = 2x + 3 and g(f(x))=2(x+3)=2x+6g(f(x)) = 2(x + 3) = 2x + 6.

find an inverse

f(x)=2x−1f(x) = 2x - 1. write y=2x−1y = 2x - 1, swap: x=2y−1x = 2y - 1, solve: y=x+12y = \frac{x + 1}{2}. so f−1(x)=x+12f^{-1}(x) = \frac{x + 1}{2}. check that it undoes ff: f(4)=7f(4) = 7 and f−1(7)=4f^{-1}(7) = 4. and 1/f(4)=1/7≈0.141/f(4) = 1/7 \approx 0.14 is something else entirely: the −1-1 in f−1f^{-1} is a name, not a power.

restrict a domain

f(x)=x2−1f(x) = x^2 - 1 has no inverse on all of xx: f(3)=f(−3)=8f(3) = f(-3) = 8. on x≥0x \ge 0 it does. swap and solve: x=y2−1x = y^2 - 1, so y=x+1y = \sqrt{x + 1}. its domain is x≥−1x \ge -1, the old range, and its range is y≥0y \ge 0, the old domain. an inverse swaps those too.

the key idea up close

why f(x − h) moves right

let g(x)=f(x−h)g(x) = f(x - h) and feed it the input x+hx + h:

g(x+h)=f(x+h−h)=f(x)g(x + h) = f(x + h - h) = f(x)

whatever ff does at xx, gg does at x+hx + h. so every point (x,f(x))(x, f(x)) of ff‘s graph shows up on gg‘s graph as (x+h,f(x))(x + h, f(x)): the same height, hh further right. the minus inside is a delay. gg has to wait until its input reaches hh before it sees what ff saw at 00. with f(x)=x2f(x) = x^2 and h=1h = 1: ff is 00 at x=0x = 0, and g(x)=(x−1)2g(x) = (x - 1)^2 is 00 at x=1x = 1.

the same argument covers bb. g(x)=f(bx)g(x) = f(bx) has g(x/b)=f(x)g(x / b) = f(x), so ff‘s point at xx lands at x/bx / b: closer to the y axis when ∣b∣>1\lvert b \rvert > 1, and on the other side of it when b<0b < 0. changes outside the function need no argument at all. they act on the output directly, so (x,y)(x, y) goes to (x,ay+k)(x, ay + k).

in one line, the point (x,y)(x, y) of ff‘s graph lands at

(h+xb,  a y+k)\Big(h + \frac{x}{b},\; a\,y + k\Big)

that is what the explore figure’s readout computes, and the first half is why the inside reads backwards: xx is divided by bb and has hh added, the reverse of what the formula does to it.

pitfalls

practice

  1. f(x)=x2−1f(x) = x^2 - 1. find f(3)f(3) and f(−3)f(-3), and say why a function may do that.

    answer

    f(3)=9−1=8f(3) = 9 - 1 = 8 and f(−3)=9−1=8f(-3) = 9 - 1 = 8. two inputs sharing an output is allowed: the rule only promises one output for each input, not one input for each output. it is the other direction, two outputs for one input, that a function can’t do.

  2. give the domain of g(x)=x−2+1x−5g(x) = \sqrt{x - 2} + \dfrac{1}{x - 5}.

    answer

    the square root needs x−2≥0x - 2 \ge 0, so x≥2x \ge 2. the fraction needs x−5≠0x - 5 \ne 0, so x≠5x \ne 5. both at once: x≥2x \ge 2 and x≠5x \ne 5.

  3. describe how y=−2(x+1)2+4y = -2(x + 1)^2 + 4 comes from y=x2y = x^2, give its vertex, and say where the parent’s point (1,1)(1, 1) lands.

    answer

    inside, x+1x + 1: left 1. outside, −2-2: stretched by 2 and flipped over the x axis. then +4+ 4: up 4. the vertex goes from (0,0)(0, 0) to (−1,4)(-1, 4), and the parabola opens down. the point (1,1)(1, 1) lands at (1−1,  −2⋅1+4)=(0,2)(1 - 1,\; -2 \cdot 1 + 4) = (0, 2).

  4. a parabola has its vertex at (3,−2)(3, -2) and passes through (4,0)(4, 0). write its equation.

    answer

    y=a(x−3)2−2y = a(x - 3)^2 - 2 from the vertex. at (4,0)(4, 0): 0=a(4−3)2−2=a−20 = a(4 - 3)^2 - 2 = a - 2, so a=2a = 2. the equation is y=2(x−3)2−2y = 2(x - 3)^2 - 2.

  5. f(x)=x+3f(x) = x + 3 and g(x)=2xg(x) = 2x. find f(g(5))f(g(5)) and g(f(5))g(f(5)), then find every xx with f(g(x))=g(f(x))f(g(x)) = g(f(x)).

    answer

    f(g(5))=f(10)=13f(g(5)) = f(10) = 13 and g(f(5))=g(8)=16g(f(5)) = g(8) = 16. in general f(g(x))=2x+3f(g(x)) = 2x + 3 and g(f(x))=2x+6g(f(x)) = 2x + 6. setting them equal gives 3=63 = 6, which never holds, so there is no such xx: for this pair the order always matters.

  6. f(x)=3x−2f(x) = 3x - 2. find f−1(x)f^{-1}(x) and f−1(7)f^{-1}(7), and check it. then say whether k(x)=x2−1k(x) = x^2 - 1 has an inverse, and give one on a restricted domain.

    answer

    swap and solve: x=3y−2x = 3y - 2, so y=x+23y = \dfrac{x + 2}{3} and f−1(x)=x+23f^{-1}(x) = \dfrac{x + 2}{3}. then f−1(7)=3f^{-1}(7) = 3, and the check: f(3)=9−2=7f(3) = 9 - 2 = 7.

    kk has no inverse on all xx, since k(3)=k(−3)=8k(3) = k(-3) = 8 fails the horizontal line test. on x≥0x \ge 0 it does: x=y2−1x = y^2 - 1 gives k−1(x)=x+1k^{-1}(x) = \sqrt{x + 1}, with domain x≥−1x \ge -1 and range y≥0y \ge 0.