TExcelTAD
Home › Calculus in Depth › Implicit Differentiation

Implicit Differentiation

Many curves are described by an equation in xx and yy, such as x2+y2=25x^2 + y^2 = 25, rather than by a formula y=f(x)y = f(x). Implicit differentiation finds dydx\frac{dy}{dx} anyway, by differentiating both sides and treating yy as an unknown function of xx. It also gives the derivatives of the inverse trigonometric functions.

For a gentler first look, see Implicit Differentiation. The technique is the chain rule from The Chain Rule, applied every time yy appears.

The method

  1. Differentiate both sides of the equation with respect to xx.
  2. Every term with yy gets a factor dydx\frac{dy}{dx} (written y′y') by the chain rule: ddxy3=3y2⋅y′\frac{d}{dx} y^3 = 3y^2 \cdot y', ddxsin⁡y=cos⁡y⋅y′\frac{d}{dx} \sin y = \cos y \cdot y', and products such as xyxy need the product rule: ddx(xy)=y+x⋅y′\frac{d}{dx} (xy) = y + x \cdot y'.
  3. Collect the y′y' terms on one side and solve.

Example: a circle. From x2+y2=25x^2 + y^2 = 25:

2x+2y⋅y′=0  ⟹  y′=−xy(y≠0)2x + 2y \cdot y' = 0 \qquad\implies\qquad y' = -\frac{x}{y} \qquad (y \ne 0)

At (3,4)(3, 4) the slope is −34-\frac{3}{4}, and at (3,−4)(3, -4) it is +34+\frac{3}{4}. One formula covers both halves of the circle, which the explicit route y=±25−x2y = \pm\sqrt{25 - x^2} has to treat separately. The slope is perpendicular to the radius, slope y/xy/x, as geometry demands.

Example: a curve with no explicit form. For x3+y3=6xyx^3 + y^3 = 6xy:

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) (check: 27+27=54=6⋅927 + 27 = 54 = 6 \cdot 9) the slope is 6−99−6=−1\frac{6 - 9}{9 - 6} = -1.

SymPy's idiff and a picture

SymPy has idiff(equation, y, x) for exactly this. The plot draws the curve as a contour of F(x,y)=x3+y3−6xyF(x, y) = x^3 + y^3 - 6xy at level 0, with the tangent at (3,3)(3, 3).

python · try it yourself
import numpy as np
import sympy as sp
import matplotlib.pyplot as plt

x, y = sp.symbols('x y')
F = x**3 + y**3 - 6*x*y
slope = sp.idiff(F, y, x)
print("dy/dx =", sp.simplify(slope))
print("slope at (3, 3):", slope.subs({x: 3, y: 3}))

X, Y = np.meshgrid(np.linspace(-4, 5, 400), np.linspace(-4, 5, 400))
plt.figure(figsize=(5, 5))
plt.contour(X, Y, X**3 + Y**3 - 6*X*Y, levels=[0])
t = np.linspace(1.5, 4.5, 2)
plt.plot(t, 3 - (t - 3), "r--", label="tangent at (3, 3)")
plt.plot([3], [3], "ro")
plt.gca().set_aspect("equal")
plt.legend()
dy/dx = (x**2 - 2*y)/(2*x - y**2)
slope at (3, 3): -1

SymPy's form x2−2y2x−y2\frac{x^2 - 2y}{2x - y^2} is ours with numerator and denominator both multiplied by −1-1.

Second derivatives implicitly

Differentiate y′y' again, substituting y′y' back in. For the circle, y′=−x/yy' = -x/y:

y′′=−1⋅y−x⋅y′y2=−y−x⋅(−x/y)y2=−y2+x2y3=−25y3y'' = -\frac{1 \cdot y - x \cdot y'}{y^2} = -\frac{y - x \cdot (-x/y)}{y^2} = -\frac{y^2 + x^2}{y^3} = -\frac{25}{y^3}

using the original equation x2+y2=25x^2 + y^2 = 25 in the last step. On the upper half (y>0y > 0) the curve is concave down, on the lower half concave up.

Why it works, and when

Implicit differentiation assumes the equation defines yy as a differentiable function of xx near the point. That is not always true: at (5,0)(5, 0) on the circle the tangent is vertical and y′=−x/yy' = -x/y has a zero denominator. The Implicit Function Theorem (met again with Partial Derivatives) says: if F(x,y)=0F(x, y) = 0 and ∂F/∂y≠0\partial F/\partial y \ne 0 at a point, then near that point the equation does define a differentiable y(x)y(x), with

dydx=−∂F/∂x∂F/∂y\frac{dy}{dx} = -\frac{\partial F/\partial x}{\partial F/\partial y}

which is exactly what the step-by-step method computes.

Derivatives of inverse trigonometric functions

Let y=arcsin⁡xy = \arcsin x, meaning sin⁡y=x\sin y = x with −π/2≤y≤π/2-\pi/2 \le y \le \pi/2. Differentiate implicitly:

cos⁡y⋅y′=1  ⟹  y′=1cos⁡y\cos y \cdot y' = 1 \qquad\implies\qquad y' = \frac{1}{\cos y}

On [−π/2,π/2][-\pi/2, \pi/2], cos⁡y≥0\cos y \ge 0, so cos⁡y=1−sin⁡2y=1−x2\cos y = \sqrt{1 - \sin^2 y} = \sqrt{1 - x^2}. Hence ddxarcsin⁡x=11−x2\frac{d}{dx} \arcsin x = \frac{1}{\sqrt{1 - x^2}} for −1<x<1-1 < x < 1.

For y=arctan⁡xy = \arctan x, tan⁡y=x\tan y = x with −π/2<y<π/2-\pi/2 < y < \pi/2:

sec⁡2y⋅y′=1  ⟹  y′=1sec⁡2y=11+tan⁡2y=11+x2\sec^2 y \cdot y' = 1 \quad\implies\quad y' = \frac{1}{\sec^2 y} = \frac{1}{1 + \tan^2 y} = \frac{1}{1 + x^2}
Function Derivative Valid for
arcsin⁡x\arcsin x 11−x2\frac{1}{\sqrt{1 - x^2}} −1<x<1-1 < x < 1
arccos⁡x\arccos x −11−x2-\frac{1}{\sqrt{1 - x^2}} −1<x<1-1 < x < 1
arctan⁡x\arctan x 11+x2\frac{1}{1 + x^2} all xx
arcsec⁡x\operatorname{arcsec} x 1xx2−1\frac{1}{x\sqrt{x^2 - 1}} x>1x > 1

arccos⁡x=π/2−arcsin⁡x\arccos x = \pi/2 - \arcsin x, which explains its minus sign.

python · try it yourself
import sympy as sp

x = sp.symbols('x')
for f in [sp.asin(x), sp.acos(x), sp.atan(x)]:
    print(f"d/dx {str(f):8} = {sp.diff(f, x)}")
print("d/dx arctan(x²) =", sp.diff(sp.atan(x**2), x))
d/dx asin(x)  = 1/sqrt(1 - x**2)
d/dx acos(x)  = -1/sqrt(1 - x**2)
d/dx atan(x)  = 1/(x**2 + 1)
d/dx arctan(x²) = 2*x/(x**4 + 1)

Tip: arctan⁡\arctan has a derivative that is a plain rational function. That is why ∫11+x2 dx=arctan⁡x+C\int \frac{1}{1 + x^2}\,dx = \arctan x + C turns up in Partial Fractions.

In software

  • Signed distance fields and implicit surfaces: graphics and games often store shapes as F(x,y,z)=0F(x, y, z) = 0. The surface normal is the gradient (∂F/∂x,∂F/∂y,∂F/∂z)(\partial F/\partial x, \partial F/\partial y, \partial F/\partial z); the slope formula −Fx/Fy-F_x/F_y is its 2D shadow (Shaders).
  • atan2: the angle of a vector (x,y)(x, y) in games uses arctan⁡\arctan, and steering code that turns smoothly relies on its bounded derivative.
  • Implicit layers in ML: "deep equilibrium" models define an output zz by an equation z=f(z,x)z = f(z, x) and get gradients by the Implicit Function Theorem instead of unrolling a loop.
  • Root tracking: solvers that follow a curve F(x,y)=0F(x, y) = 0 as a parameter changes (continuation methods) step along dydx=−Fx/Fy\frac{dy}{dx} = -F_x/F_y.

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

y′=−4x9yy' = -\frac{4x}{9y}; slope 0 at (0,2)(0, 2).

Solution
8x+18y⋅y′=0  ⟹  y′=−8x18y=−4x9yat (0,2): −0/18=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){:}\ -0/18 = 0 && \text{(the top of the ellipse)} \end{aligned}

Exercise 2: A product term

Find dydx\frac{dy}{dx} for x2y+y3=10x^2y + y^3 = 10 and evaluate it at (3,1)(3, 1).

Answer

y′=−2xyx2+3y2y' = -\frac{2xy}{x^2 + 3y^2}; at (3,1)(3, 1) it is −12-\frac{1}{2}.

Solution
check point: 9⋅1+1=10 ✓2xy+x2⋅y′+3y2⋅y′=0y′(x2+3y2)=−2xyy′=−2xyx2+3y2=−69+3=−12\begin{aligned} &\text{check point: } 9 \cdot 1 + 1 = 10 \ \checkmark \\ &2xy + x^2 \cdot y' + 3y^2 \cdot y' = 0 \\ &y'(x^2 + 3y^2) = -2xy \\ &y' = -\frac{2xy}{x^2 + 3y^2} = -\frac{6}{9 + 3} = -\frac{1}{2} \end{aligned}

Exercise 3: Trig inside

Find dydx\frac{dy}{dx} for sin⁡(x+y)=y\sin(x + y) = y.

Answer

y′=cos⁡(x+y)1−cos⁡(x+y)y' = \frac{\cos(x + y)}{1 - \cos(x + y)}

Solution
cos⁡(x+y)⋅(1+y′)=y′cos⁡(x+y)=y′(1−cos⁡(x+y))y′=cos⁡(x+y)1−cos⁡(x+y)\begin{aligned} \cos(x + y) \cdot (1 + y') &= y' \\ \cos(x + y) &= y'(1 - \cos(x + y)) \\ y' &= \frac{\cos(x + y)}{1 - \cos(x + y)} \end{aligned}

Exercise 4: Arctan with a chain

Differentiate f(x)=arctan⁡(3x)f(x) = \arctan(3x) and evaluate f′(1)f'(1). Then check with SymPy.

Answer

f′(x)=31+9x2f'(x) = \frac{3}{1 + 9x^2}, f′(1)=310f'(1) = \frac{3}{10}

Solution
f′(x)=11+(3x)2⋅3=31+9x2;f′(1)=310f'(x) = \frac{1}{1 + (3x)^2} \cdot 3 = \frac{3}{1 + 9x^2}; \qquad f'(1) = \frac{3}{10}
python · try it yourself
import sympy as sp

x = sp.symbols('x')
d = sp.diff(sp.atan(3*x), x)
print(d, d.subs(x, 1))
3/(9*x**2 + 1) 3/10

Exercise 5: Horizontal tangents

Find the points on x2−xy+y2=3x^2 - xy + y^2 = 3 where the tangent is horizontal.

Answer

(1,2)(1, 2) and (−1,−2)(-1, -2)

Solution
2x−y−x⋅y′+2y⋅y′=0  ⟹  y′=y−2x2y−xhorizontal: y=2x; substitute: x2−2x2+4x2=3x2=3  ⟹  x=±1points (1,2) and (−1,−2); there 2y−x=±3≠0, so y′ is defined\begin{aligned} &2x - y - x \cdot y' + 2y \cdot y' = 0 \implies y' = \frac{y - 2x}{2y - x} \\ &\text{horizontal: } y = 2x; \text{ substitute: } x^2 - 2x^2 + 4x^2 = 3x^2 = 3 \implies x = \pm 1 \\ &\text{points } (1, 2) \text{ and } (-1, -2); \text{ there } 2y - x = \pm 3 \ne 0, \text{ so } y' \text{ is defined} \end{aligned}

Test yourself

What is ddx(y2)\frac{d}{dx} (y^2) when yy is a function of xx?

  1. 2y2y
  2. 2y⋅y′2y \cdot y'
  3. 2x2x
  4. y2⋅y′y^2 \cdot y'

What is ddxarcsin⁡x\frac{d}{dx} \arcsin x?

  1. 11+x2\frac{1}{1 + x^2}
  2. −11−x2-\frac{1}{\sqrt{1 - x^2}}
  3. 11−x2\frac{1}{\sqrt{1 - x^2}}
  4. cos⁡x\cos x

For F(x,y)=0F(x, y) = 0, which condition guarantees yy is locally a differentiable function of xx?

  1. ∂F/∂x≠0\partial F/\partial x \ne 0
  2. ∂F/∂y≠0\partial F/\partial y \ne 0
  3. FF is a polynomial
  4. x≠0x \ne 0