23. Inverse functions and the inverse trig derivatives
Last lesson differentiated \ln x by writing e^{\ln x} = x and differentiating both sides. That wasn't a trick specific to logarithms — it's the general method for inverses, and it produces the entire inverse-trig table.
The rule
If f is differentiable and one-to-one, and g = f^{-1}, then
g'(x) = \frac{1}{f'(g(x))}
Derivation. By definition f(g(x)) = x. Differentiate both sides, chain rule on the left:
f'(g(x))\cdot g'(x) = 1 \implies g'(x) = \frac{1}{f'(g(x))}
The only requirement is f'(g(x)) \neq 0 — and where it is zero, f has a horizontal tangent, so its inverse has a vertical one and isn't differentiable there. The formula reports that honestly by dividing by zero.
Why the reciprocal
The graph of f^{-1} is the graph of f reflected across y = x (§0.2). Reflection swaps the horizontal and vertical axes, so it swaps rise and run — and a slope of \frac{\text{rise}}{\text{run}} becomes \frac{\text{run}}{\text{rise}}.
That's the whole content: reflecting a graph inverts its slopes.
The point-form is worth stating separately because it's what you actually compute with:
(f^{-1})'(b) = \frac{1}{f'(a)} \quad\text{where } f(a) = b
Find the matching input first, evaluate f' there, reciprocate. You never need a formula for f^{-1} — which is the point, because usually there isn't one.
Example without a formula. Let f(x) = x^5 + 2x + 1. It's strictly increasing (its derivative 5x^4+2 is always positive), so an inverse exists, but solving y = x^5+2x+1 for x is hopeless.
Still: f(1) = 4, so f^{-1}(4) = 1, and
(f^{-1})'(4) = \frac{1}{f'(1)} = \frac{1}{5+2} = \frac17
No formula for the inverse required.
The inverse trig functions
Sine isn't one-to-one, so \arcsin is defined by restricting the domain to \left[-\frac\pi2, \frac\pi2\right], where sine increases from -1 to 1. Similar restrictions define the others. Those choices are conventions, but universal ones.
Deriving \frac{d}{dx}\arcsin x. Let y = \arcsin x, so \sin y = x with y \in \left[-\frac\pi2,\frac\pi2\right]. Differentiate both sides:
\cos y\cdot\frac{dy}{dx} = 1 \implies \frac{dy}{dx} = \frac{1}{\cos y}
Now convert \cos y into something in terms of x. From \sin^2 y + \cos^2 y = 1:
\cos y = \pm\sqrt{1 - \sin^2 y} = \pm\sqrt{1-x^2}
The sign is decided by the domain restriction. On \left[-\frac\pi2,\frac\pi2\right] cosine is non-negative, so take the positive root:
\frac{d}{dx}\arcsin x = \frac{1}{\sqrt{1-x^2}}
That last step is where the restriction earns its keep. Without it the derivative would be ambiguous.
\arctan, the same way. \tan y = x gives \sec^2y\cdot y' = 1, and \sec^2 y = 1 + \tan^2 y = 1+x^2, so
\frac{d}{dx}\arctan x = \frac{1}{1+x^2}
No sign ambiguity at all here, since \sec^2 is never negative. This is the tidiest of the six.
The table
| f(x) | f'(x) | Domain |
|---|---|---|
| \arcsin x | \dfrac{1}{\sqrt{1-x^2}} | (-1,1) |
| \arccos x | -\dfrac{1}{\sqrt{1-x^2}} | (-1,1) |
| \arctan x | \dfrac{1}{1+x^2} | all \mathbb R |
| \operatorname{arccot} x | -\dfrac{1}{1+x^2} | all \mathbb R |
| \operatorname{arcsec} x | \dfrac{1}{\lvert x\rvert\sqrt{x^2-1}} | \lvert x\rvert>1 |
| \operatorname{arccsc} x | -\dfrac{1}{\lvert x\rvert\sqrt{x^2-1}} | \lvert x\rvert>1 |
Two observations that make this memorable:
The "co-" versions are just negatives. That's not a coincidence: \arcsin x + \arccos x = \frac\pi2 identically, so differentiating gives \arcsin' + \arccos' = 0. Same for the other two pairs. Three formulas, not six.
Algebraic derivatives from transcendental functions. \arctan is deeply non-algebraic, and its derivative is \frac{1}{1+x^2}. Read backwards that says
\int\frac{dx}{1+x^2} = \arctan x, \qquad \int\frac{dx}{\sqrt{1-x^2}} = \arcsin x
which is why inverse trig functions appear all over §4 as answers to integrals that contain no trigonometry whatsoever. It's also the source of the classic series \frac\pi4 = 1 - \frac13 + \frac15 - \cdots in §8.3.
With the chain rule
\frac{d}{dx}\arctan(u) = \frac{u'}{1+u^2}, \qquad \frac{d}{dx}\arcsin(u) = \frac{u'}{\sqrt{1-u^2}}
\frac{d}{dx}\arctan(3x) = \frac{3}{1+9x^2}, \qquad \frac{d}{dx}\arcsin(x^2) = \frac{2x}{\sqrt{1-x^4}}
Doing it in Python
The reciprocal rule, without ever forming the inverse:
from math import sqrt
def numerical(f, x, h=1e-6):
return (f(x + h) - f(x - h)) / (2 * h)
f = lambda t: t**5 + 2*t + 1
fp = lambda t: 5*t**4 + 2
# f(1) = 4, so f_inverse(4) = 1
def f_inverse(y, lo=-5.0, hi=5.0):
for _ in range(200):
mid = (lo + hi) / 2
lo, hi = (mid, hi) if f(mid) < y else (lo, mid)
return (lo + hi) / 2
print(f"f(1) = {f(1)}, so f_inverse(4) = {f_inverse(4):.10f}")
print(f"rule (f_inv)'(4) = 1/f'(1) = {1/fp(1):.10f}")
print(f"numeric (f_inv)'(4) = {numerical(f_inverse, 4.0, h=1e-5):.10f}")
The whole inverse-trig table:
from math import asin, acos, atan, sqrt
def numerical(f, x, h=1e-6):
return (f(x + h) - f(x - h)) / (2 * h)
table = [
("arcsin", asin, lambda x: 1 / sqrt(1 - x*x)),
("arccos", acos, lambda x: -1 / sqrt(1 - x*x)),
("arctan", atan, lambda x: 1 / (1 + x*x)),
]
x = 0.4
print(f"{'f':>8} {'rule':>14} {'numerical':>14}")
for name, f, df in table:
print(f"{name:>8} {df(x):>14.8f} {numerical(f, x):>14.8f}")
print(f"\narcsin(x) + arccos(x) = {asin(x) + acos(x):.10f} = pi/2, always")
print("so their derivatives must sum to zero -- which is why one is the other's negative")
The reflection picture, in numbers:
from math import exp, log
print(f"{'x':>6} {'e^x':>10} {'slope of e^x':>14} "
f"{'point on ln':>14} {'slope of ln':>14}")
for x in (-1.0, 0.0, 1.0, 2.0):
y = exp(x)
print(f"{x:>6} {y:>10.5f} {y:>14.5f} {'(' + format(y, '.3f') + ', ' + str(x) + ')':>14} "
f"{1/y:>14.5f}")
print("\nreflecting swaps the axes, so rise/run becomes run/rise: the slopes reciprocate")
Where the rule breaks:
from math import sqrt
# f(x) = x^3 has f'(0) = 0, so its inverse has a vertical tangent at 0
def cbrt(y):
return y ** (1/3) if y >= 0 else -((-y) ** (1/3))
print(f"{'y':>12} {'slope of cbrt':>16} {'1/(3 x^2) at x=cbrt(y)':>26}")
for y in (1.0, 1e-2, 1e-4, 1e-6):
x = cbrt(y)
print(f"{y:>12.0e} {(cbrt(y + 1e-9) - cbrt(y - 1e-9)) / 2e-9:>16.2f} "
f"{1 / (3 * x**2):>26.2f}")
print("\nf'(0) = 0 means the inverse's slope blows up -- a vertical tangent (2.1)")
Worked example
Differentiate y = \arctan\!\left(\sqrt{x}\right), and find the slope at x = 1.
Chain rule with u = \sqrt x:
\frac{dy}{dx} = \frac{1}{1+u^2}\cdot u' = \frac{1}{1+(\sqrt x)^2}\cdot\frac{1}{2\sqrt x} = \frac{1}{2\sqrt x\,(1+x)}
At x = 1: \frac{1}{2\cdot1\cdot2} = \frac14.
Sanity checks. As x \to 0^+ the slope blows up — and it should, since \sqrt x has a vertical tangent at 0 and composing preserves that. As x \to \infty the slope \to 0, matching \arctan flattening toward \frac\pi2.
A second one, showing where the domain bites. Differentiate y = \arcsin(2x):
\frac{dy}{dx} = \frac{2}{\sqrt{1-4x^2}}
The original function needs |2x| \le 1, i.e. |x| \le \frac12; the derivative needs the strict version |x| < \frac12. At exactly x = \pm\frac12 the function is defined but has a vertical tangent. Inverse functions inherit their domain restrictions, and the derivative's domain is usually one notch smaller than the function's.
Your turn
1. f(x) = x^3 + x + 1. Find (f^{-1})'(3).
2. \dfrac{d}{dx}\arctan(x^2)
3. \dfrac{d}{dx}\left[x\arcsin x + \sqrt{1-x^2}\right]
4. Why is \frac{d}{dx}\operatorname{arcsec} x = \frac{1}{|x|\sqrt{x^2-1}} rather than without the absolute value?
Solutions
1. Find the input mapping to 3: try x=1, giving 1+1+1 = 3 ✓. So f^{-1}(3) = 1.
f'(x) = 3x^2+1 \implies f'(1) = 4
(f^{-1})'(3) = \frac{1}{f'(1)} = \boxed{\frac14}
2. Chain rule with u = x^2:
\frac{2x}{1+(x^2)^2} = \boxed{\frac{2x}{1+x^4}}
3. Product rule on the first term, chain rule on the second:
\frac{d}{dx}\left[x\arcsin x\right] = \arcsin x + \frac{x}{\sqrt{1-x^2}}
\frac{d}{dx}\sqrt{1-x^2} = \frac{-2x}{2\sqrt{1-x^2}} = \frac{-x}{\sqrt{1-x^2}}
Adding, the two fractional terms cancel exactly:
\boxed{\arcsin x}
That cancellation is not luck — it means x\arcsin x + \sqrt{1-x^2} is the antiderivative of \arcsin x, which is how §4.6 computes \int\arcsin x\,dx by parts.
4. Because \operatorname{arcsec} is increasing on both branches of its domain, so its derivative must be positive for x < -1 as well as for x > 1.
Deriving it: \sec y = x gives \sec y\tan y\cdot y' = 1, so y' = \frac{1}{\sec y\tan y} = \frac{1}{x\tan y}. Then \tan y = \pm\sqrt{\sec^2y - 1} = \pm\sqrt{x^2-1}, and the sign depends on which branch you're on.
Working the cases through, both give a positive result, and \frac{1}{|x|\sqrt{x^2-1}} is the single expression covering both. Drop the absolute value and you get a negative derivative for x<-1, contradicting the graph.
This is exactly the \sqrt{x^2} = |x| care from §1.6, reappearing.
Check yourself in code
Verify the inverse-function rule for four functions.
For \arcsin at x=0.6, \arctan at x=0.6, \ln at x=2, and \sqrt[3]{x} at x=8: print the central difference (h=10^{-6}) and the formula's value, each to 8 decimals.
Print exactly this:
arcsin x=0.6 numeric 1.25000000 rule 1.25000000
arctan x=0.6 numeric 0.73529412 rule 0.73529412
ln x=2.0 numeric 0.50000000 rule 0.50000000
cbrt x=8.0 numeric 0.08333333 rule 0.08333333
from math import asin, atan, log, sqrt
def numerical(f, x, h=1e-6):
return (f(x + h) - f(x - h)) / (2 * h)
cases = [
("arcsin", asin, lambda x: 1 / sqrt(1 - x*x), 0.6),
("arctan", atan, lambda x: 1 / (1 + x*x), 0.6),
("ln", log, lambda x: 1 / x, 2.0),
("cbrt", lambda t: t ** (1/3), lambda x: 1 / (3 * x**(2/3)), 8.0),
]
for name, f, df, x in cases:
# print the numerical derivative and the rule's value
print(f"{name:<8} x={x:<5} ...")
from math import asin, atan, log, sqrt
def numerical(f, x, h=1e-6):
return (f(x + h) - f(x - h)) / (2 * h)
cases = [
("arcsin", asin, lambda x: 1 / sqrt(1 - x*x), 0.6),
("arctan", atan, lambda x: 1 / (1 + x*x), 0.6),
("ln", log, lambda x: 1 / x, 2.0),
("cbrt", lambda t: t ** (1/3), lambda x: 1 / (3 * x**(2/3)), 8.0),
]
for name, f, df, x in cases:
print(f"{name:<8} x={x:<5} numeric {numerical(f, x):.8f} rule {df(x):.8f}")
(f^{-1})'(x) = \frac{1}{f'(f^{-1}(x))}, because reflecting a graph across y = x turns rise-over-run into run-over-rise. You never need a formula for the inverse — just the matching input. Applied to the restricted trig functions it gives \arcsin' = \frac{1}{\sqrt{1-x^2}} and \arctan' = \frac{1}{1+x^2}, with the "co-" versions differing only by a sign. Those algebraic derivatives are why inverse trig functions turn up as answers throughout §4.
Next: the hyperbolic functions, which mirror all of this with the signs changed — and one of which you already know as an activation function.