Graphs of logarithmic functions
Every logarithm undoes an exponential. What does the graph of y = log_3(x - 2) + 1 look like, which inputs is it allowed, and which line does it run along?
Where you are 11 in Logarithms
When you reach for it
From Definition of a logarithm you know that \log_b x is the power b must be raised to in order to give x. Read as a rule, y = \log_b x is a function: it takes a positive number and returns an exponent. You also know the graph of y = b^x from Graphs of exponential functions. The two functions undo each other, so by The graph of an inverse the graph of the logarithm is the exponential’s graph reflected in the line y = x. Everything about the logarithmic graph, its shape, the inputs it accepts and the line it runs along, comes from that one reflection.
You reach for this whenever a rule has a logarithm in it and you want its picture: where the graph exists at all, where it shoots down (or up) along a wall, where it crosses the axes, and whether it rises or falls. A rule such as y = \log_3(x - 2) + 1 is the parent graph moved, in the sense of Graphing by transforming a parent graph, so it is drawn by moving a few points and the asymptote, not by plotting point after point.
The procedure
The logarithmic function. For a base b > 0 with b \ne 1, the logarithmic function with base b is
where y = \log_b x means exactly b^y = x. The common logarithm \log x has base 10, and the natural logarithm \ln x has base e \approx 2.718, the base of the The number e and the natural exponential function. Both are cases of the same graph.
Logarithms and exponentials undo each other. Two facts follow straight from the definition:
The first holds because \log_b\left(b^x\right) asks for the power of b that gives b^x, and that power is x. The second holds because \log_b x is, by definition, the power that turns b into x. So applying one function and then the other returns the input you started with: f(x) = \log_b x and g(x) = b^x are inverse functions. The second fact needs x > 0, since \log_b x has no value otherwise.
Swap the coordinates. Because the two are inverses, a point (p, q) lies on y = b^x exactly when (q, p) lies on y = \log_b x: q = b^p says the same as p = \log_b q. The easiest points of the exponential, \displaystyle \left(-1, \frac{1}{b}\right), (0, 1) and (1, b), give the easiest points of the logarithm:
Swapping the coordinates of every point is the reflection in the line y = x.
Domain, range and the asymptote. Swapping coordinates swaps the domain with the range. The exponential accepts every real number and returns only positive numbers, so the logarithm accepts only positive numbers, x > 0, and returns every real number. There is a reason in the definition too: \log_b x = y means b^y = x, and a power of a positive base is never 0 or negative, so \log_b 0 and \log_b(-4) have no value. The exponential’s horizontal asymptote y = 0 reflects to the line x = 0, the y-axis, which is a vertical asymptote of the logarithm. For b > 1, as x \to 0^{+} the logarithm falls without bound, written \log_b x \to -\infty: to get a power of b very close to 0, the exponent must be a large negative number.
Rising or falling. If b > 1 the exponential rises, and so does its reflection: bigger inputs give bigger logarithms. If 0 < b < 1 both fall. In fact a base below 1 gives nothing new, since
so y = \log_{1/b} x is y = \log_b x reflected in the x-axis. (Example 3 shows why.)
Slow growth, but no ceiling. Each step of 1 upward on y = \log_b x needs the input multiplied by b. On y = \log_2 x the height is 10 at x = 2^{10} = 1024, and 20 only at x = 2^{20} = 1{,}048{,}576. The graph flattens as it goes, but it never levels off at a height: any height M, however large, is reached at x = b^M. So a logarithmic graph has no horizontal asymptote; its only asymptote is the vertical one.
Moving the graph. Every moved logarithm in this lesson is written as in Combining transformations and the general form:
with b > 0, b \ne 1 and a \ne 0. The number h shifts the parent right (h > 0) or left (h < 0), a stretches it vertically and flips it over if a < 0, and k shifts it up or down. Each point (p, q) of y = \log_b x lands at
This is allowed because if q = \log_b p, then at the input x = p + h the new rule gives a \log_b\big((p + h) - h\big) + k = a \log_b p + k = aq + k.
Carry the asymptote. The parent’s asymptote is the line x = 0, the points of horizontal position 0. The point rule moves a horizontal position 0 to 0 + h = h, so the new asymptote is the line x = h. Only h moves it: a vertical stretch or shift slides the vertical line x = 0 along itself. This is the exponential’s rule turned on its side, where only the vertical shift moved the horizontal asymptote. The domain moves with the asymptote. The logarithm needs a positive input, x - h > 0, so the domain is x > h. In general, the domain of a logarithm of an expression is where that expression is positive, and the asymptote stands where it equals 0. The range stays all real numbers, because stretching and shifting all real numbers gives all real numbers.
Intercepts. Because the range is all real numbers and the graph rises or falls steadily, the graph of y = a \log_b(x - h) + k crosses the x-axis exactly once. To find the crossing, set y = 0, so \displaystyle \log_b(x - h) = -\frac{k}{a}, and rewrite in exponential form: x = h + b^{-k/a}. The y-intercept is another matter: it exists only if 0 is in the domain, that is, only if h < 0, and then it is a \log_b(-h) + k.
| Feature | y = \log_b x | y = a \log_b(x - h) + k |
|---|---|---|
| A key point | (1, 0) | (h + 1,\ k) |
| The next point | (b, 1) | (h + b,\ a + k) |
| Asymptote | x = 0 | x = h |
| Domain | x > 0 | x > h |
| Range | all real numbers | all real numbers |
Every row follows from the point rule, the asymptote rule and the domain rule above. Draw the asymptote first, dashed; the curve is laid against it on the side where the domain lies.
Worked examples
A logarithm as a mirror image
Graph y = \log_5 x by reflecting y = 5^x in the line y = x. Give its domain, range and asymptote, and the input at which the height is 3.
SolutionPoints of y = 5^x, with their coordinates swapped, are points of y = \log_5 x:
| On y = 5^x | On y = \log_5 x |
|---|---|
| \displaystyle \left(-1, \frac{1}{5}\right) | \displaystyle \left(\frac{1}{5}, -1\right) |
| (0, 1) | (1, 0) |
| (1, 5) | (5, 1) |
| (2, 25) | (25, 2) |
Each right-hand point checks against the definition: \displaystyle \log_5 \frac{1}{5} = -1 because \displaystyle 5^{-1} = \frac{1}{5}, and \log_5 25 = 2 because 5^2 = 25.
The exponential has domain all real numbers, range y > 0 and asymptote y = 0. Swapping the roles of x and y, the logarithm has domain x > 0, range all real numbers and asymptote x = 0, the y-axis. The base 5 is above 1, so the graph rises; as x \to 0^{+} it falls without bound along the y-axis. Height 3 means \log_5 x = 3, that is x = 5^3 = 125, far to the right of the window: the curve climbs from 1 to 2 between x = 5 and x = 25, and from 2 to 3 between x = 25 and x = 125.
Shifted right and up
Graph y = \log_3(x - 2) + 1. Give its asymptote, domain, range and intercepts.
SolutionHere b = 3, h = 2, a = 1 and k = 1: shift y = \log_3 x right 2 and up 1. Each point (p, q) goes to (p + 2,\ q + 1).
| Parent point | Image |
|---|---|
| \displaystyle \left(\frac{1}{3}, -1\right) | \displaystyle \left(\frac{7}{3}, 0\right) |
| (1, 0) | (3, 1) |
| (3, 1) | (5, 2) |
| (9, 2) | (11, 3) |
The asymptote x = 0 moves right 2 to x = 2; the shift up does not touch it. The input must make x - 2 > 0, so the domain is x > 2. The range is all real numbers. The base 3 is above 1, so the graph rises, and as x \to 2^{+} it falls without bound along the line x = 2.
The x-intercept: set y = 0, so \log_3(x - 2) = -1, which in exponential form is \displaystyle x - 2 = 3^{-1} = \frac{1}{3}, giving \displaystyle x = \frac{7}{3}. It is the first point in the table, the image of \displaystyle \left(\frac{1}{3}, -1\right). There is no y-intercept: x = 0 is not in the domain, since \log_3(0 - 2) = \log_3(-2) has no value. Check one point in the rule: at x = 11, \log_3 9 + 1 = 2 + 1 = 3, as the table says.
Flipped over
Graph y = -\log_2 x, give its asymptote and end behavior, and show that it is the same graph as y = \log_{1/2} x.
SolutionThe rule is y = -1 \cdot \log_2 x: reflect y = \log_2 x in the x-axis. Each point (p, q) goes to (p, -q):
A reflection in the x-axis moves no point sideways, so the asymptote stays at x = 0 and the domain stays x > 0. The parent falls without bound as x \to 0^{+}, so the flipped graph rises without bound there: as x \to 0^{+}, y \to \infty. On the right the parent climbs without bound, so as x \to \infty, y \to -\infty. The graph falls everywhere.
Now compare with y = \log_{1/2} x. That rule means \displaystyle \left(\frac{1}{2}\right)^y = x. Since \displaystyle \frac{1}{2} = 2^{-1}, by Powers of powers, products and quotients \displaystyle \left(\frac{1}{2}\right)^y = 2^{-y}, so the rule says 2^{-y} = x, which in logarithmic form is -y = \log_2 x, that is y = -\log_2 x. The two rules give the same output at every positive input, so they have the same graph. A base between 0 and 1 is a reflected base above 1.
Where the input can go
Find the domain and the asymptotes of (a) y = \log_5(12 - 3x) and (b) y = \log_2(x^2 - 4x). For (a), say whether the graph rises or falls and give the points at heights 0, 1 and 2.
Solution(a) The logarithm needs 12 - 3x > 0. Adding 3x to both sides gives 12 > 3x, and dividing by the positive number 3 gives x < 4. So the domain is x < 4, and the asymptote stands where the argument is 0: 12 - 3x = 0 at x = 4. The graph lies to the left of its asymptote, the opposite side from the parent.
As x increases toward 4, the argument 12 - 3x decreases toward 0, and a base-5 logarithm of a shrinking positive number shrinks. So the graph falls, and as x \to 4 from the left it falls without bound. The heights come from exponential form:
So the points are \displaystyle \left(\frac{11}{3}, 0\right), \displaystyle \left(\frac{7}{3}, 1\right) and \displaystyle \left(-\frac{13}{3}, 2\right); the x-intercept is \displaystyle \frac{11}{3}.
(b) The logarithm needs x^2 - 4x > 0, that is x(x - 4) > 0. A product of two numbers is positive when both are positive or both are negative. Both positive: x > 0 and x > 4, so x > 4. Both negative: x < 0 and x < 4, so x < 0. The domain is x < 0 or x > 4, two separate pieces. Between 0 and 4 the argument is negative or zero and the graph has no points at all. The argument is 0 at x = 0 and at x = 4, so the graph has two vertical asymptotes, x = 0 and x = 4, one at the inner end of each piece.
Stretched, flipped and moved
Graph y = -2\log_3(x + 1) + 4. Give its asymptote, domain, range, intercepts and end behavior.
SolutionThe x + 1 is x - (-1), so h = -1, a = -2, b = 3 and k = 4: shift y = \log_3 x left 1, stretch vertically by 2 and reflect in the x-axis, then shift up 4. Each point (p, q) goes to (p - 1,\ -2q + 4):
The asymptote moves left 1 to x = -1, and the domain is x + 1 > 0, that is x > -1. The range is all real numbers. Since a < 0 the rising parent is flipped, so the graph falls: as x \to -1^{+}, y \to \infty, and as x \to \infty, y \to -\infty.
This time 0 is in the domain, so there is a y-intercept: -2\log_3 1 + 4 = 0 + 4 = 4, the point (0, 4). For the x-intercept, set y = 0: 2\log_3(x + 1) = 4, so \log_3(x + 1) = 2 and x + 1 = 3^2 = 9, giving x = 8. Check: -2\log_3 9 + 4 = -4 + 4 = 0.
The base and the shifts from three dots
The graph below is y = \log_b(x - h) + k, with its asymptote drawn dashed at x = -3. Find b, h and k.
The asymptote is x = h, so h = -3 and the rule is y = \log_b(x + 3) + k. The parent’s point (1, 0) lands one unit right of the asymptote, at height k, because \log_b 1 = 0 for every base. The graph passes through (-2, 2), one unit right of x = -3, so k = 2. The point (1, 4) then gives \log_b(1 + 3) + 2 = 4, so \log_b 4 = 2, which in exponential form is b^2 = 4. The base is positive, so b = 2. The rule is
Check with the third point: \log_2(5 + 3) + 2 = 3 + 2 = 5, matching (5, 5).
A function and its inverse
Find the inverse of f(x) = 2^{x+1} - 3. Give the asymptote, domain and range of f and of its inverse, and check that the inverse undoes f.
SolutionFollowing Finding an inverse from a rule, write y = 2^{x+1} - 3 and swap the roles of x and y: x = 2^{y+1} - 3. Adding 3 gives 2^{y+1} = x + 3, and in logarithmic form this is y + 1 = \log_2(x + 3). So
The function f is y = 2^x moved left 1 and down 3: its asymptote is y = -3, its domain all real numbers, its range y > -3. The inverse is y = \log_2 x moved left 3 and down 1: its asymptote is x = -3, its domain x > -3, its range all real numbers. The domain of each is the range of the other, and the two asymptotes are mirror images in y = x. Points of f such as (-1, -2), (0, -1) and (2, 5) appear on the inverse as (-2, -1), (-1, 0) and (5, 2).
The check uses the fact that logarithms and exponentials undo each other:
for every real x, and in the other order f\big(f^{-1}(x)\big) = 2^{\log_2(x + 3)} - 3 = x + 3 - 3 = x for every x > -3, the domain of the inverse.
Boundaries
- The base needs b > 0 and b \ne 1. With b = 1 every power of b is 1, so \log_1 x has no sensible value, and a negative base has no unbroken exponential graph to reflect. The stretch needs a \ne 0; with a = 0 the rule is the line y = k.
- A logarithm, in the real numbers, only accepts positive inputs. \log_b 0 and the logarithm of a negative number have no value, which is why the graph has a domain edge and an asymptote.
- The point rule reads a, h and k from the form a\log_b(x - h) + k exactly. A rule such as \log_b(2x - 6) must have its argument factored, to \log_b\big(2(x - 3)\big): a horizontal compression by 2, then a shift right 3. The quickest safe route to the asymptote and domain is always the argument itself: positive for the domain, zero for the asymptote.
- The asymptote of a moved logarithm is always vertical, and only a horizontal shift moves it. A logarithmic graph has no horizontal asymptote, however slowly it climbs.
- The inverse facts hold on the right domains: \log_b\left(b^x\right) = x for every real x, but b^{\log_b x} = x only for x > 0.
Where this goes next
Solving an equation with logarithms in it, in Solving logarithmic equations, rests on the domain found here: an answer that puts a logarithm’s argument at zero or below is not a solution. The laws of logarithms explain why a horizontal stretch of a logarithmic graph is the same as a vertical shift, and Change of base shows that every logarithmic graph is a vertical stretch of every other, which is why they all share the point (1, 0). The slow climb of the graph is what Logarithmic scales put to use, and Semi-log plots: straightening exponential data with logarithms use the logarithm to straighten exponential data into a line.
Exercises
Drawing each graph
- Graph y = \log x, the common logarithm, from its points at \displaystyle x = \frac{1}{10}, 1, 10 and 100. Give its domain, range and asymptote.
- Graph y = \log_2(x + 4) by moving the points \displaystyle \left(\frac{1}{2}, -1\right), (1, 0), (2, 1) and (4, 2) of y = \log_2 x. Give the asymptote, domain and intercepts.
- Graph y = \log_3 x - 2 from the points of y = \log_3 x at \displaystyle x = \frac{1}{3}, 1, 3 and 9. Give the asymptote and the x-intercept.
- Graph y = \log_{1/3} x from its points at \displaystyle x = \frac{1}{3}, 1, 3 and 9. Does it rise or fall? Which reflection of y = \log_3 x is it?
- Graph y = 3\log_2(x - 1). Give the images of \displaystyle \left(\frac{1}{2}, -1\right), (1, 0), (2, 1) and (4, 2), the asymptote, the domain and the x-intercept.
- Describe y = \log_2(-x) as a move of y = \log_2 x. Give its domain, its asymptote, the points at \displaystyle x = -\frac{1}{2}, -1, -2 and -4, and whether it rises or falls.
Domain and asymptote
- Find the domain and asymptote of y = \log_6(x + 7).
- Find the domain and asymptote of y = \log_2(9 - x). On which side of its asymptote does the graph lie?
- Find the domain and asymptote of y = \ln(2x - 5).
- Find the domain of y = \log_4(x^2 - 1) and its vertical asymptotes.
Rules from described moves
- Shift y = \log_3 x left 5 and up 2. Write the rule, give the asymptote and domain, find the x-intercept exactly, and say between which two integers the y-intercept lies.
- Reflect y = \log_4 x in the x-axis, then shift it right 3. Write the rule, and give the domain, the x-intercept and the points at x = 7 and x = 19.
- The graph in the exercise figure is y = \log_b(x - h) + k, with its asymptote dashed at x = 1. Find the rule, and check it against all three dots.
Inverses
- Find the inverse of f(x) = \log_5(x - 1). Give the domain and range of f and of its inverse.
- Find the inverse of g(x) = 2^x - 6, and give the asymptote of each graph.
- Simplify 9^{\log_9 2}, \log_5 5^{x+1} and 3^{\log_3(x - 2)}, saying for which x the last one is allowed.
Where the graph meets the axes
- Find the x-intercept, y-intercept and asymptote of y = \log_2(x + 8) - 1.
- Find the x-intercept of y = 2\log_3 x + 4. Does the graph have a y-intercept?
Reasoning
- Explain why shifting a logarithmic graph left or right moves its asymptote, while shifting it up or down never does.
- Explain why the graph of y = a\log_b(x - h) + k always crosses the x-axis exactly once, but has a y-intercept only when h < 0.
- Show that \log_{1/b} x = -\log_b x for every x > 0, and say what this means for the graphs of y = \log_{1/b} x and y = \log_b x.
- Brannagh says y = \log_2\left(x^2\right) and y = 2\log_2 x have the same graph. Compare their domains and their values at x = 4 and x = -4, and say what each graph looks like.
- The graph of y = \log_2 x is at height 20 only at x = 2^{20}. Find that input, and explain why the graph still has no horizontal asymptote.
Answers
- Points \displaystyle \left(\frac{1}{10}, -1\right), (1, 0), (10, 1) and (100, 2), since \displaystyle 10^{-1} = \frac{1}{10} and 10^2 = 100. Domain x > 0; range all real numbers; asymptote x = 0. The graph rises.
- Each point moves left 4: \displaystyle \left(-\frac{7}{2}, -1\right), (-3, 0), (-2, 1) and (0, 2). Asymptote x = -4; domain x > -4. x-intercept -3; y-intercept 2, since \log_2 4 = 2.
- Each point moves down 2: \displaystyle \left(\frac{1}{3}, -3\right), (1, -2), (3, -1), (9, 0). Asymptote x = 0; x-intercept 9, since \log_3 x = 2 gives x = 3^2.
- Points \displaystyle \left(\frac{1}{3}, 1\right), (1, 0), (3, -1) and (9, -2): it falls. It is y = -\log_3 x, the reflection of y = \log_3 x in the x-axis.
- Each point (p, q) goes to (p + 1,\ 3q): \displaystyle \left(\frac{3}{2}, -3\right), (2, 0), (3, 3), (5, 6). Asymptote x = 1; domain x > 1; x-intercept 2.
- A reflection in the y-axis: each point (p, q) goes to (-p, q). Domain x < 0; asymptote x = 0. Points \displaystyle \left(-\frac{1}{2}, -1\right), (-1, 0), (-2, 1), (-4, 2). It falls: as x increases toward 0, -x shrinks and so does its logarithm.
- x + 7 > 0: domain x > -7; asymptote x = -7.
- 9 - x > 0: domain x < 9; asymptote x = 9. The graph lies to the left of it.
- 2x - 5 > 0: domain \displaystyle x > \frac{5}{2}; asymptote \displaystyle x = \frac{5}{2}.
- x^2 - 1 > 0, that is (x - 1)(x + 1) > 0: domain x < -1 or x > 1. Asymptotes x = -1 and x = 1.
- y = \log_3(x + 5) + 2. Asymptote x = -5; domain x > -5. Setting y = 0: \log_3(x + 5) = -2, so \displaystyle x + 5 = \frac{1}{9} and \displaystyle x = -\frac{44}{9}. The y-intercept is \log_3 5 + 2; since 3 < 5 < 9, \log_3 5 is between 1 and 2, so the y-intercept is between 3 and 4.
- y = -\log_4(x - 3). Domain x > 3; x-intercept 4, since \log_4 1 = 0. At x = 7, y = -\log_4 4 = -1; at x = 19, y = -\log_4 16 = -2.
- h = 1. The dot (2, -1) is one unit right of the asymptote, so k = -1. The dot (4, 0) gives \log_b 3 - 1 = 0, so \log_b 3 = 1 and b = 3: y = \log_3(x - 1) - 1. Check: at x = 2, 0 - 1 = -1; at x = 4, 1 - 1 = 0; at x = 10, \log_3 9 - 1 = 1.
- Swap: x = \log_5(y - 1), so y - 1 = 5^x and f^{-1}(x) = 5^x + 1. f has domain x > 1 and range all real numbers; f^{-1} has domain all real numbers and range y > 1.
- Swap: x = 2^y - 6, so 2^y = x + 6 and g^{-1}(x) = \log_2(x + 6). The graph of g has asymptote y = -6; the graph of g^{-1} has asymptote x = -6.
- 9^{\log_9 2} = 2; \log_5 5^{x+1} = x + 1 for every real x; 3^{\log_3(x - 2)} = x - 2, allowed only for x > 2.
- \log_2(x + 8) = 1 gives x + 8 = 2, so the x-intercept is -6. y-intercept \log_2 8 - 1 = 3 - 1 = 2. Asymptote x = -8.
- 2\log_3 x = -4 gives \log_3 x = -2, so \displaystyle x = 3^{-2} = \frac{1}{9}. No y-intercept: the domain is x > 0, which leaves out x = 0.
- The asymptote is a vertical line x = h. A left or right shift moves every point sideways, the line included, so the asymptote moves with it. An up or down shift slides every point along its own vertical line, and a vertical line slid along itself is the same line, so the asymptote stays.
- The range of the parent is all real numbers, and stretching by a \ne 0 and shifting by k keeps it all real numbers, so the height 0 is reached; the graph rises or falls steadily, so it is reached once. A y-intercept needs x = 0 in the domain x > h, which happens exactly when h < 0.
- Let y = \log_{1/b} x, so \displaystyle \left(\frac{1}{b}\right)^y = x. Since \displaystyle \frac{1}{b} = b^{-1}, this is b^{-y} = x, so -y = \log_b x and y = -\log_b x. The graph of y = \log_{1/b} x is the graph of y = \log_b x reflected in the x-axis.
- Not the same. \log_2\left(x^2\right) needs only x^2 > 0, so its domain is every x \ne 0; 2\log_2 x needs x > 0. At x = 4 both give 4. At x = -4 the first gives \log_2 16 = 4 and the second has no value. For x > 0 they agree, since if 2^y = x then 2^{2y} = x^2. So the first graph is the second together with its mirror image in the y-axis.
- 2^{20} = 1{,}048{,}576. A horizontal asymptote would be a height the graph approaches but never passes. For any height M the graph reaches M at x = 2^M and goes above it beyond, so no height can be such a line.