Skip to contentSkip to lesson map

Modeling with Exponential Functions I

Reading
MMAC Ch 2.2, pp 138-141
Practice
Optional HW 5 Q5.1, Q7.2, and Q9.1.
Lesson map

Objectives

  1. Use log and exponent rules to solve equations or simplify expressions.
  2. Interpret the parameters CC and kk of an exponential function, and describe how the function changes as each is adjusted.
  3. Given kk, calculate the doubling/halving rate of an exponential process (and vice-versa).
  4. Use log rules to show an exponential function becomes ln⁡(y)=mx+b\ln(y) = mx + b in semi-log form, where k=mk = m and C=ebC = e^{b}.
  5. Given a function or dataset, use plotPoints() to obtain a semi-log plot.
  6. In R, use makeFun() and plotFun() to define and plot logarithmic functions.

1. Log and Exponent Rules

Objective. Use log and exponent rules to solve equations or simplify expressions.

The natural logarithm is ln⁡(x)\ln(x), the inverse of the natural exponential function exe^{x}, with domain (0,∞)(0, \infty).

Every logarithm in this course is the natural logarithm. The R spellings log(x) and exp(x) are on the Lesson 1 sheet, section 2.

Rule 1 (Log and exponent rules).

For u>0u > 0, w>0w > 0, and real numbers rr and ss, with ss a positive integer in urs=ur/s\sqrt[s]{u^{r}} = u^{r/s}, the rules below hold.

Inverse pairsLog algebraExponents
eln⁡(u)=ue^{\ln(u)} = uln⁡(uw)=ln⁡(u)+ln⁡(w)\ln(uw) = \ln(u) + \ln(w)urus=ur+su^{r}u^{s} = u^{r+s}
ln⁡(er)=r\ln(e^{r}) = rln⁡ ⁣(uw)=ln⁡(u)−ln⁡(w)\ln\!\left(\tfrac{u}{w}\right) = \ln(u) - \ln(w)urs=ur/s\sqrt[s]{u^{r}} = u^{r/s}
ln⁡(1)=0\ln(1) = 0ln⁡(ur)=rln⁡(u)\ln(u^{r}) = r\ln(u)1us=u−s\tfrac{1}{u^{s}} = u^{-s}
ln⁡(e)=1\ln(e) = 1ln⁡ ⁣(1w)=−ln⁡(w)\ln\!\left(\tfrac{1}{w}\right) = -\ln(w)

Solving for a variable in the exponent.

  1. Isolate the exponential e(⋅)e^{(\cdot)} on one side.
  2. Apply ln⁡\ln to both sides. The other side must be positive, because e(⋅)e^{(\cdot)} is always positive; when it is zero or negative, the equation has no solution.
  3. Use ln⁡(er)=r\ln(e^{r}) = r to bring the exponent down.
  4. Solve for the variable with ordinary algebra.

Solving with a sum or difference of logarithms.

  1. Combine the sum or difference into a single logarithm with the log algebra rules.
  2. Apply e(⋅)e^{(\cdot)} to both sides.
  3. Use eln⁡(u)=ue^{\ln(u)} = u to clear the logarithm.
  4. Solve for the variable with ordinary algebra.
  5. Keep only the solutions at which every logarithm in the original equation is defined.

Example 1

Simplify by hand:

ln⁡ ⁣(e5)+ln⁡ ⁣(1e2)+ln⁡ ⁣(e3e). \ln\!\left(\sqrt{e^{5}}\right) + \ln\!\left(\frac{1}{e^{2}}\right) + \ln\!\left(e^{3}e\right).
ShowHide solution

Rewrite each argument as a single power of ee, then bring each exponent down:

ln⁡ ⁣(e5)+ln⁡ ⁣(1e2)+ln⁡ ⁣(e3e)=ln⁡ ⁣(e5/2)+ln⁡ ⁣(e−2)+ln⁡ ⁣(e4)urs=ur/s,  1us=u−s,  urus=ur+s=52−2+4ln⁡(er)=r=92=4.5.\begin{align*} &\ln\!\left(\sqrt{e^{5}}\right) + \ln\!\left(\tfrac{1}{e^{2}}\right) + \ln\!\left(e^{3}e\right) \\ &= \ln\!\left(e^{5/2}\right) + \ln\!\left(e^{-2}\right) + \ln\!\left(e^{4}\right) & &\sqrt[s]{u^{r}} = u^{r/s},\ \ \tfrac{1}{u^{s}} = u^{-s},\ \ u^{r}u^{s} = u^{r+s} \\ &= \tfrac{5}{2} - 2 + 4 & &\ln(e^{r}) = r \\ &= \tfrac{9}{2} = 4.5. & & \end{align*}

Example 2

Simplify by hand:

e2ln⁡(3)+ln⁡(1). e^{2\ln(3)} + \ln(1).
ShowHide solution

Move the coefficient 2 inside the logarithm as a power, then apply eln⁡(u)=ue^{\ln(u)} = u:

e2ln⁡(3)+ln⁡(1)=eln⁡(32)+0rln⁡(u)=ln⁡(ur),  ln⁡(1)=0=32eln⁡(u)=u=9.\begin{align*} e^{2\ln(3)} + \ln(1) &= e^{\ln(3^{2})} + 0 & &r\ln(u) = \ln(u^{r}),\ \ \ln(1) = 0 \\ &= 3^{2} & &e^{\ln(u)} = u \\ &= 9. & & \end{align*}

Example 3

Solve for xx by hand:

5=2e3x. 5 = 2e^{3x}.
ShowHide solution

Isolate the exponential, then take ln⁡\ln of both sides:

e3x=52divide by 2 to isolate the exponential3x=ln⁡ ⁣(52)apply ln⁡, ln⁡(er)=rx=13ln⁡ ⁣(52).divide by 3\begin{align*} e^{3x} &= \tfrac{5}{2} & &\text{divide by } 2 \text{ to isolate the exponential} \\ 3x &= \ln\!\left(\tfrac{5}{2}\right) & &\text{apply } \ln,\ \ln(e^{r}) = r \\ x &= \tfrac{1}{3}\ln\!\left(\tfrac{5}{2}\right). & &\text{divide by } 3 \end{align*}

In R, log(5/2)/3 prints [1] 0.3054302, which gives x≈0.305x \approx 0.305.

Example 4

Solve for xx by hand:

ln⁡(x+3)−ln⁡(x)=1. \ln(x + 3) - \ln(x) = 1.
ShowHide solution

Combine the logarithms into one, then exponentiate both sides and solve for xx:

ln⁡ ⁣(x+3x)=1ln⁡(u)−ln⁡(w)=ln⁡ ⁣(uw)x+3x=eapply e(⋅), eln⁡(u)=ux+3=exmultiply by x3=(e−1)xcollect the x termsx=3e−1.divide by e−1\begin{align*} \ln\!\left(\frac{x+3}{x}\right) &= 1 & &\ln(u) - \ln(w) = \ln\!\left(\tfrac{u}{w}\right) \\ \frac{x+3}{x} &= e & &\text{apply } e^{(\cdot)},\ e^{\ln(u)} = u \\ x + 3 &= ex & &\text{multiply by } x \\ 3 &= (e - 1)x & &\text{collect the } x \text{ terms} \\ x &= \frac{3}{e - 1}. & &\text{divide by } e - 1 \end{align*}

In R, 3/(exp(1) - 1) prints [1] 1.74593, which gives x≈1.746x \approx 1.746. Both logarithms in the original equation are defined there, because xx and x+3x + 3 are positive.

Example 5

Solve for xx in terms of yy by hand:

y=ln⁡ ⁣(7e4x). y = \ln\!\left(\frac{7}{e^{4x}}\right).
ShowHide solution

Split the logarithm of the quotient, then solve the linear equation for xx:

y=ln⁡(7)−ln⁡ ⁣(e4x)ln⁡ ⁣(uw)=ln⁡(u)−ln⁡(w)y=ln⁡(7)−4xln⁡(er)=r4x=ln⁡(7)−ymove 4x and y acrossx=14(ln⁡(7)−y).divide by 4\begin{align*} y &= \ln(7) - \ln\!\left(e^{4x}\right) & &\ln\!\left(\tfrac{u}{w}\right) = \ln(u) - \ln(w) \\ y &= \ln(7) - 4x & &\ln(e^{r}) = r \\ 4x &= \ln(7) - y & &\text{move } 4x \text{ and } y \text{ across} \\ x &= \tfrac{1}{4}\left(\ln(7) - y\right). & &\text{divide by } 4 \end{align*}

Next: 2. The Parameters CC and kkLesson map

2. The Parameters CC and kk

Objective. Interpret the parameters CC and kk of an exponential function, and describe how the function changes as each is adjusted.

Definition 2 (General exponential function).

An exponential function is a function of the form

y=Cek(x−h), y = Ce^{k(x-h)},

where CC, kk, and hh are constants with C≠0C \neq 0 and k≠0k \neq 0, and e=2.71828…e = 2.71828\ldots. Its parameters are CC, the output at x=hx = h; the steepness kk; and the horizontal shift hh. With h=0h = 0 the form is y=Cekxy = Ce^{kx}.

The function y=5e3y = 5e^{3} is not an exponential function, because its exponent has no xx. Written as 5e3e0x5e^{3}e^{0x}, it has k=0k = 0, which the definition excludes. Its graph is the horizontal line y=5e3≈100.428y = 5e^{3} \approx 100.428.

Every exponential model on this sheet has the form y=Cekxy = Ce^{kx}, with h=0h = 0.

Because ek(x+Δx)=ekΔxekxe^{k(x + \Delta x)} = e^{k\Delta x}e^{kx}, the output of y=Cekxy = Ce^{kx} is multiplied by the same factor ekΔxe^{k\Delta x} over every input step of width Δx\Delta x.

A function is concave up on an interval if, for every two points on its graph over that interval, the straight segment joining them lies above the graph between those points.

A function is concave down on an interval if, for every two points on its graph over that interval, the straight segment joining them lies below the graph between those points.

A line is neither concave up nor concave down, because the segment joining two of its points lies along the line.

A horizontal asymptote is a horizontal line y=Ly = L that the outputs of a function approach as xx increases without bound or as xx decreases without bound.

The graph of y=Cekxy = Ce^{kx} has the horizontal asymptote y=0y = 0. When k>0k > 0, the outputs approach 0 as xx decreases without bound and grow in size without bound as xx increases. When k<0k < 0, the outputs approach 0 as xx increases without bound and grow in size without bound as xx decreases.

ParameterRoleEffect of the sign
CCthe output at x=hx = h. When h=0h = 0, the constant CC is the vertical interceptC>0C > 0: above the axis, concave up
C<0C < 0: below the axis, concave down
kkthe steepness of the curve: the larger ∣k∣|k| is, the less xx has to change to double or halve the outputk>0k > 0: ∣y∣|y| grows as xx increases
k<0k < 0: ∣y∣|y| shrinks as xx increases
hhthe horizontal shifth>0h > 0: shifts the curve right
h<0h < 0: shifts the curve left

Every exponential function is monotonic (Lesson 3 sheet, section 4). The signs of CC and kk together decide whether the function increases or decreases, and the sign of CC decides whether the function is concave up or concave down.

Each graph below marks the output CC at x=0x = 0, with xx in hours or months.

Positive CC and positive kk

Figure

The function y=3e0.4xy = 3e^{0.4x} is increasing and concave up. A colony of bacteria that starts at 3 thousand and follows this model gains more bacteria in each later hour.

Positive CC and negative kk

Figure

The function y=3e−0.4xy = 3e^{-0.4x} is decreasing and concave up. A 3-milligram dose of a drug that follows this model loses less of the drug in each later hour, approaching y=0y = 0.

Negative CC and positive kk

Figure

The function y=−3e0.4xy = -3e^{0.4x} is decreasing and concave down. A debt recorded as a balance of −3-3 thousand dollars that follows this model falls by more in each later month.

Negative CC and negative kk

Figure

The function y=−3e−0.4xy = -3e^{-0.4x} is increasing and concave down. A cold can is 3 degrees Celsius below room temperature. Its temperature minus the room’s follows this model and rises by less in each later hour, approaching y=0y = 0.

Example 6

Plot the function below for −0.5≤x≤4-0.5 \le x \le 4, then state CC and kk and interpret each:

f(x)=2e−3x. f(x) = 2e^{-3x}.

Then add the function g(x)=2e−5xg(x) = 2e^{-5x} to the same axes and describe what changed.

ShowHide solution

Define and plot ff, then define gg and add it in red:

f = makeFun(2*exp(-3*x) ~ x)
plotFun(f(x) ~ x, xlim = range(-0.5, 4))
mathaxis.on()
g = makeFun(2*exp(-5*x) ~ x)
plotFun(g(x) ~ x, add = TRUE, col = "red")

Match ff to the definition of an exponential function, y=Cek(x−h)y = Ce^{k(x-h)} with h=0h = 0. The output at x=0x = 0 is CC, and f(0)=2e0=2f(0) = 2e^{0} = 2. The blue curve crosses the vertical axis at that height. The steepness is the coefficient of xx in the exponent, k=−3k = -3. Because k<0k < 0, the output shrinks toward the horizontal asymptote y=0y = 0 as xx increases. With C>0C > 0 and k<0k < 0, the function ff is decreasing and concave up.

The red curve gg also has output 2 at x=0x = 0. The curve gg decreases toward y=0y = 0 faster than ff, because the size of its steepness, ∣−5∣=5|-5| = 5, exceeds ∣−3∣=3|-3| = 3. The red curve lies below ff for every xx with x>0x > 0.

Figure

Example 7

A model gives the amount of a drug in the bloodstream, in milligrams, tt hours after a 200-milligram dose:

A(t)=200e−0.3t. A(t) = 200e^{-0.3t}.

A 400-milligram dose follows B(t)=400e−0.3tB(t) = 400e^{-0.3t}. State CC and kk for each model, and describe how doubling the dose changes the function.

ShowHide solution

Match each model to y=Cekxy = Ce^{kx} as in Example 6. The model AA has C=200C = 200 and k=−0.3k = -0.3, and the model BB has C=400C = 400 and k=−0.3k = -0.3. Factor 2 out of BB to compare the outputs:

B(t)=400e−0.3t=2⋅200e−0.3t=2A(t). B(t) = 400e^{-0.3t} = 2 \cdot 200e^{-0.3t} = 2A(t).

Doubling CC doubles every output, and the green curve BB is the blue curve AA stretched vertically by a factor of 2. The black dots mark each curve’s starting value CC. The steepness k=−0.3k = -0.3 is unchanged, and both models are decreasing and concave up.

Figure

Over each hour, both outputs are multiplied by the same factor e−0.3e^{-0.3}. In R, exp(-0.3) prints [1] 0.7408182. Each model keeps about 0.741 of its drug from one hour to the next.

The constant ee in plotFun(). A bare e in a plotFun() formula is a free parameter with no value, and plotFun() stops with an error:

> plotFun(2*e^(-3*x) ~ x, xlim = range(-0.5, 4))
Error in plotFun(2 * e^(-3 * x) ~ x, xlim = range(-0.5, 4)) :
  Cannot plot with free parameters; try setting e

Replace 2*e^(-3*x) with 2*exp(-3*x) to clear the error. The Lesson 3 sheet, section 3, shows the same mistake inside makeFun().

Next: 3. Doubling and Halving TimesLesson map

3. Doubling and Halving Times

Objective. Given kk, calculate the doubling/halving rate of an exponential process (and vice-versa).

Growth, k>0k > 0

Figure

Over each input step of width Δx\Delta x, the doubling time, the output doubles. A population of CC cells reaches 2C2C after one doubling time and 4C4C after two.

Decay, k<0k < 0

Figure

Over each input step of width Δx\Delta x, the halving time, the output halves. A dose of CC milligrams of a drug falls to 12C\tfrac{1}{2}C after one halving time and 14C\tfrac{1}{4}C after two.

For k>0k > 0, set the output of y=Cekxy = Ce^{kx} at x+Δxx + \Delta x equal to twice the output at xx, and solve for the input step Δx\Delta x:

Cek(x+Δx)=2 CekxekΔx=2divide by CekxkΔx=ln⁡(2)apply ln⁡, ln⁡(er)=rΔx=ln⁡(2)k.divide by k\begin{align*} Ce^{k(x + \Delta x)} &= 2\,Ce^{kx} \\ e^{k \Delta x} &= 2 & &\text{divide by } Ce^{kx} \\ k \Delta x &= \ln(2) & &\text{apply } \ln,\ \ln(e^{r}) = r \\ \Delta x &= \frac{\ln(2)}{k}. & &\text{divide by } k \end{align*}

For k<0k < 0, the same steps with 12\tfrac{1}{2} in place of 2 give the step over which the output halves:

ekΔx=12divide by CekxkΔx=ln⁡ ⁣(12)=−ln⁡(2)apply ln⁡, ln⁡ ⁣(1w)=−ln⁡(w)Δx=−ln⁡(2)k=ln⁡(2)∣k∣.divide by k; −k=∣k∣ for k<0\begin{align*} e^{k \Delta x} &= \tfrac{1}{2} & &\text{divide by } Ce^{kx} \\ k \Delta x &= \ln\!\left(\tfrac{1}{2}\right) = -\ln(2) & &\text{apply } \ln,\ \ln\!\left(\tfrac{1}{w}\right) = -\ln(w) \\ \Delta x &= \frac{-\ln(2)}{k} = \frac{\ln(2)}{|k|}. & &\text{divide by } k;\ -k = |k| \text{ for } k < 0 \end{align*}

Neither step width depends on xx, the input where the step starts.

Definition 3 (Doubling time and halving time).

For y=Cekxy = Ce^{kx} with k>0k > 0, the doubling time is the width Δx=x2−x1\Delta x = x_2 - x_1 of an input interval with x2>x1x_2 > x_1 and y(x2)=2y(x1)y(x_2) = 2y(x_1); with k<0k < 0 and y(x2)=12y(x1)y(x_2) = \frac{1}{2}y(x_1), the width is the halving time. In science contexts the halving time is called the half-life.

The two derivations above give the formulas

doubling time=ln⁡(2)k,halving time=ln⁡(2)∣k∣. \text{doubling time} = \frac{\ln(2)}{k}, \qquad\qquad \text{halving time} = \frac{\ln(2)}{|k|}.

Solving each formula for kk gives kk from the doubling or halving time:

k=ln⁡(2)doubling time,k=−ln⁡(2)halving time. k = \frac{\ln(2)}{\text{doubling time}}, \qquad\qquad k = \frac{-\ln(2)}{\text{halving time}}.

The function y=5e−0.1xy = 5e^{-0.1x} has no doubling time, because its steepness k=−0.1k = -0.1 is negative and the definition requires k>0k > 0. Its outputs only shrink, and it has a halving time instead. In the same way, the function y=5e0.1xy = 5e^{0.1x} has no halving time, because its steepness k=0.1k = 0.1 is positive and the definition requires k<0k < 0 for a halving time.

Proposition 4 (Independence from the starting output).

For k>0k > 0, the doubling time of y=Cekxy = Ce^{kx} is the same from every starting output. For k<0k < 0, the halving time is the same from every starting output.

For a single model with C>0C > 0, growing from 40 to 80 takes the same input step as growing from 4000 to 8000. Quadrupling takes two doubling times, because 4=2⋅24 = 2 \cdot 2.

Example 8

An algae population follows the model below, with tt in days:

p(t)=40 e0.23t. p(t) = 40\,e^{0.23t}.

Find the doubling time, then find how many days the population takes to grow from 80 to 320.

ShowHide solution

The model has a doubling time, because its steepness k=0.23k = 0.23 is positive, as the definition of doubling time requires. Divide ln⁡(2)\ln(2) by the steepness:

doubling time=ln⁡(2)k=ln⁡(2)0.23. \text{doubling time} = \frac{\ln(2)}{k} = \frac{\ln(2)}{0.23}.

In R, log(2)/0.23 prints [1] 3.013683. The doubling time is about 3.0143.014 days. Growing from 80 to 320 multiplies the population by 320/80=4=22320/80 = 4 = 2^{2}. Two doublings take two doubling times:

time from 80 to 320=2⋅doubling time=2⋅ln⁡(2)0.23. \text{time from 80 to 320} = 2 \cdot \text{doubling time} = 2 \cdot \frac{\ln(2)}{0.23}.

In R, 2*log(2)/0.23 prints [1] 6.027367. The population takes about 6.0276.027 days to grow from 80 to 320.

Example 9

Carbon-14 decays with a half-life of 5730 years. Find kk for the model below, with xx in years:

f(x)=Cekx. f(x) = Ce^{kx}.
ShowHide solution

The steepness of a decaying model is −ln⁡(2)-\ln(2) divided by the halving time:

k=−ln⁡(2)halving time=−ln⁡(2)5730. k = \frac{-\ln(2)}{\text{halving time}} = \frac{-\ln(2)}{5730}.

In R, -log(2)/5730 prints [1] -0.0001209681. The steepness is k≈−0.000121k \approx -0.000121 per year.

Example 10

A koala population starts at 150 and doubles every 75 days. Write the model p(t)=Cektp(t) = Ce^{kt}, with tt in days.

ShowHide solution

The output at t=0t = 0 is C=150C = 150. Substitute the doubling time 75 into k=ln⁡(2)/doubling timek = \ln(2)/\text{doubling time}, the doubling-time formula solved for kk:

k=ln⁡(2)75. k = \frac{\ln(2)}{75}.

In R, log(2)/75 prints [1] 0.009241962. The model is

p(t)=150 e(ln⁡(2)/75) t, p(t) = 150\,e^{(\ln(2)/75)\,t},

with k≈0.009k \approx 0.009 per day.

Example 11

The function

f(x)=31.486 e−0.048x f(x) = 31.486\,e^{-0.048x}

models the price of coal, in dollars per short ton, with xx counting years since 1989. The model was built on data from 1989 to 2011.

  • (a) Report CC and the halving time, and explain each in context.
  • (b) Predict the price of coal in 2021, and decide whether to trust the prediction.
ShowHide solution

(a) The output at x=0x = 0 is C=31.486C = 31.486. According to the model, a short ton of coal cost $31.486 in 1989. With k=−0.048k = -0.048,

halving time=ln⁡(2)∣k∣=ln⁡(2)0.048. \text{halving time} = \frac{\ln(2)}{|k|} = \frac{\ln(2)}{0.048}.

In R, log(2)/0.048 prints [1] 14.44057. In the model, the price of a short ton of coal falls by half about every 14.44114.441 years.

(b) The input for 2021 is

x=2021−1989=32. x = 2021 - 1989 = 32.

Define the model and evaluate it at 32:

coal = makeFun(31.486*exp(-0.048*x) ~ x)
coal(32)

The last line prints [1] 6.777057: the model predicts $6.777 per short ton in 2021. The prediction is an extrapolation and deserves little trust, because 2021 lies outside the years 1989 to 2011 on which the model was built. The call coal(2021) uses the calendar year in place of years since 1989 and prints [1] 2.333879e-41, a price of zero to forty decimal places.

Next: 4. Semi-Log Form of an ExponentialLesson map

4. Semi-Log Form of an Exponential

Objective. Use log rules to show an exponential function becomes ln⁡(y)=mx+b\ln(y) = mx + b in semi-log form, where k=mk = m and C=ebC = e^{b}.

Figure

The left graph shows an exponential function with C>0C > 0, and the right graph is its semi-log plot. Each point (x0,y0)(x_0, y_0) on the curve moves to (x0,ln⁡(y0))(x_0, \ln(y_0)), at the same input. The curve becomes a line with slope m=km = k and vertical intercept b=ln⁡(C)b = \ln(C), as the derivation below shows.

Definition 5 (Semi-log plot).

If (x0,y0)(x_0, y_0) is a point from a given data set or curve with y0>0y_0 > 0, then its semi-log plot includes the point (x0,ln⁡(y0))(x_0, \ln(y_0)).

The data point (3,0)(3, 0) does not appear on a semi-log plot, because ln⁡(0)\ln(0) is undefined. The definition requires y0>0y_0 > 0.

Definition 6 (Semi-log form).

For an exponential function y=Cekxy = Ce^{kx} with C>0C > 0, the semi-log form is the equation ln⁡(y)=mx+b\ln(y) = mx + b with m=km = k and b=ln⁡(C)b = \ln(C). It gives ln⁡(y)\ln(y) as a linear function of xx.

The function y=−2e0.5xy = -2e^{0.5x} has no semi-log form, because C=−2C = -2 makes every output negative, and ln⁡(y)\ln(y) is undefined for a negative yy.

For y=Cekxy = Ce^{kx} with C>0C > 0, taking ln⁡\ln of both sides gives a linear function of xx:

ln⁡(y)=ln⁡ ⁣(Cekx)apply ln⁡ to both sides=ln⁡(C)+ln⁡ ⁣(ekx)ln⁡(uw)=ln⁡(u)+ln⁡(w)=kx+ln⁡(C).ln⁡(er)=r\begin{align*} \ln(y) &= \ln\!\left(Ce^{kx}\right) & &\text{apply } \ln \text{ to both sides} \\ &= \ln(C) + \ln\!\left(e^{kx}\right) & &\ln(uw) = \ln(u) + \ln(w) \\ &= kx + \ln(C). & &\ln(e^{r}) = r \end{align*}

Comparing ln⁡(y)=kx+ln⁡(C)\ln(y) = kx + \ln(C) with ln⁡(y)=mx+b\ln(y) = mx + b shows that ln⁡(y)\ln(y) is a linear function of xx, with slope m=km = k and vertical intercept b=ln⁡(C)b = \ln(C). Conversely, a semi-log line ln⁡(y)=mx+b\ln(y) = mx + b determines the parameters of the exponential function:

k=m,C=eb. k = m, \qquad\qquad C = e^{b}.

Example 12

Use log rules to write the semi-log form of the function below, and state its slope and vertical intercept:

f(x)=31.486 e−0.048x. f(x) = 31.486\,e^{-0.048x}.
ShowHide solution

The function has a semi-log form by the definition, because C=31.486C = 31.486 is positive. Take ln⁡\ln of both sides and split the logarithm of the product:

ln⁡ ⁣(f(x))=ln⁡ ⁣(31.486 e−0.048x)=ln⁡(31.486)+ln⁡ ⁣(e−0.048x)ln⁡(uw)=ln⁡(u)+ln⁡(w)=−0.048x+ln⁡(31.486).ln⁡(er)=r\begin{align*} \ln\!\left(f(x)\right) &= \ln\!\left(31.486\,e^{-0.048x}\right) \\ &= \ln(31.486) + \ln\!\left(e^{-0.048x}\right) & &\ln(uw) = \ln(u) + \ln(w) \\ &= -0.048x + \ln(31.486). & &\ln(e^{r}) = r \end{align*}

The semi-log form has slope

m=k=−0.048. m = k = -0.048.

In R, log(31.486) prints [1] 3.449543. The vertical intercept is

b=ln⁡(31.486)≈3.450. b = \ln(31.486) \approx 3.450.

Example 13

The semi-log plot of a data set lies on the line below. Find kk and CC, and write the exponential model:

ln⁡(y)=0.2x+1.5. \ln(y) = 0.2x + 1.5.
ShowHide solution

The slope and the vertical intercept give

k=m=0.2,C=eb=e1.5. k = m = 0.2, \qquad\qquad C = e^{b} = e^{1.5}.

In R, exp(1.5) prints [1] 4.481689. The exponential model is

y=e1.5e0.2x, y = e^{1.5}e^{0.2x},

with C≈4.482C \approx 4.482 and k=0.2k = 0.2.

Next: 5. Semi-Log Plots in RLesson map

5. Semi-Log Plots in R

Objective. Given a function or dataset, use plotPoints() to obtain a semi-log plot.

For a semi-log plot in R, wrap the output in log() and leave the input as it is:

plotPoints(log(Output) ~ Input, data = DataSet)

The data = argument gives the stored data set (Lesson 2 sheet, section 6). Data typed in as vectors with c() need no data = argument.

For a function f with every output positive, the semi-log plot is plotFun(log(f(x)) ~ x).

Example 14

The data set Transistors records the number of transistors in an integrated circuit from 1971 to 2021 in the variables Year and Transistors. Make the standard plot and the semi-log plot of Transistors against Year in R.

ShowHide solution

Plot Transistors against Year, then plot its natural logarithm against Year for the semi-log plot:

plotPoints(Transistors ~ Year, data = Transistors)
plotPoints(log(Transistors) ~ Year, data = Transistors)

By the definition of a semi-log plot, each row (Year,Transistors)(\text{Year}, \text{Transistors}) becomes the point (Year,ln⁡(Transistors))(\text{Year}, \ln(\text{Transistors})). The 1971 row records 2308.2417 transistors and plots at height ln⁡(2308.2417)≈7.744\ln(2308.2417) \approx 7.744. The 2021 row records 58.2 billion and plots at height ln⁡(58,200,000,000)≈24.787\ln(58{,}200{,}000{,}000) \approx 24.787. Both are the filled points below. R labels the vertical axis log(Transistors), its spelling of ln⁡(Transistors)\ln(\text{Transistors}).

Figure

Standard plot: near zero until about 2010, then a sharp rise.

Figure

Semi-log plot: close to one rising line.

An exponential model is reasonable for the transistor counts, because the semi-log points lie close to one rising line, the pattern section 4 derives for an exponential function.

Example 15

The table gives air pressure, in inches of mercury, at altitudes in thousands of feet.

Altitude051015202530
Pressure29.9224.9020.5816.8913.7511.108.89

Make the semi-log plot in R. Then estimate kk from the slope between the first and last semi-log points, and find the halving time: the altitude gain over which the pressure halves.

ShowHide solution

The semi-log plot tests whether an exponential model is reasonable, the slope of the semi-log line estimates kk, and kk gives the halving time, here measured in thousands of feet. Store the data, make the semi-log plot, and compute the slope and the halving time:

Altitude = c(0, 5, 10, 15, 20, 25, 30)
Pressure = c(29.92, 24.90, 20.58, 16.89, 13.75, 11.10, 8.89)
plotPoints(log(Pressure) ~ Altitude)
m = (log(8.89) - log(29.92))/(30 - 0)
m
log(2)/abs(m)

The semi-log points lie close to a falling line. The first and last of them are (0,ln⁡(29.92))≈(0,3.399)(0, \ln(29.92)) \approx (0, 3.399) and (30,ln⁡(8.89))≈(30,2.185)(30, \ln(8.89)) \approx (30, 2.185), the filled points in the figure. The R line for m substitutes them into the slope formula,

m=ln⁡(8.89)−ln⁡(29.92)30−0, m = \frac{\ln(8.89) - \ln(29.92)}{30 - 0},

the slope of the dashed line. The last R line computes the halving time ln⁡(2)/∣k∣\ln(2)/|k| with mm in place of kk.

Figure

The last two lines print [1] -0.04045334 and [1] 17.13449. The two-point slope estimates the steepness, k≈−0.040k \approx -0.040 per thousand feet, and the pressure halves about every 17.134 thousand feet of climb.

Example 16

Plot the function below and its semi-log plot in R for 0≤x≤40 \le x \le 4. Then find kk and CC from the semi-log line:

f(x)=3e2x. f(x) = 3e^{2x}.
ShowHide solution

Define and plot ff, then plot ln⁡(f(x))\ln(f(x)) on the same interval:

f = makeFun(3*exp(2*x) ~ x)
plotFun(f(x) ~ x, xlim = range(0, 4))
plotFun(log(f(x)) ~ x, xlim = range(0, 4))

By the semi-log form, ln⁡(f(x))=ln⁡(3)+ln⁡ ⁣(e2x)=ln⁡(3)+2x\ln(f(x)) = \ln(3) + \ln\!\left(e^{2x}\right) = \ln(3) + 2x. The semi-log plot is the line with that equation, of slope 2 through (0,ln⁡(3))(0, \ln(3)). On R’s second plot the line starts at height ln⁡(3)≈1.099\ln(3) \approx 1.099 and climbs 2 for each unit of xx. The conversion gives

k=m=2,C=eln⁡(3)=3. k = m = 2, \qquad\qquad C = e^{\ln(3)} = 3.

Both values match f(x)=3e2xf(x) = 3e^{2x}.

Next: 6. Logarithmic Functions in RLesson map

6. Logarithmic Functions in R

Objective. In R, use makeFun() and plotFun() to define and plot logarithmic functions.

Definition 7 (General logarithmic function).

A general logarithmic function is a function of the form y=Cln⁡(x−h)+vy = C\ln(x - h) + v, where CC, hh, and vv are constants with C≠0C \neq 0, and its domain is (h,∞)(h, \infty).

The function y=(ln⁡(x))2y = (\ln(x))^{2} is not a general logarithmic function, because its logarithm is squared. In the definition, the logarithm is multiplied by a constant CC and shifted by a constant vv.

The domain is (h,∞)(h, \infty) because ln⁡(x−h)\ln(x - h) is defined only when x−h>0x - h > 0, that is, when x>hx > h.

A vertical asymptote is a vertical line x=ax = a such that the outputs of a function grow in size without bound as xx approaches aa. The graph of y=Cln⁡(x−h)+vy = C\ln(x - h) + v has the vertical asymptote x=hx = h, approached from the right.

Each parameter of y=Cln⁡(x−h)+vy = C\ln(x - h) + v moves or stretches the graph of y=ln⁡(x)y = \ln(x):

ParameterEffect on the graph of y=ln⁡(x)y = \ln(x)In Example 18
hhmoves it right by hh when h>0h > 0 and left by ∣h∣|h| when h<0h < 0y=ln⁡(x−2)y = \ln(x - 2): right 2
vvmoves it up by vv when v>0v > 0 and down by ∣v∣|v| when v<0v < 0y=ln⁡(x)+2y = \ln(x) + 2: up 2
CCstretches it vertically by a factor of ∣C∣|C|, and reflects it across the horizontal axis when C<0C < 0y=3ln⁡(x)y = 3\ln(x): stretched by 3

Every curve y=Cln⁡(x−h)+vy = C\ln(x - h) + v passes through the point (h+1,v)(h + 1, v), because ln⁡(1)=0\ln(1) = 0.

The ylim window. Set ylim on every plot of a general logarithmic function. Without it, R scales the window to the outputs near the asymptote and squeezes the rest of the curve flat.

Example 17

State the domain, the vertical asymptote, and the output at x=4x = 4 for the function below, then plot it in R:

y=2ln⁡(x−3)+1. y = 2\ln(x - 3) + 1.
ShowHide solution

Matching the definition of a general logarithmic function, Cln⁡(x−h)+vC\ln(x - h) + v, gives C=2C = 2, h=3h = 3, and v=1v = 1. The domain is (3,∞)(3, \infty), because the argument x−3x - 3 must be positive, and the vertical asymptote is the line x=h=3x = h = 3. At x=4x = 4 the output is

y=2ln⁡(4−3)+1=2ln⁡(1)+1=1, y = 2\ln(4 - 3) + 1 = 2\ln(1) + 1 = 1,

the point (h+1,v)=(4,1)(h + 1, v) = (4, 1) that every such curve passes through. Plot it in a window that shows the asymptote:

f = makeFun(2*log(x - 3) + 1 ~ x)
plotFun(f(x) ~ x, xlim = range(0, 20), ylim = range(-8, 8))

Figure

Example 18

Plot y=ln⁡(x)y = \ln(x) on the window 0≤x≤100 \le x \le 10 and −8≤y≤8-8 \le y \le 8, then add each function below to the same axes in its own color:

y=ln⁡(x−2),y=3ln⁡(x),y=ln⁡(x)+2,y=3ln⁡(x−2)+2. y = \ln(x - 2), \qquad y = 3\ln(x), \qquad y = \ln(x) + 2, \qquad y = 3\ln(x - 2) + 2.
ShowHide solution

Plot ln⁡(x)\ln(x) on the window, then add each function with add = TRUE and its own color:

=1.2em f1 = makeFun(log(x) ~ x)
plotFun(f1(x) ~ x, xlim = range(0, 10),
ylim = range(-8, 8))
mathaxis.on()
f2 = makeFun(log(x - 2) ~ x)
plotFun(f2(x) ~ x, add = TRUE,
col = "blueviolet")
f3 = makeFun(3*log(x) ~ x)
plotFun(f3(x) ~ x, add = TRUE, col = "brown4")
f4 = makeFun(log(x) + 2 ~ x)
plotFun(f4(x) ~ x, add = TRUE,
col = "darkgoldenrod4")
f5 = makeFun(3*log(x - 2) + 2 ~ x)
plotFun(f5(x) ~ x, add = TRUE,
col = "darkseagreen3")

Figure

The black dots mark each curve’s point (h+1,v)(h + 1, v): (1,0)(1, 0) for ln⁡(x)\ln(x) and 3ln⁡(x)3\ln(x), (3,0)(3, 0) for ln⁡(x−2)\ln(x - 2), (1,2)(1, 2) for ln⁡(x)+2\ln(x) + 2, and (3,2)(3, 2) for 3ln⁡(x−2)+23\ln(x - 2) + 2. The shift h=2h = 2 moves the point right 2, and v=2v = 2 moves it up 2.

Lesson map