The Derivative as a Function
Letting the point vary turns the derivative into a new function , whose value at each is the slope of there. This lesson covers the notations, how the graph of is read off the graph of , where derivatives fail to exist, the theorem that differentiability implies continuity, and higher derivatives.
For a first look see The Derivative and Differentiability in the survey course. Here we prove the key theorem and look closely at the failure cases.
as a function
The domain of is the set of where this limit exists; it can be smaller than the domain of . Example: (domain ).
So , defined only for . At the quotient : a vertical tangent.
Notations
| Notation | Read as | Notes |
|---|---|---|
| "f prime of x" | Lagrange | |
| , | "dee y dee x" | Leibniz; reminds you of |
| , | "D of f" | is the differentiation operator |
| "y dot" | Newton; time derivatives in physics |
The value at a point is written or .
import sympy as sp
x, h = sp.symbols('x h', positive=True)
for f in [sp.sqrt(x), x**3 - 4*x, 1/(x + 1)]:
from_def = sp.limit((f.subs(x, x + h) - f)/h, h, 0)
print(f"f = {str(f):12} from definition: {str(sp.factor(from_def)):18} sp.diff: {sp.diff(f, x)}")f = sqrt(x) from definition: 1/(2*sqrt(x)) sp.diff: 1/(2*sqrt(x))
f = x**3 - 4*x from definition: 3*x**2 - 4 sp.diff: 3*x**2 - 4
f = 1/(x + 1) from definition: -1/(x + 1)**2 sp.diff: -1/(x + 1)**2
(The symbols are declared positive so that SymPy can simplify freely; the formulas hold wherever they are defined.)
Reading from the graph of
- Where rises, ; where falls, .
- At a smooth peak or valley, the tangent is horizontal: .
- Where is steepest, is largest.
import numpy as np
import matplotlib.pyplot as plt
x = np.linspace(-2.5, 2.5, 501)
f = x**3 - 3*x
df = np.gradient(f, x) # numerical derivative (central differences)
fig, (a1, a2) = plt.subplots(2, 1, figsize=(6, 5), sharex=True)
a1.plot(x, f); a1.set_ylabel("f(x) = x³ − 3x"); a1.grid(alpha=0.3)
a2.plot(x, df, "C1"); a2.axhline(0, color="k", lw=0.6); a2.set_ylabel("f′(x)"); a2.grid(alpha=0.3)
zeros = x[np.where(np.diff(np.sign(df)) != 0)[0]]
print("f′ changes sign near x =", [round(float(z), 2) for z in zeros])
print("max error vs 3x² − 3 (interior):", round(float(np.max(np.abs(df[1:-1] - (3*x[1:-1]**2 - 3)))), 10))f′ changes sign near x = [-1.0, 0.99]
max error vs 3x² − 3 (interior): 0.0001
The sign changes of sit at , the peak and valley of . NumPy's np.gradient uses central differences with step , so its error on a cubic is exactly .
Differentiable implies continuous
is differentiable at if exists, and differentiable on an open interval if it is differentiable at every point of it.
Theorem. If is differentiable at , then is continuous at .
Proof. For ,
By the product law,
so , which is continuity at . ∎
The converse is false: is continuous at but not differentiable there. Continuity is necessary for differentiability, not sufficient. (There are even continuous functions differentiable nowhere, such as the Weierstrass function.)
Three ways to fail
| Failure | Example at 0 | What the difference quotient does |
|---|---|---|
| Corner or kink | , ReLU | one-sided limits differ ( vs , or vs ) |
| Discontinuity | step function | blows up on one side (theorem above) |
| Vertical tangent |
For corners we still speak of one-sided derivatives: the right derivative of ReLU at is , the left derivative is .
Higher derivatives
The derivative of is the second derivative , written . Then , and in general. For position : is velocity, acceleration, jerk. Geometrically, means the slope is increasing (the graph bends upward), a theme of How Derivatives Affect the Shape of a Graph. Example: has , , , and for .
In software
- ReLU and subgradients. ReLU is not differentiable at ; frameworks such as PyTorch simply use the left or right derivative there (usually ). The corner lies on a set of measure zero, so training rarely notices (Machine Learning).
- Smooth motion. Animation curves are judged by their derivatives: continuous position but discontinuous velocity looks like a jolt, so splines are built to keep (and often ) continuous at the joints (Game Math).
- Jerk-limited motion in robotics, elevators and CNC machines keeps bounded for comfort and mechanical safety.
Exercises
Exercise 1: Derivative from the definition
Find from the definition for .
Answer
Solution
Exercise 2: Domain of
Find for and state the domains of and .
Answer
; domain of is , of is .
Solution
Exercise 3: One-sided derivatives
for and for . Is continuous at ? Differentiable?
Answer
Continuous (both sides give 1) and differentiable, with .
Solution
Exercise 4: Higher derivatives in SymPy
For (metres, seconds), find the times when the velocity is zero and the acceleration at those times.
Answer
at and ; acceleration and .
Solution
import sympy as sp
t = sp.symbols('t')
s = t**3 - 6*t**2 + 9*t
v, a = sp.diff(s, t), sp.diff(s, t, 2)
for r in sp.solve(v, t):
print(f"t = {r}: acceleration {a.subs(t, r)}")t = 1: acceleration -6
t = 3: acceleration 6
Test yourself
Which statement is true?
- Every continuous function is differentiable
- Every differentiable function is continuous
- A function with a vertical tangent is differentiable there
- is not continuous at 0
The key step in proving that differentiability implies continuity is writing as what?
What are the left and right derivatives of at 0?
- Both 0
- Both 1
- Left 0, right 1
- Left 1, right 0