# Logarithmic Functions

##### 489 words — categories: calculus

If we wanted to solve the equation

\[10^y = 1000\]

we would be trying to find the power of 10 that will give 1000. Since \(10^3 = 1000\), the answer is 3, hence the number 3 is called the logarithm, base 10, of 1000.

A **logarithm** is defined as

\[\log_{a} x = y \rightarrow a^y = x\] for \(a > 0\) and \(a \neq 1\). The number \(log_ax\) is the power \(y\) to which we raise \(a\) to get \(x\). We can think of a logarithm as an exponent, so to graph a logarithmic equation, we can graph its equivalent exponential equation. Logarithmic and exponential functions are inverse of each other.

Let’s graph \(y = \log_{2} x\) and \(y = \log_{10} x\).

```
from sympy import *
import numpy as np
import matplotlib.pyplot as plt
def f(x):
return np.log2(x)
def g(x):
return np.log10(x)
x = np.linspace(1, 8)
plt.plot(x, f(x), label="$f(x) = \log_{2} x$")
plt.plot(x, g(x), label="$g(x) = \log_{10} x$")
plt.legend(frameon=False)
```

The common logarithms are \(\log_{10} x\) and the **natural logarithm** \(\ln x = \log_{e} x\).

Let’s calculate the natural logarithms \(\ln 2\), and \(\ln 3\).

```
def h(x):
return np.log(x)
h(2)
```

`## 0.6931471805599453`

`h(3)`

`## 1.0986122886681098`

If an equation contains a variable in an exponent, the equation is **exponential**. We can use logarithms to manipulate or solve exponential equations.

Let’s say we have an equation like \(e^t = 40\) and we want to solve for \(t\).

```
from mpmath import ln, e
t = symbols("t")
equation = Eq(e**t, 40)
equation
```

`## Eq(2.71828182845905**t, 40)`

`solve(equation, t)`

`## [3.68887945411393]`

As with other logarithmic functions, we can graph the natural logarithmic function or its equivalent exponential function.

```
def f(x):
return x
def g(x):
return np.log(x)
def h(x):
return e**x
x = np.linspace(0, 2)
plt.plot(x, f(x), "--", label="$y = x$")
plt.plot(x, h(x), label="$h(x) = e^x$")
plt.plot(x, g(x), label="$g(x) = \ln x$")
plt.legend(frameon=False)
```

The derivative of the natural logarithmic function is

```
x = symbols("x")
diff(log(x))
```

`## 1/x`

For any positive number

\[\frac{d}{dx} \ln x = \frac{1}{x}\]

Let’s differentiate \(y = 3 \ln x\) and \(y = x^2 \ln x + 5x\).

`diff(3 * log(x))`

`## 3/x`

`diff(x**2 * log(x) + 5 * x)`

`## 2*x*log(x) + x + 5`

## Forgetting

The forgetting curve is an interesting application of logarithmic functions. In a psychological experiment, students were shown a set of nonsense syllables, such as POK, RIZ, DEQ, and so on, and asked to recall them every minute thereafter. The percentage \(R(t)\) who retained the syllables after \(t\) minutes was found to be given by the logarithmic learning model

\[R(t) = 80 - 27 \ln t\]

- what percentage of students retained the syllables after 1 minute
- find \(R^\prime(2)\), and explain what it represents

```
def R(t):
return 80 - 27 * log(t)
R(1)
```

`## 80`

```
ddt = diff(R(t), t)
ddt
```

`## -27/t`

`ddt.subs({t:2})`

`## -27/2`

The derivative of the retention rate tells us that after 2 minutes, the percentage of students who remember the syllables is decreasing by 13.5%.