Exponentials & Logarithms

Graphing Logarithmic Functions Step by Step

Every log graph follows y=alog⁡b(x−h)+ky=a\log_b(x-h)+k: draw the vertical asymptote at x=hx=h, then plot (h+1b, k−a)(h+\tfrac1b,\,k-a), (h+1, k)(h+1,\,k) and (h+b, k+a)(h+b,\,k+a). Join them with a smooth curve that hugs the asymptote and climbs slowly to the right.

y=alog⁡b(x−h)+ky = a\log_b(x-h)+k

Those three points work because they come straight from the definition of a logarithm. The sections below show why, how to avoid the trap that costs the most points (the asymptote comes from the inside of the parentheses after factoring), and how to check a sketch in under a minute.

How do you graph a basic logarithmic function?

The parent graph is y=log⁡b(x)y=\log_b(x) with b>0b>0 and b≠1b\neq1. It has a vertical asymptote along the y-axis, x=0x=0, and it passes through three easy points. Each one comes from the definition in What Is a Logarithm?: log⁡b(x)=y\log_b(x)=y means by=xb^y=x. Since b0=1b^0=1, b1=bb^1=b and b−1=1bb^{-1}=\tfrac1b, the points (1,0)(1,0), (b,1)(b,1) and (1b,−1)(\tfrac1b,-1) always lie on the curve.

The trick is to choose xx-values that are powers of the base, so the outputs are whole numbers. For y=log⁡2(x)y=\log_2(x) the table looks like this:

xx 14\tfrac14 12\tfrac12 11 22 44 88
log⁡2x\log_2 x −2-2 −1-1 00 11 22 33

The domain is (0,∞)(0,\infty) and the range is all real numbers. The curve approaches the y-axis but never touches it, and it never levels off on the right. A common slip is to draw the curve crossing the y-axis, or to end it at a dot on the axis. Instead, bend it downward so it runs alongside the asymptote.

Quick check

Give the three key points of y=log⁡4(x)y=\log_4(x).

Why is a log graph the mirror image of an exponential graph?

Graph of y = 2^x and y = log base 2 of x mirrored across the line y = x
Swapping x and y turns (2, 4) on 2ˣ into (4, 2) on log₂ x, so the log curve must creep upward.

The function y=log⁡b(x)y=\log_b(x) is the inverse of y=bxy=b^x. Inverse functions swap inputs and outputs, so every point (p,q)(p,q) on the exponential graph becomes (q,p)(q,p) on the log graph. Geometrically, the log graph is the exponential graph reflected across the line y=xy=x. The horizontal asymptote y=0y=0 turns into the vertical asymptote x=0x=0, and the y-intercept (0,1)(0,1) turns into the x-intercept (1,0)(1,0). If you already know how to graph exponential functions, you already know the shape of a log graph.

This reflection explains the slow growth. An exponential graph explodes upward, so its mirror image has to creep. For y=log⁡2(x)y=\log_2(x) to reach a height of 1010, xx must be 210=10242^{10}=1024.

Slow growth check

Because log⁡10(1,000,000)=6\log_{10}(1{,}000{,}000)=6, a million on the x-axis sits only 66 units high. A log graph never flattens completely, but it gains just one unit each time xx is multiplied by the base.

The base controls how flat the curve is. Every log graph passes through (1,0)(1,0), but for x>1x>1 a larger base gives a lower curve. At x=8x=8, log⁡28=3\log_2 8=3, log⁡88=1\log_8 8=1 and log⁡108≈0.903\log_{10}8\approx0.903. The natural logarithm y=ln⁡(x)y=\ln(x) uses the base e≈2.718e\approx2.718, so its key points are (1,0)(1,0) and (e,1)(e,1). Where that constant comes from is covered in Euler’s number e.

How do transformations move a logarithmic graph?

Wrong versus right asymptote for log base 2 of 2x minus 6, marked on a number line
Reading the shift straight from 2x − 6 gives x = 6, but factoring to 2(x − 3) puts the asymptote at x = 3.

Every transformed log graph fits one template:

y=alog⁡b(x−h)+ky=a\log_b(x-h)+k

Each letter does one job:

  • hh slides the graph right (left if negative) and moves the asymptote to x=hx=h.
  • kk slides the graph up or down and leaves the asymptote alone.
  • aa stretches the graph vertically by ∣a∣|a|, and flips it over the x-axis if a<0a<0.
  • bb sets how steeply the curve climbs.

The trap is the sign of hh. In log⁡2(x+3)\log_2(x+3) the value is h=−3h=-3, so the asymptote is x=−3x=-3, not x=3x=3. The second trap is a coefficient inside the log. In log⁡2(2x−6)\log_2(2x-6) the shift is not 66. The argument has to be factored as 2(x−3)2(x-3) first, so the shift is 33. Writing awkward expressions in a simpler form with expanding logarithms often makes the shifts visible.

A faster way to read any log graph uses two settings of the argument. Set it to 00 to get the asymptote. Set it to 11 to get an anchor point, because log⁡b(1)=0\log_b(1)=0 and the output is then exactly kk.

Try this: For y=4log⁡5(x+7)−2y=4\log_5(x+7)-2, find the asymptote (argument =0=0) and the anchor point (argument =1=1) without graphing. Answer: the asymptote is x=−7x=-7, and the anchor point is (−6,−2)(-6,-2).

Graphing logarithmic functions with shifts and stretches: worked examples

Example 1. Graph f(x)=2log⁡3(x−1)+1f(x)=2\log_3(x-1)+1. Here a=2a=2, b=3b=3, h=1h=1, k=1k=1.

  1. The asymptote is x=1x=1.
  2. The key points (h+1b, k−a)(h+\tfrac1b,\,k-a), (h+1, k)(h+1,\,k) and (h+b, k+a)(h+b,\,k+a) become (43, −1)(\tfrac43,\,-1), (2, 1)(2,\,1) and (4, 3)(4,\,3).
  3. Check one point: f(4)=2log⁡3(3)+1=3f(4)=2\log_3(3)+1=3. ✓
  4. The domain is (1,∞)(1,\infty) and the range is all real numbers.

To find the x-intercept, set f(x)=0f(x)=0, a method from solving logarithmic equations. Then 2log⁡3(x−1)=−12\log_3(x-1)=-1, so log⁡3(x−1)=−12\log_3(x-1)=-\tfrac12, so x−1=3−1/2x-1=3^{-1/2} and

x=1+13≈1.577.x=1+\frac{1}{\sqrt3}\approx1.577.

Example 2. Graph g(x)=log⁡2(2x−6)g(x)=\log_2(2x-6). Start with the domain: 2x−6>02x-6>0 gives x>3x>3, so the asymptote is x=3x=3. Now factor the argument and use the product property from the logarithm rules:

g(x)=log⁡2(2(x−3))=log⁡22+log⁡2(x−3)=log⁡2(x−3)+1.g(x)=\log_2\big(2(x-3)\big)=\log_2 2+\log_2(x-3)=\log_2(x-3)+1.

This is the parent graph shifted 33 right and 11 up. The key points are (3.5, 0)(3.5,\,0), (4, 1)(4,\,1) and (5, 2)(5,\,2). Check: g(5)=log⁡2(4)=2g(5)=\log_2(4)=2. ✓

Example 2 shows a useful general fact. A factor cc inside the log, log⁡b(cx)\log_b(cx), looks like a horizontal squeeze, but it is the same curve as a vertical shift of log⁡b(c)\log_b(c). Log graphs have no true horizontal stretch. That is why only hh and kk move the picture sideways and up.

Quick check

For y=log⁡3(x+5)y=\log_3(x+5), what is the domain?

How do you find the equation from a log graph?

Work backwards with the same two settings. Read the asymptote to get hh. Then find the point whose xx is exactly one unit to the right of the asymptote. Its height is kk, because the log term is zero there. A third point gives aa.

Example 3. A graph with form y=alog⁡2(x−h)+ky=a\log_2(x-h)+k has asymptote x=−2x=-2 and passes through (−1,3)(-1,3) and (2,5)(2,5).

  1. The asymptote gives h=−2h=-2, so y=alog⁡2(x+2)+ky=a\log_2(x+2)+k.
  2. At x=−1x=-1 the argument is 11, so y=ky=k. The point (−1,3)(-1,3) gives k=3k=3.
  3. At x=2x=2: alog⁡2(4)+3=5a\log_2(4)+3=5, so 2a=22a=2 and a=1a=1.
  4. The equation is y=log⁡2(x+2)+3y=\log_2(x+2)+3.

Check both points: log⁡2(1)+3=3\log_2(1)+3=3 and log⁡2(4)+3=5\log_2(4)+3=5. ✓

This method has a limit. A picture alone cannot tell aa and bb apart. The curve y=2log⁡3(x)y=2\log_3(x) is identical to y=log⁡3(x)y=\log_{\sqrt3}(x), because log⁡3(x)=log⁡3xlog⁡33=2log⁡3x\log_{\sqrt3}(x)=\dfrac{\log_3 x}{\log_3\sqrt3}=2\log_3 x. That is the change of base formula at work. Problems therefore either give the base or ask for any equivalent form.

What changes with a base below 1 or a negative input?

A base between 00 and 11 flips the graph. Let y=log⁡1/b(x)y=\log_{1/b}(x). Then (1b)y=x(\tfrac1b)^y=x, which means b−y=xb^{-y}=x, so −y=log⁡b(x)-y=\log_b(x). The result is

log⁡1/b(x)=−log⁡b(x).\log_{1/b}(x)=-\log_b(x).

So y=log⁡1/2(x)y=\log_{1/2}(x) is the mirror image of y=log⁡2(x)y=\log_2(x) in the x-axis. It still has asymptote x=0x=0 and passes through (1,0)(1,0). Its key points are (12, 1)(\tfrac12,\,1) and (2, −1)(2,\,-1), and it falls from left to right.

Replacing xx by −x-x gives a different reflection, across the y-axis. For y=log⁡2(−x)y=\log_2(-x) the argument must be positive, so x<0x<0. The domain is (−∞,0)(-\infty,0), the asymptote is still x=0x=0, and the curve passes through (−1,0)(-1,0). For example, at x=−8x=-8 the value is log⁡2(8)=3\log_2(8)=3, so (−8,3)(-8,3) is on the graph. Writing log⁡2∣x∣\log_2|x| keeps both branches, since the absolute value makes every nonzero xx valid.

Never plot a point with x≤0x\le0 on a plain log⁡b(x)\log_b(x). No real power of a positive base gives zero or a negative number, so those inputs are undefined, and the graph has nothing there.

Quick check

What is yy when x=9x=9 on the graph of y=log⁡1/3(x)y=\log_{1/3}(x)?

How do you check a log graph, and where is it used?

Before moving on, run these four checks on any sketch:

  1. Set the argument to 00. The curve must run along that vertical line without touching it.
  2. Set the argument to 11. The point must have height kk.
  3. Set the argument to bb. The point must have height k+ak+a.
  4. Confirm direction: a>0a>0 with b>1b>1 rises, and a negative aa or a base below 11 falls.

If the equation is a sum of logs, such as log⁡2x+log⁡2(x−3)\log_2 x+\log_2(x-3), condense it into one log first. The domain then comes from the original terms: both x>0x>0 and x>3x>3 must hold. On a calculator, enter ln⁡(x)/ln⁡(2)\ln(x)/\ln(2) for base 22, since most keys only offer base 1010 and base ee.

Why science uses log scales

Chemists define pH=−log⁡10[H+]\text{pH}=-\log_{10}[\text{H}^+], which is a reflected log graph. A concentration of 0.0010.001 gives a pH of 33, and each drop of one pH unit means ten times more acid.

Log graphs show up wherever a quantity spans huge ranges. Sound level in decibels is 10log⁡10(I/I0)10\log_{10}(I/I_0), so doubling the intensity adds only about 10log⁡102≈310\log_{10}2\approx3 dB. Reading a log graph backwards also answers growth questions: it takes log⁡2(1000)≈9.97\log_2(1000)\approx9.97 doublings to grow 1000-fold. For exact answers to questions like that, see solving exponential equations with logarithms.

Practice problems

0 of 5 solved

  1. State the vertical asymptote of y=log⁡2(x+4)−3y=\log_2(x+4)-3.

  2. Find the domain of f(x)=log⁡5(3−x)f(x)=\log_5(3-x).

  3. Find the x-intercept of y=log⁡3(x−2)+1y=\log_3(x-2)+1.

  4. A graph has the form y=alog⁡4(x−h)+ky=a\log_4(x-h)+k, with vertical asymptote x=2x=2 and passes through (3,−1)(3,-1) and (6,1)(6,1). Find the equation.

  5. Rewrite y=log⁡3(9x−27)y=\log_3(9x-27) as a shifted parent graph, then give its asymptote and x-intercept.

Common questions

How do you graph a logarithmic function step by step?

Draw the vertical asymptote by setting the argument equal to 00. Then plot the points where the argument equals 11, bb and 1b\tfrac1b (after shifting), and draw a smooth curve that hugs the asymptote and rises slowly to the right.

What is the vertical asymptote of a logarithmic function?

For y=alog⁡b(x−h)+ky=a\log_b(x-h)+k it is the line x=hx=h. Find it by setting the expression inside the log equal to 00. Stretches, reflections and vertical shifts never move it.

What are the domain and range of a logarithmic function?

The domain is every xx that makes the argument positive, such as (h,∞)(h,\infty) for log⁡b(x−h)\log_b(x-h). The range is all real numbers, because the graph keeps falling near the asymptote and keeps rising forever.

Why can you not take the logarithm of a negative number?

A logarithm asks which power of a positive base gives the number. A positive base raised to any real power is always positive, so no real exponent produces zero or a negative result.

How do you graph log base 2 on a calculator?

Most calculators only have base 10 and base ee, so enter ln⁡(x)/ln⁡(2)\ln(x)/\ln(2) or log⁡(x)/log⁡(2)\log(x)/\log(2). Many graphing tools also accept the base directly, as in log base 2 of x.

How do you graph the natural log function?

Draw the asymptote x=0x=0, then plot (1,0)(1,0) and (e,1)(e,1), where e≈2.718e\approx2.718. Add (1e,−1)(\tfrac1e,-1) and sketch a curve that drops steeply near the asymptote and flattens to the right.

Up next