We often write a function the output variable (usually \(y\)) isolated on one side of the equation (e.g., \(y = 3x + 7\)). However, sometimes, it’s cumbersome or impossible to isolate the output variable (e.g. \(y^3 + x^2y^5 - x^4 = 27\)). In such cases, we have what’s called an implicit relationship between our variables. We can find the derivative with respect to \(y\) for these functions using a process called implicit differentiation. More details about the operation can be found here and here.

In Python, we can perform implicit differentiation using the sympy.idiff.


For \(y^3 + x^2y^5 - x^4 = 27\) (a) find \(dy/dx\) using implicit differentiation (b) find the slope of the tangent line to the curve at the point \((0, 3)\).

from sympy import *

x, y = symbols("x y")

expr = y**3 + x**2*y**5 - x**4 - 27

dydx = idiff(expr, y, x)
## 2*x*(2*x**2 - y**5)/(y**2*(5*x**2*y**2 + 3))
dydx.subs({x:0, y:3})
## 0


For the demand equation \(x = \sqrt{200 - p^3}\), differentiate implicitly to find \(dp/dx\).

p = symbols("p")

expr = -x + sqrt(200 - p**3)

dpdx = idiff(expr, p, x)
## -2*sqrt(200 - p**3)/(3*p**2)