TExcelTAD
Home › Calculus Essentials › Implicit Differentiation

Implicit Differentiation

Not every curve comes as y=f(x)y = f(x). A circle x2+y2=25x^2 + y^2 = 25 or a curve like x3+y3=6xyx^3 + y^3 = 6xy ties xx and yy together in one equation. Implicit differentiation finds the slope dydx\frac{dy}{dx} anyway: differentiate both sides with respect to xx, treat yy as an unknown function of xx, and solve for dydx\frac{dy}{dx}.

The method

  1. Differentiate every term of the equation with respect to xx.
  2. Whenever you differentiate an expression in yy, multiply by dydx\frac{dy}{dx} (chain rule): ddxy2=2y⋅dydx\frac{d}{dx} y^2 = 2y \cdot \frac{dy}{dx}.
  3. Collect the dydx\frac{dy}{dx} terms on one side and solve.

Example: the circle

x2+y2=252x+2y⋅y′=0y′=−xy\begin{aligned} x^2 + y^2 &= 25 \\ 2x + 2y \cdot y' &= 0 \\ y' &= -\frac{x}{y} \end{aligned}

At the point (3,4)(3, 4) the slope is −3/4-3/4; at (3,−4)(3, -4) it is +3/4+3/4. One formula covers both the upper and the lower half of the circle, which an explicit y=±25−x2y = \pm\sqrt{25 - x^2} would need two formulas for. Note that the slope is −x/y-x/y, the negative reciprocal of the radius direction y/xy/x: tangents to a circle are perpendicular to the radius.

Example: a curve with a product

For x3+y3=6xyx^3 + y^3 = 6xy (the folium of Descartes), the right side needs the product rule:

3x2+3y2⋅y′=6y+6x⋅y′y′(3y2−6x)=6y−3x2y′=2y−x2y2−2x\begin{aligned} 3x^2 + 3y^2 \cdot y' &= 6y + 6x \cdot y' \\ y' (3y^2 - 6x) &= 6y - 3x^2 \\ y' &= \frac{2y - x^2}{y^2 - 2x} \end{aligned}

At the point (3,3)(3, 3): y′=6−99−6=−1y' = \frac{6 - 9}{9 - 6} = -1.

SymPy does it with idiff

python · try it yourself
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 expression=0\text{expression} = 0. The last line asks for the second derivative. SymPy returns (-x**2 - y**2)/y**3; on the circle x2+y2=25x^2 + y^2 = 25, so this is −25/y3-25/y^3.

Numeric evidence

On the upper half of the circle we can also solve for yy explicitly and compare with the implicit formula:

python · try it yourself
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 xx approaches 5, y→0y \to 0 and the slope −x/y-x/y blows up: the tangent at (5,0)(5, 0) is vertical.

Derivatives of inverse functions

Implicit differentiation explains the inverse-function derivatives. For y=arcsin⁡xy = \arcsin x we have sin⁡y=x\sin y = x, so

cos⁡y⋅y′=1  ⟹  y′=1cos⁡y=11−sin⁡2y=11−x2\cos y \cdot y' = 1 \implies y' = \frac{1}{\cos y} = \frac{1}{\sqrt{1 - \sin^2 y}} = \frac{1}{\sqrt{1 - x^2}}

The same trick on ey=xe^y = x gives (ln⁡x)′=1/x(\ln x)' = 1/x, as in Derivatives of Exponentials and Logs.

In software

  • Implicit surfaces and SDFs: graphics and games describe shapes as F(x,y)=0F(x, y) = 0 or F(x,y,z)=0F(x, y, z) = 0 (signed distance fields, metaballs, terrain iso-surfaces). The surface normal, needed for lighting and collision response, is the gradient of FF; in 2D the tangent slope is dydx=−Fx/Fy\frac{dy}{dx} = -F_x / F_y, 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 x2+y2=L2x^2 + y^2 = L^2. Differentiating it in time gives xx˙+yy˙=0x\dot{x} + y\dot{y} = 0: 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 dydx\frac{dy}{dx} for 4x2+9y2=364x^2 + 9y^2 = 36, and the slope at (0,2)(0, 2).

Answer

dydx=−4x9y\frac{dy}{dx} = -\frac{4x}{9y}; slope 0 at (0,2)(0, 2).

Solution
8x+18y⋅y′=0  ⟹  y′=−8x18y=−4x9yat (0,2): y′=0(the top of the ellipse)\begin{aligned} &8x + 18y \cdot y' = 0 \implies y' = -\frac{8x}{18y} = -\frac{4x}{9y} \\ &\text{at } (0, 2){:}\ y' = 0 \quad \text{(the top of the ellipse)} \end{aligned}

Exercise 2: Mixed terms

Find dydx\frac{dy}{dx} for x2y+y3=10x^2 y + y^3 = 10.

Answer

dydx=−2xyx2+3y2\dfrac{dy}{dx} = -\dfrac{2xy}{x^2 + 3y^2}

Solution
ddx(x2y)=2xy+x2y′(product rule)ddx(y3)=3y2y′2xy+x2y′+3y2y′=0  ⟹  y′(x2+3y2)=−2xyy′=−2xyx2+3y2\begin{aligned} &\frac{d}{dx} (x^2 y) = 2xy + x^2 y' && \text{(product rule)} \\ &\frac{d}{dx} (y^3) = 3y^2 y' \\ &2xy + x^2 y' + 3y^2 y' = 0 \implies y' (x^2 + 3y^2) = -2xy \\ &y' = -\frac{2xy}{x^2 + 3y^2} \end{aligned}

Exercise 3: Tangent line

Find the tangent line to x2+xy+y2=7x^2 + xy + y^2 = 7 at the point (1,2)(1, 2).

Answer

y=−0.8x+2.8y = -0.8x + 2.8 (slope −4/5-4/5).

Solution
2x+(y+xy′)+2yy′=0  ⟹  y′=−2x+yx+2yat (1,2): y′=−2+21+4=−45y=2−45(x−1)=−0.8x+2.8\begin{aligned} &2x + (y + x y') + 2y y' = 0 \implies y' = -\frac{2x + y}{x + 2y} \\ &\text{at } (1, 2){:}\ y' = -\frac{2 + 2}{1 + 4} = -\frac{4}{5} \\ &y = 2 - \tfrac{4}{5}(x - 1) = -0.8x + 2.8 \end{aligned}

Exercise 4: Check with idiff

Use SymPy's idiff to confirm the slope in Exercise 3.

Answer

-4/5

Solution
python · try it yourself
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 y3y^3 with respect to xx (yy depends on xx), you get …

  1. 3y2⋅dydx3y^2 \cdot \frac{dy}{dx}
  2. 3y23y^2
  3. 3x23x^2
  4. 00

What is the slope of x2+y2=25x^2 + y^2 = 25 at (−3,4)(-3, 4)?

  1. −3/4-3/4
  2. 4/34/3
  3. 3/43/4
  4. −4/3-4/3

For a curve F(x,y)=0F(x, y) = 0, what is dydx\frac{dy}{dx} in terms of partial derivatives?

  1. Fx⋅FyF_x \cdot F_y
  2. −Fx/Fy-F_x / F_y
  3. Fy/FxF_y / F_x
  4. −Fy/Fx-F_y / F_x