Implicit Differentiation
Not every curve comes as . A circle or a curve like ties and together in one equation. Implicit differentiation finds the slope anyway: differentiate both sides with respect to , treat as an unknown function of , and solve for .
The method
- Differentiate every term of the equation with respect to .
- Whenever you differentiate an expression in , multiply by (chain rule): .
- Collect the terms on one side and solve.
Example: the circle
At the point the slope is ; at it is . One formula covers both the upper and the lower half of the circle, which an explicit would need two formulas for. Note that the slope is , the negative reciprocal of the radius direction : tangents to a circle are perpendicular to the radius.
Example: a curve with a product
For (the folium of Descartes), the right side needs the product rule:
At the point : .
SymPy does it with idiff
import sympy as sp
x, y = sp.symbols('x y')
circle = x**2 + y**2 - 25
folium = x**3 + y**3 - 6 * x * y
print("circle y' :", sp.idiff(circle, y, x))
print("folium y' :", sp.simplify(sp.idiff(folium, y, x)))
print("slope at (3, 3):", sp.idiff(folium, y, x).subs({x: 3, y: 3}))
print("circle y'' :", sp.simplify(sp.idiff(circle, y, x, 2)))circle y' : -x/y
folium y' : (x**2 - 2*y)/(2*x - y**2)
slope at (3, 3): -1
circle y'' : (-x**2 - y**2)/y**3
sp.idiff(eq, y, x) expects the equation in the form . The last line asks for the second derivative. SymPy returns (-x**2 - y**2)/y**3; on the circle , so this is .
Numeric evidence
On the upper half of the circle we can also solve for explicitly and compare with the implicit formula:
import math
def upper(x):
return math.sqrt(25 - x * x)
h = 1e-6
print(" x y numeric slope -x/y")
for x0 in [-4.0, -1.0, 0.0, 2.0, 3.0, 4.5]:
y0 = upper(x0)
numeric = (upper(x0 + h) - upper(x0 - h)) / (2 * h)
print(f"{x0:4} {y0:6.4f} {numeric:12.6f} {-x0 / y0:9.6f}") x y numeric slope -x/y
-4.0 3.0000 1.333333 1.333333
-1.0 4.8990 0.204124 0.204124
0.0 5.0000 0.000000 -0.000000
2.0 4.5826 -0.436436 -0.436436
3.0 4.0000 -0.750000 -0.750000
4.5 2.1794 -2.064742 -2.064742
As approaches 5, and the slope blows up: the tangent at is vertical.
Derivatives of inverse functions
Implicit differentiation explains the inverse-function derivatives. For we have , so
The same trick on gives , as in Derivatives of Exponentials and Logs.
In software
- Implicit surfaces and SDFs: graphics and games describe shapes as or (signed distance fields, metaballs, terrain iso-surfaces). The surface normal, needed for lighting and collision response, is the gradient of ; in 2D the tangent slope is , exactly what implicit differentiation produces. Ray marching shaders estimate it with finite differences of the SDF.
- Constraints in physics: a pendulum or a bead on a wire obeys a constraint like . Differentiating it in time gives : the velocity must be perpendicular to the rod. Constraint solvers use exactly this (distance constraints).
- Economics and ML: "how does one variable respond to another while staying on a constraint curve" is implicit differentiation; it is also how implicit layers and equilibrium models in deep learning get their gradients without unrolling an iteration.
Exercises
Exercise 1: An ellipse
Find for , and the slope at .
Answer
; slope 0 at .
Solution
Exercise 2: Mixed terms
Find for .
Answer
Solution
Exercise 3: Tangent line
Find the tangent line to at the point .
Answer
(slope ).
Solution
Exercise 4: Check with idiff
Use SymPy's idiff to confirm the slope in Exercise 3.
Answer
-4/5
Solution
import sympy as sp
x, y = sp.symbols('x y')
print(sp.idiff(x**2 + x*y + y**2 - 7, y, x).subs({x: 1, y: 2}))-4/5
Test yourself
When differentiating with respect to ( depends on ), you get …
What is the slope of at ?
For a curve , what is in terms of partial derivatives?