---
title: Derivatives of logarithms and inverse functions
heading: The slope of ln x is 1/x
eyebrow: A5 · Lesson 16 · Logarithms and inverses
xp: 40
---

::: hook
A diode's voltage is a logarithm of its current, $V = V_T\ln(I/I_s)$. A decibel meter reads a logarithm of power. A phase meter reports an arctangent. To know how sensitive any of these is to a small change, you need the derivative of a logarithm or an inverse trig function. They all follow from one idea: the slope of an inverse function is the reciprocal of the original's slope, at the matching point.
:::

::: play
- The curves are $e^x$ and its inverse $\ln x$, mirror images in the dashed line $y = x$.
- The point on $e^x$ is at $x = a$; its mirror on $\ln x$ is at $x = e^a$. Compare the two slopes in the strip.
- How are they related, and why?
:::
:::

```sim plot
view: graph
x: x = -2..5
y: y = -2..5
slider: a = -1.5..1.5 step 0.05 = 0.5
plot: exp(x) | label: eˣ
plot: ln(x) | color: ch2 | label: ln x
plot: x | dashed | color: ch3
point: a, exp(a)
point: exp(a), a
readout: slope of eˣ at a = exp(a) | digits: 4
readout: slope of ln x at eᵃ = 1/exp(a) | digits: 4
```

::: predict
## The slope of $e^x$ at $x = 1$ is $e \approx 2.718$. What is the slope of $\ln x$ at $x = e$?

- [ ] $e$
- [x] $1/e \approx 0.368$
- [ ] 1
- [ ] 0

::: reveal
$1/e$. Reflecting a graph in $y = x$ swaps rise and run, so the mirror point's slope is the reciprocal. $\ln x$ at $x = e$ mirrors $e^x$ at $x = 1$. In general the slope of $\ln x$ is $1/x$.
:::
:::

::: nameit
## Inverse functions

If $y = f^{-1}(x)$, then $f(y) = x$. Differentiating implicitly, $f'(y)\,y' = 1$, so

$$\frac{d}{dx}f^{-1}(x) = \frac{1}{f'\big(f^{-1}(x)\big)}$$

The slope of the inverse is one over the slope of the original, at the mirrored point.

## Logarithms

With $f = e^x$, $f' = e^x$, and $e^{\ln x} = x$:

$$\frac{d}{dx}\ln x = \frac{1}{x} \qquad \frac{d}{dx}\ln|x| = \frac{1}{x} \qquad \frac{d}{dx}\log_b x = \frac{1}{x\ln b}$$

and with the chain rule, $\frac{d}{dx}\ln g(x) = \frac{g'(x)}{g(x)}$. Other exponentials follow from $b^x = e^{x\ln b}$:

$$\frac{d}{dx}b^x = b^x\ln b$$

## Inverse trig functions

$$\frac{d}{dx}\sin^{-1}x = \frac{1}{\sqrt{1 - x^2}} \qquad \frac{d}{dx}\cos^{-1}x = -\frac{1}{\sqrt{1 - x^2}} \qquad \frac{d}{dx}\tan^{-1}x = \frac{1}{1 + x^2}$$

The arctangent's derivative is how a phase measurement's sensitivity is found: the phase of an RC low-pass is $-\tan^{-1}(\omega RC)$, so it changes fastest, at $-RC$ per rad/s, right at the corner.

## Logarithmic differentiation

For products and powers, take logs first. If $y = x^x$, then $\ln y = x\ln x$, and $\frac{y'}{y} = \ln x + 1$, so $y' = x^x(\ln x + 1)$. The same trick gives relative sensitivities: for $P = V^2/R$, $\ln P = 2\ln V - \ln R$, so $\frac{dP}{P} = 2\frac{dV}{V} - \frac{dR}{R}$, exactly the rule A1 stated for small changes.
:::

::: example
## How sensitive is a diode's voltage to its current at 1 mA, and at 10 mA? Use $V = V_T\ln(I/I_s)$ with $V_T$ = 25.85 mV.

::: solution
1. **Differentiate.**
   $$\frac{dV}{dI} = V_T \cdot \frac{1}{I}$$
2. **At 1 mA.**
   $$\begin{aligned} \frac{dV}{dI} &= \frac{25.85\ \text{mV}}{1\ \text{mA}} \\ &= 25.85\ \Omega \end{aligned}$$
3. **At 10 mA.**
   $$\begin{aligned} \frac{dV}{dI} &= \frac{25.85\ \text{mV}}{10\ \text{mA}} \\ &= 2.585\ \Omega \end{aligned}$$
4. **In relative terms.**
   $$dV = V_T\,\frac{dI}{I}$$
   so a 1% change in current changes the voltage by 0.26 mV, at any current.
5. **Doubling the current.**
   $$\begin{aligned} \Delta V &= V_T\ln 2 \\ &= 17.9\ \text{mV} \end{aligned}$$
   the familiar "18 mV per octave" of a diode.

**Answer:** $dV/dI$ is 25.85 Ω at 1 mA and 2.585 Ω at 10 mA.
:::
:::

::: example
## Differentiate $y = \tan^{-1}(2x)$ and find the slope at $x = 0.5$.

::: solution
1. **Chain rule.**
   $$\begin{aligned} y' &= \frac{1}{1 + (2x)^2} \cdot 2 \\ &= \frac{2}{1 + 4x^2} \end{aligned}$$
2. **Evaluate at $x = 0.5$.**
   $$\begin{aligned} y'(0.5) &= \frac{2}{1 + 1} \\ &= 1 \end{aligned}$$
3. **Check with the inverse rule.** $\tan^{-1}(1) = \pi/4$, and the slope of $\tan(u)/2$ at $u = \pi/4$ is
   $$\tfrac{1}{2}\sec^2(\pi/4) = 1$$
   The reciprocal is 1.

**Answer:** $y' = \dfrac{2}{1 + 4x^2}$, and the slope at $x = 0.5$ is 1.
:::
:::

::: example
## Differentiate $y = x^x$ and find its slope at $x = 2$.

::: solution
1. **Take logs first.** Neither the power rule nor the exponential rule fits, since both the base and the exponent vary:
   $$\ln y = x\ln x$$
2. **Differentiate both sides.**
   $$\frac{y'}{y} = \ln x + 1$$
   so
   $$y' = x^x(\ln x + 1)$$
3. **Evaluate at $x = 2$.**
   $$\begin{aligned} y'(2) &= 4(\ln 2 + 1) \\ &= 4 \times 1.693 \\ &= 6.77 \end{aligned}$$

**Answer:** $y' = x^x(\ln x + 1)$, and the slope at $x = 2$ is 6.77.
:::
:::

::: check
kind: expression
given: a = 2 | 3 | 5; b = 1 | 4
answer: 2*a*x/(a*x^2 + b)
vars: x = 0.5..3

## Differentiate $\ln(\given{a}x^2 + \given{b})$.

::: right
Right. $\frac{g'}{g}$ with $g = \given{a}x^2 + \given{b}$.
:::

::: misses
- [1/(a*x^2 + b)] Multiply by the derivative of the inside, $2 \cdot \given{a}x$.
- [2*a*x] Divide by the inside too: $\frac{d}{dx}\ln g = g'/g$.
- [any] Not yet. $\frac{d}{dx}\ln g(x) = g'(x)/g(x)$.
:::
:::

::: check
given: I = 0.1 | 0.5 | 5 | 20
answer: 25.85/I
unit: Ω

## A diode follows $V = V_T\ln(I/I_s)$ with $V_T$ = 25.85 mV. What is $dV/dI$ at $I$ = {I} mA?

::: right
Right. $V_T/I$ = {answer}.
:::

::: misses
- [25.85*I] The derivative of $\ln I$ is $1/I$: divide by the current.
- [0.02585/I] Put the current in amperes: {I} mA is $\given{I} \times 10^{-3}$ A.
- [any] Not yet. $\frac{d}{dI}V_T\ln(I/I_s) = V_T/I$.
:::
:::

::: check
given: b = 2 | 10; x0 = 2 | 8
answer: 1/(x0*ln(b))
tolerance: 0.5%

## What is the slope of $\log_{\given{b}} x$ at $x$ = {x0}?

::: right
Right. $\frac{1}{x\ln b}$ = {answer}.
:::

::: misses
- [1/x0] That's for $\ln x$. Divide by $\ln \given{b}$ too.
- [ln(b)/x0] $\log_b x = \ln x/\ln b$, so $\ln b$ is on the bottom.
- [any] Not yet. Write $\log_b x = \ln x / \ln b$ and differentiate.
:::
:::

::: check
given: k = 2 | 3; x0 = 0.5 | 1
answer: k/(1 + (k*x0)^2)
tolerance: 0.5%

## What is the slope of $\tan^{-1}(\given{k}x)$ at $x$ = {x0}?

::: right
Right. $\frac{\given{k}}{1 + (\given{k}x)^2}$ = {answer}.
:::

::: misses
- [1/(1 + (k*x0)^2)] Multiply by {k}, the inside's rate.
- [1/(1 + x0^2)] Use the inside, $\given{k}x$, in the formula.
- [any] Not yet. Chain rule with $\frac{d}{du}\tan^{-1}u = \frac{1}{1 + u^2}$.
:::
:::

::: check
given: R = 1 | 10; C = 10 | 100
answer: -R*1e3*C*1e-9/2
unit: s

## An RC low-pass ($R$ = {R} kΩ, $C$ = {C} nF) has phase $\varphi = -\tan^{-1}(\omega RC)$. What is $d\varphi/d\omega$ at the corner, $\omega = 1/(RC)$, in seconds (radians per rad/s)?

::: right
Right. $-\frac{RC}{1 + (\omega RC)^2}$, and at the corner $\omega RC = 1$, so it's $-RC/2$ = {answer} s.
:::

::: misses
- [-R*1e3*C*1e-9] At the corner, the $1 + (\omega RC)^2$ on the bottom is 2.
- [-1/2] Multiply by $RC$, the inside's rate with respect to $\omega$.
- [any] Not yet. Chain rule, then put $\omega RC = 1$.
:::
:::

::: check
kind: parts
given: a = 2 | 5; x0 = 0.5 | 2; b = 3 | 10

## Differentiate these at $x$ = {x0}.

::: part
answer: 1/x0
tolerance: 0.5%

### $\ln(\given{a}x)$

::: misses
- [a/x0] $\ln(ax) = \ln a + \ln x$, and $\ln a$ is a constant.
- [any] The chain rule gives $\frac{a}{ax}$.
:::
:::

::: part
answer: 1/sqrt(b^2 - x0^2)
tolerance: 0.5%

### $\sin^{-1}(x/\given{b})$

::: misses
- [1/sqrt(1 - (x0/b)^2)] Include the chain rule's $1/\given{b}$.
- [any] $\frac{d}{du}\sin^{-1}u = \frac{1}{\sqrt{1 - u^2}}$, with $u = x/b$.
:::
:::

::: part
answer: x0^a*exp(x0)*(a/x0 + 1)
tolerance: 0.5%

### $x^{\given{a}}e^{x}$, by logarithmic differentiation

::: misses
- [a*x0^(a - 1)*exp(x0)] That's only one of the two terms.
- [any] $\ln y = a\ln x + x$, so $y'/y = a/x + 1$.
:::
:::
:::

::: check
kind: derivation
vars: x = -3..3, k = 0.5..3

## Derive the derivative of $\tan^{-1} x$ from $\tan y = x$.

::: step
answer: 1 + x^2

### Differentiating $\tan y = x$ gives $\sec^2 y\cdot y' = 1$. Write $\sec^2 y$ in terms of $x$.
:::

::: step
answer: 1/(1 + x^2)

### Solve for $y'$.
:::

::: step
answer: k/(1 + k^2*x^2)

### With the chain rule, what is the derivative of $\tan^{-1}(kx)$?
:::

::: right
Right. $\frac{d}{dx}\tan^{-1}(kx) = \frac{k}{1 + k^2x^2}$: the slope of every RC filter's phase curve.
:::
:::

::: explain
## Why is the slope of an inverse function the reciprocal of the original function's slope?

::: model
The graph of an inverse function is the original graph reflected in the line $y = x$, which swaps every point's coordinates. Swapping the coordinates also swaps rise and run for any small step along the curve, so a slope of $m$ becomes $1/m$ at the mirrored point. In symbols, differentiating $f(f^{-1}(x)) = x$ gives $f'(f^{-1}(x)) \cdot (f^{-1})'(x) = 1$.
:::
:::

::: practice

::: check
kind: expression
given: k = 2..9 int
answer: 1/x
vars: x = 0.5..4

## Differentiate $\ln(\given{k}x)$.

::: misses
- [k/x] $\ln(\given{k}x) = \ln \given{k} + \ln x$: the constant drops out.
- [any] Chain rule: $\frac{\given{k}}{\given{k}x}$.
:::
:::

::: check
given: b = 2 | 3 | 10; x0 = 1 | 2
answer: b^x0*ln(b)
tolerance: 0.5%

## What is the slope of $\given{b}^x$ at $x$ = {x0}?

::: misses
- [x0*b^(x0 - 1)] The power rule is for $x^n$, not $b^x$.
- [any] $\frac{d}{dx}b^x = b^x\ln b$.
:::
:::

::: check
given: x0 = 0.3 | 0.6 | 0.8
answer: 1/sqrt(1 - x0^2)
tolerance: 0.5%

## What is the slope of $\sin^{-1}x$ at $x$ = {x0}?

::: misses
- [1/sqrt(1 + x0^2)] It's $1/\sqrt{1 - x^2}$.
- [any] $\frac{1}{\sqrt{1 - x^2}}$.
:::
:::
:::
