Module contents
Lesson 10 of 20Advanced 110 min

Inverse and implicit function theorems and implicit differentiation

When an equation F(x, θ) = 0 locally defines x as a differentiable function of θ, and how to differentiate that function without solving it explicitly. The inverse function theorem is proved using Banach's fixed point theorem, the implicit function theorem is derived from it, and both are applied at today's practical frontier: differentiation through solutions of equations and optimization problems (equilibrium layers, hypergradients, implicit meta-learning).

After this lesson you can

  • Prove the inverse function theorem using Banach's fixed point theorem and derive the implicit function theorem.
  • Compute derivatives of implicitly defined functions and solutions of nonlinear systems.
  • Derive argmin sensitivity, dx*/dθ = -[∇²ₓₓg]⁻¹∇²ₓθg, and apply it without matrix inversion using an adjoint linear system.
  • Describe regular level sets as submanifolds and compute their tangent and normal spaces.
  • Implement hypergradients using implicit differentiation and an equilibrium layer with implicit backward pass.

Before you start

Motivation: layers as equations

A neural network layer is usually a formula: z=tanh⁡(Wx+b)\vb{z} = \tanh(\mat{W}\vb{x} + \vb{b}). Given x\vb{x}, it is evaluated; for training, autograd saves intermediates and applies the chain rule. But increasingly, parts of modern systems are not formulas but solutions of something:

  • Equilibrium layers. A deep equilibrium model (DEQ) defines its output as a layer’s fixed point z∗=fθ(z∗,x)\vb{z}^* = f_\theta(\vb{z}^*, \vb{x}), as if stacking infinitely many copies with the same weights. Nobody writes z∗\vb{z}^* as a formula: it is computed iteratively.
  • Optimization layers. OptNet returns the solution of a quadratic problem whose coefficients depend on the input. A projector onto a set, an optimal-transport problem or a physical system at equilibrium work the same way.
  • Hyperparameters. Ridge regression weights are w∗(λ)=arg min⁡wLtr(w,λ)\vb{w}^*(\lambda) = \argmin_{\vb{w}} \Loss_{\text{tr}}(\vb{w}, \lambda). To tune λ\lambda by gradient, you need dw∗/dλd\vb{w}^*/d\lambda, the derivative of an argmin.
  • Meta-learning. In implicit MAML, the model adapted to a task is the minimum of a regularized loss, and the meta-gradient passes through that minimum.
  • Robotics and inverse problems. Inverse kinematics solves f(q)=xf(\vb{q}) = \vb{x} for joints q\vb{q} taking the end effector to position x\vb{x}; tomography solves a system of equations yielding physical parameters.

In every case an equation F(x,θ)=0F(\vb{x}, \theta) = \vb{0} determines unknown x\vb{x} as a function of parameters θ\theta, and there are two questions. When does the equation actually define a differentiable function θ↦x(θ)\theta \mapsto \vb{x}(\theta)? And how do we compute its derivative without knowing a formula or backpropagating through the hundred iterations of the method solving it? The answers are the implicit function theorem and its practical consequence, implicit differentiation. Both rest on the inverse function theorem, which we will prove using the Banach fixed point theorem: the proof is literally an algorithm.

Intuition: when a curve is a graph

Start with the smallest case: one equation in two unknowns, F(x,y)=0F(x, y) = 0. Its solution set is a plane curve, a level set of FF. The question “does this equation define yy as a function of xx?” is geometric: near a point, is the curve a function’s graph?

Globally, almost never. Circle x2+y2=1x^2 + y^2 = 1 is not a function’s graph because each x∈(−1,1)x \in (-1, 1) has two heights. But locally, almost always: near (0.6,0.8)(0.6, 0.8) the circle is the graph of g(x)=1−x2g(x) = \sqrt{1 - x^2}. Only two points fail, (±1,0)(\pm 1, 0), where the tangent is vertical. There, on one side of the point the curve has two heights and on the other none.

InteractiveWhere a curve is a function
∇F = 0
  • branch y=g(x)y = g(x) from the theorem
  • branch x=h(y)x = h(y)
  • tangent
  • vertical tangent (Fy=0F_y = 0)
  • singular point
(x2+y2)2=x2−y2(x^2 + y^2)^2 = x^2 - y^2
10 %
Point (x,y)(x, y)(0.626, 0.353)
∇F=(Fx,Fy)\nabla F = (F_x, F_y)(0.041, 1.437)
Slope −Fx/Fy-F_x/F_y−0.029
Local y=g(x)y = g(x)yes
Local x=h(y)x = h(y)no
Branch over x∈x \in[0.03, 1.00]
Drag the blue point along the curve or use the slider. The orange branch is the segment y=g(x)y = g(x) guaranteed by the implicit function theorem when Fy≠0F_y \neq 0, extended while it remains a graph; the dashed line is the tangent with slope −Fx/Fy-F_x/F_y. Move the point to a vertical tangent (hollow turquoise circle): the branch becomes x=h(y)x = h(y). On the lemniscate and folium, move the point to the crossing (red circle, ∇F=0\nabla F = \vb{0}): neither exists. Cubic y3=xy^3 = x shows the theorem's condition is sufficient, not necessary.

The key in the figure is what controls the change. The orange branch dies exactly where Fy=0F_y = 0, and the slope readout explodes there. The reason fits on one line: if y=g(x)y = g(x) is differentiable and F(x,g(x))=0F(x, g(x)) = 0 for all xx, differentiation by the chain rule gives

Fx(x,g(x))+Fy(x,g(x)) g′(x)=0⟹g′(x)=−FxFy.F_x(x, g(x)) + F_y(x, g(x))\, g'(x) = 0 \quad\Longrightarrow\quad g'(x) = -\frac{F_x}{F_y}.

Where Fy≠0F_y \neq 0, the formula gives slope without solving for anything: we need not even know how to write gg. Where Fy=0F_y = 0 but Fx≠0F_x \neq 0, the roles switch and the curve is locally x=h(y)x = h(y) with h′=−Fy/Fxh' = -F_y/F_x. And where ∇F=0\nabla F = \vb{0}, as at the lemniscate crossing, neither formula makes sense and in fact two branches pass through the origin. In every regular case the tangent is perpendicular to ∇F\nabla F, as you already knew from level sets.

The general version replaces “Fy≠0F_y \neq 0” with “matrix ∂F/∂x\partial F/\partial\vb{x} is invertible”. To get there, first understand when a map Rn→Rn\R^n \to \R^n can be inverted.

The inverse function theorem

In one variable the answer seems easy: if f′(a)≠0f'(a) \neq 0 and f′f' is continuous, f′f' has constant sign near aa, ff is strictly monotone there and therefore injective, with differentiable inverse of derivative 1/f′1/f'. Continuity of f′f' is not a detail. Function f(x)=x+2x2sin⁡(1/x)f(x) = x + 2x^2\sin(1/x), with f(0)=0f(0) = 0, is differentiable everywhere and f′(0)=1f'(0) = 1, but f′(x)=1+4xsin⁡(1/x)−2cos⁡(1/x)f'(x) = 1 + 4x\sin(1/x) - 2\cos(1/x) takes negative values arbitrarily close to 0. So ff is not injective in any neighborhood of the origin, however small.

In several variables monotonicity does not exist and another idea is needed. The idea is the lesson’s central one: the differential Df(a)Df(\vb{a}) is the best linear approximation of ff near a\vb{a}. If that linear map is invertible, nonlinearity is a small perturbation of something invertible, and a small perturbation of an isomorphism remains invertible. Banach’s fixed point theorem turns this into a theorem.

This is the inverse function theorem. A bijective map C1C^1 with inverse C1C^1 is called a diffeomorphism; the theorem says det⁡Df(a)≠0\det Df(\vb{a}) \neq 0 suffices for ff to be a local diffeomorphism around a\vb{a}. The formula for DgDg is what you would guess: if g(f(x))=xg(f(\vb{x})) = \vb{x}, the chain rule gives Dg(f(x)) Df(x)=IDg(f(\vb{x}))\,Df(\vb{x}) = \mat{I}. What is not automatic is that gg exists and is differentiable, which is what the proof shows.

Proof using a contraction

Proof

Write A=Df(a)\mat{A} = Df(\vb{a}) and b=f(a)\vb{b} = f(\vb{a}), and use the matrix operator norm.

Step 1: a working radius. Since DfDf is continuous, there exists r>0r > 0 such that closed ball Bˉ(a,r)\bar B(\vb{a}, r) lies in UU and

∥Df(x)−A∥≤12∥A−1∥para todo x∈Bˉ(a,r).\norm{Df(\vb{x}) - \mat{A}} \le \frac{1}{2\norm{\mat{A}\inv}} \qquad \text{para todo } \vb{x} \in \bar B(\vb{a}, r).

Step 2: solving f(x)=yf(\vb{x}) = \vb{y} means finding a fixed point. For each y∈Rn\vb{y} \in \R^n define

φy(x)=x+A−1(y−f(x)).\varphi_{\vb{y}}(\vb{x}) = \vb{x} + \mat{A}\inv\big(\vb{y} - f(\vb{x})\big).

Its fixed points are exactly the solutions of f(x)=yf(\vb{x}) = \vb{y}, because A−1\mat{A}\inv is injective. Its differential is Dφy(x)=I−A−1Df(x)=A−1(A−Df(x))D\varphi_{\vb{y}}(\vb{x}) = \mat{I} - \mat{A}\inv Df(\vb{x}) = \mat{A}\inv\big(\mat{A} - Df(\vb{x})\big), of norm ≤∥A−1∥⋅12∥A−1∥=12\le \norm{\mat{A}\inv}\cdot\frac{1}{2\norm{\mat{A}\inv}} = \frac12 on the ball. Since the ball is convex, the mean value inequality gives

∥φy(x1)−φy(x2)∥≤12∥x1−x2∥para x1,x2∈Bˉ(a,r).\norm{\varphi_{\vb{y}}(\vb{x}_1) - \varphi_{\vb{y}}(\vb{x}_2)} \le \tfrac12\norm{\vb{x}_1 - \vb{x}_2} \qquad \text{para } \vb{x}_1, \vb{x}_2 \in \bar B(\vb{a}, r).

Step 3: quantitative injectivity. Write x1−x2=(φ0(x1)−φ0(x2))+A−1(f(x1)−f(x2))\vb{x}_1 - \vb{x}_2 = \big(\varphi_{\vb{0}}(\vb{x}_1) - \varphi_{\vb{0}}(\vb{x}_2)\big) + \mat{A}\inv\big(f(\vb{x}_1) - f(\vb{x}_2)\big). With the previous bound,

∥x1−x2∥≤12∥x1−x2∥+∥A−1∥∥f(x1)−f(x2)∥,es decir,∥x1−x2∥≤2∥A−1∥ ∥f(x1)−f(x2)∥.(∗)\norm{\vb{x}_1 - \vb{x}_2} \le \tfrac12\norm{\vb{x}_1 - \vb{x}_2} + \norm{\mat{A}\inv}\norm{f(\vb{x}_1) - f(\vb{x}_2)}, \quad\text{es decir,}\quad \norm{\vb{x}_1 - \vb{x}_2} \le 2\norm{\mat{A}\inv}\,\norm{f(\vb{x}_1) - f(\vb{x}_2)}. \tag{$\ast$}

In particular, ff is injective on Bˉ(a,r)\bar B(\vb{a}, r).

Step 4: surjectivity onto a ball. Let ρ=r/(2∥A−1∥)\rho = r/(2\norm{\mat{A}\inv}) and V0=B(b,ρ)V_0 = B(\vb{b}, \rho). If y∈V0\vb{y} \in V_0 and x∈Bˉ(a,r)\vb{x} \in \bar B(\vb{a}, r),

∥φy(x)−a∥≤∥φy(x)−φy(a)∥+∥φy(a)−a∥≤r2+∥A−1∥∥y−b∥<r2+r2=r.\norm{\varphi_{\vb{y}}(\vb{x}) - \vb{a}} \le \norm{\varphi_{\vb{y}}(\vb{x}) - \varphi_{\vb{y}}(\vb{a})} + \norm{\varphi_{\vb{y}}(\vb{a}) - \vb{a}} \le \tfrac{r}{2} + \norm{\mat{A}\inv}\norm{\vb{y} - \vb{b}} < \tfrac{r}{2} + \tfrac{r}{2} = r.

Thus φy\varphi_{\vb{y}} maps the closed ball, a complete metric space because it is closed in Rn\R^n, into itself and is a contraction with constant 12\frac12. By Banach it has a unique fixed point, also in open ball B(a,r)B(\vb{a}, r). Define U0=B(a,r)∩f−1(V0)U_0 = B(\vb{a}, r) \cap f^{-1}(V_0), open by continuity of ff and with a∈U0\vb{a} \in U_0. Then f:U0→V0f: U_0 \to V_0 is bijective, and its inverse gg maps each y\vb{y} to the fixed point of φy\varphi_{\vb{y}}.

Step 5: gg is Lipschitz. Applying (∗)(\ast) to xi=g(yi)\vb{x}_i = g(\vb{y}_i), ∥g(y1)−g(y2)∥≤2∥A−1∥∥y1−y2∥\norm{g(\vb{y}_1) - g(\vb{y}_2)} \le 2\norm{\mat{A}\inv}\norm{\vb{y}_1 - \vb{y}_2}. In particular, gg is continuous.

Step 6: gg is differentiable. For x∈U0\vb{x} \in U_0, Df(x)=A(I−A−1(A−Df(x)))Df(\vb{x}) = \mat{A}\big(\mat{I} - \mat{A}\inv(\mat{A} - Df(\vb{x}))\big), and the parenthesis is invertible because ∥A−1(A−Df(x))∥≤12<1\norm{\mat{A}\inv(\mat{A} - Df(\vb{x}))} \le \frac12 < 1 (Neumann series). Fix y∈V0\vb{y} \in V_0, write x=g(y)\vb{x} = g(\vb{y}) and, for small k\vb{k}, h=g(y+k)−x\vb{h} = g(\vb{y} + \vb{k}) - \vb{x}, tending to 0\vb{0} with k\vb{k} by step 5. By differentiability of ff at x\vb{x},

k=f(x+h)−f(x)=Df(x)h+R(h),∥R(h)∥∥h∥→0,\vb{k} = f(\vb{x} + \vb{h}) - f(\vb{x}) = Df(\vb{x})\vb{h} + R(\vb{h}), \qquad \frac{\norm{R(\vb{h})}}{\norm{\vb{h}}} \to 0,

so h=Df(x)−1k−Df(x)−1R(h)\vb{h} = Df(\vb{x})\inv\vb{k} - Df(\vb{x})\inv R(\vb{h}). Since ∥h∥≤2∥A−1∥∥k∥\norm{\vb{h}} \le 2\norm{\mat{A}\inv}\norm{\vb{k}}, relative error satisfies

∥Df(x)−1R(h)∥∥k∥≤∥Df(x)−1∥ ∥R(h)∥∥h∥ 2∥A−1∥⟶0,\frac{\norm{Df(\vb{x})\inv R(\vb{h})}}{\norm{\vb{k}}} \le \norm{Df(\vb{x})\inv}\,\frac{\norm{R(\vb{h})}}{\norm{\vb{h}}}\,2\norm{\mat{A}\inv} \longrightarrow 0,

so gg is differentiable at y\vb{y} with Dg(y)=Df(g(y))−1Dg(\vb{y}) = Df(g(\vb{y}))\inv.

Step 7: regularity. Dg=inv⁡∘Df∘gDg = \operatorname{inv} \circ Df \circ g, composition of gg (continuous), DfDf (continuous), and matrix inversion, which is continuous, indeed C∞C^\infty, on the open set of invertible matrices because its entries are ratios of polynomials (Cramer’s rule). Hence g∈C1g \in C^1. If f∈Ckf \in C^k, induction gives g∈Ckg \in C^k: if g∈Cjg \in C^j with j<kj < k, then DgDg is CjC^j, that is, g∈Cj+1g \in C^{j+1}.

∎

Two observations make the proof a tool. First, the contraction is an algorithm. Iterating xk+1=xk+A−1(y−f(xk))\vb{x}_{k+1} = \vb{x}_k + \mat{A}\inv(\vb{y} - f(\vb{x}_k)) is Newton’s method with Jacobian frozen at a\vb{a} (the chord method). It converges linearly with asymptotic rate ρ(I−A−1Df(x∗))\rho\big(\mat{I} - \mat{A}\inv Df(\vb{x}^*)\big), bounded by norm ∥I−A−1Df(x∗)∥\norm{\mat{I} - \mat{A}\inv Df(\vb{x}^*)}, whereas Newton, updating the Jacobian each step, converges quadratically (see Newton for systems). Second, radii rr and ρ\rho are explicit. For f(x,y)=(x2−y2,2xy)f(x, y) = (x^2 - y^2, 2xy) we have Df(x)−Df(a)=2[x−a1−(y−a2)y−a2x−a1]Df(\vb{x}) - Df(\vb{a}) = 2\begin{bmatrix} x - a_1 & -(y - a_2) \\ y - a_2 & x - a_1 \end{bmatrix}, of norm 2∥x−a∥2\norm{\vb{x} - \vb{a}}, and ∥Df(a)−1∥=1/(2∥a∥)\norm{Df(\vb{a})\inv} = 1/(2\norm{\vb{a}}). Step 1 asks 2r≤∥a∥2r \le \norm{\vb{a}}: the proof guarantees an inverse on the ball of radius ∥a∥/2\norm{\vb{a}}/2 onto the ball of radius ρ=∥a∥2/2\rho = \norm{\vb{a}}^2/2 around f(a)f(\vb{a}). The closer to the origin, where DfDf is singular, the smaller both neighborhoods.

Local, not global

That ff is the complex map z↦z2z \mapsto z^2 written in real coordinates, the best laboratory for seeing what “local” means. Its Jacobian has determinant 4(x2+y2)4(x^2 + y^2), vanishing only at the origin. Thus ff is a local diffeomorphism around every point except the origin. Yet it is not injective on any open set containing two opposite points, because f(−z)=f(z)f(-\vb{z}) = f(\vb{z}).

InteractiveLocal inverse of z ↦ z²
Domain: the patch and its center c\vb{c}
Image under f(x,y)=(x2−y2, 2xy)f(x, y) = (x^2 - y^2,\ 2xy)
  • horizontal patch lines and their images
  • vertical lines
  • linear approximation
  • origin (det⁡Df=0\det Df = 0)
Patch
0.30
Center c\vb{c}(1.10, 0.55)
det⁡Df(c)=4∥c∥2\det Df(\vb{c}) = 4\|\vb{c}\|^26.050
Injective on the patchyes
Fraction of the patch with two preimages0.0 %
Remainder 2h22h^2 versus linear part 22 ∥c∥h2\sqrt2\,\|\vb{c}\|h0.180 versus 1.044
Drag the patch center c\vb{c}. Cells are translucent: where the image darkens, they cover it twice. Far from the origin the image is a distorted copy of the patch, nearly equal to its linear approximation (dashed): a rotation by arg⁡c\arg\vb{c} and scaling by 2∥c∥2\norm{\vb{c}}, with determinant 4∥c∥24\norm{\vb{c}}^2. Approach the origin: the linear approximation no longer resembles the image, which bends around 0\vb{0}, and when the patch contains a point q\vb{q} and its opposite −q-\vb{q} both land at the same q2\vb{q}^2. Enlarge hh far from the origin: the image becomes increasingly distorted, but does it fold before the patch contains the origin?

The figure shows both sides of the theorem. Near a point with det⁡Df≠0\det Df \neq 0, ff behaves like its invertible differential and the patch transforms bijectively. The size of the neighborhood depends on how long nonlinearity takes to dominate the linear part: the remainder of f(c+δ)=c2+2cδ+δ2f(\vb{c} + \vb{\delta}) = \vb{c}^2 + 2\vb{c}\vb{\delta} + \vb{\delta}^2 is δ2\vb{\delta}^2, of size ∥δ∥2\norm{\vb{\delta}}^2, versus the linear part of size 2∥c∥∥δ∥2\norm{\vb{c}}\norm{\vb{\delta}}. Once ∥δ∥\norm{\vb{\delta}} is comparable to ∥c∥\norm{\vb{c}}, linearization no longer dominates. This does not mean ff ceases to be injective: z12=z22\vb{z}_1^2 = \vb{z}_2^2 only if z2=±z1\vb{z}_2 = \pm\vb{z}_1, and a convex set containing q\vb{q} and −q-\vb{q} contains their midpoint, the origin. Thus ff is injective on any convex patch not containing the origin in its interior, however large: the answer to the figure’s question is no. Radius ∥a∥/2\norm{\vb{a}}/2 from the proof is a guarantee, not the actual neighborhood size. At the origin, det⁡Df=0\det Df = 0 and no neighborhood has an inverse, large or small.

Global failure can occur even without singular points. The map (x,y)↦(excos⁡y,exsin⁡y)(x, y) \mapsto (e^x\cos y, e^x\sin y), which is z↦ezz \mapsto e^z, has det⁡Df=e2x>0\det Df = e^{2x} > 0 everywhere in the plane and is not injective because it is periodic in yy. The global theorem that does exist (Hadamard) requires another hypothesis: a f∈C1(Rn,Rn)f \in C^1(\R^n, \R^n) is a diffeomorphism from Rn\R^n to Rn\R^n if and only if det⁡Df(x)≠0\det Df(\vb{x}) \neq 0 everywhere and ∥f(x)∥→∞\norm{f(\vb{x})} \to \infty when ∥x∥→∞\norm{\vb{x}} \to \infty. The complex exponential fails the second condition: along the imaginary axis, ∣eiy∣=1\abs{e^{iy}} = 1.

The implicit function theorem

Now separate variables into unknowns x∈Rn\vb{x} \in \R^n and parameters θ∈Rp\theta \in \R^p, with as many equations as unknowns: F:Rn×Rp→RnF: \R^n \times \R^p \to \R^n. The Jacobian of FF splits into two blocks,

DF=[ ∂F∂x  ∣  ∂F∂θ ],∂F∂x∈Rn×n,∂F∂θ∈Rn×p.DF = \Big[\, \pd{F}{\vb{x}} \;\Big|\; \pd{F}{\theta} \,\Big], \qquad \pd{F}{\vb{x}} \in \R^{n\times n}, \quad \pd{F}{\theta} \in \R^{n\times p}.

This is the implicit function theorem. It follows from the inverse function theorem applied to augmented map G(x,θ)=(F(x,θ),θ)G(\vb{x}, \theta) = (F(\vb{x}, \theta), \theta), which leaves parameters alone and has block-triangular Jacobian: the complete proof is the first guided exercise. Once x(θ)\vb{x}(\theta) is known to be differentiable, the derivative formula is the chain rule applied to identity F(x(θ),θ)=0F(\vb{x}(\theta), \theta) = \vb{0}:

∂F∂x Dx(θ)+∂F∂θ=0.\pd{F}{\vb{x}}\,D\vb{x}(\theta) + \pd{F}{\theta} = \mat{0}.

Three readings of the statement, each with a lesson:

  • Count dimensions. nn equations fix nn unknowns and leave pp parameters free: the solution set near (x0,θ0)(\vb{x}_0, \theta_0) is a “surface” of dimension pp, the graph of x(⋅)\vb{x}(\cdot). Invertibility of ∂F/∂x\partial F/\partial\vb{x} says the equations are independent in the unknown directions.
  • Linearize. If FF were linear, F=Ax+BθF = \mat{A}\vb{x} + \mat{B}\theta, the solution would be x=−A−1Bθ\vb{x} = -\mat{A}\inv\mat{B}\theta, exactly the derivative formula. The theorem says that near a solution the nonlinear case behaves like its linearization.
  • Local. Like the inverse function theorem, the theorem says nothing about how far Θ\Theta extends. Branch x(θ)\vb{x}(\theta) may end at a point where ∂F/∂x\partial F/\partial\vb{x} becomes singular, or merge with another branch.

Plane curves: the lemniscate and folium

With n=p=1n = p = 1 and (x,y)(x, y) instead of (θ,x)(\theta, \vb{x}), the theorem says: if F(x0,y0)=0F(x_0, y_0) = 0 and Fy(x0,y0)≠0F_y(x_0, y_0) \neq 0, near the point the curve is the graph of a differentiable gg with g′=−Fx/Fyg' = -F_x/F_y. Return to the curves in the opening figure with this lens.

Implicit differentiation

The theorem’s formula is the part used daily. Let x∗(θ)\vb{x}^*(\theta) be the solution of F(x,θ)=0F(\vb{x}, \theta) = \vb{0}, computed by any method (Newton, fixed point, a commercial solver), and abbreviate Fx=∂F/∂x\mat{F}_{\vb{x}} = \partial F/\partial\vb{x} and Fθ=∂F/∂θ\mat{F}_\theta = \partial F/\partial\theta, evaluated at the solution. Implicit differentiation obtains derivatives of x∗\vb{x}^* without solving explicitly:

∂x∗∂θ=−Fx−1Fθ.\frac{\partial\vb{x}^*}{\partial\theta} = -\mat{F}_{\vb{x}}^{-1}\mat{F}_\theta.

Nobody forms this matrix n×pn \times p, just as nobody forms a network’s Jacobian to train it. What is needed is one of its two products, both reducible to solving a linear system with Fx\mat{F}_{\vb{x}}:

  • Tangent mode (the JVP). For parameter direction v∈Rp\vb{v} \in \R^p, x˙=(∂x∗/∂θ)v\dot{\vb{x}} = (\partial\vb{x}^*/\partial\theta)\vb{v} solves
Fx x˙=−Fθv.\mat{F}_{\vb{x}}\,\dot{\vb{x}} = -\mat{F}_\theta\vb{v}.

One system per direction: useful when pp is small.

  • Adjoint mode (the VJP). For scalar loss L(x∗(θ))L(\vb{x}^*(\theta)), ∇θL=(∂x∗/∂θ)⊤∇xL=−Fθ⊤Fx−T∇xL\nabla_\theta L = (\partial\vb{x}^*/\partial\theta)\T\nabla_{\vb{x}}L = -\mat{F}_\theta\T\mat{F}_{\vb{x}}^{-\mathsf{T}}\nabla_{\vb{x}}L. Grouping from the right,
Fx⊤u=∇xL,∇θL=−Fθ⊤u.\mat{F}_{\vb{x}}\T\vb{u} = \nabla_{\vb{x}}L, \qquad \nabla_\theta L = -\mat{F}_\theta\T\vb{u}.

One linear system, regardless of pp, followed by a VJP with Fθ\mat{F}_\theta.

Vector u\vb{u} is called the adjoint variable and is the exact analog of the gradient backpropagated by autograd. If LL also depends directly on θ\theta, add ∂L/∂θ\partial L/\partial\theta. This cost is what matters in machine learning: with millions of parameters and a scalar loss, adjoint mode costs one n×nn \times n system and two VJPs, no more and no less.

CostMemory
Finite differencesp+1p + 1 complete nonlinear problem solvesone solve
Unroll solver with autograda backward pass through all iterationsproportional to the number of iterations
Implicit, tangent modeone linear system per directionone system
Implicit, adjoint modeone linear system with Fx⊤\mat{F}_{\vb{x}}\T and one VJPone system

Two practical details. The adjoint system does not need Fx\mat{F}_{\vb{x}} in memory: an iterative method such as conjugate gradient (if Fx\mat{F}_{\vb{x}} is symmetric positive definite) or GMRES only needs products Fx⊤u\mat{F}_{\vb{x}}\T\vb{u}, provided by autograd as VJPs. And when F(z,θ)=z−f(z,θ)F(\vb{z}, \theta) = \vb{z} - f(\vb{z}, \theta) is a fixed-point equation, Fz=I−J\mat{F}_{\vb{z}} = \mat{I} - \mat{J} with J=∂f/∂z\mat{J} = \partial f/\partial\vb{z}, the adjoint system (I−J⊤)u=g(\mat{I} - \mat{J}\T)\vb{u} = \vb{g} is solved using the same iteration u←J⊤u+g\vb{u} \leftarrow \mat{J}\T\vb{u} + \vb{g}, converging at the forward rate ρ(J)\rho(\mat{J}).

The formula uses only the solution, not the path to it. Whether EE comes from Newton, bisection or a table, the derivative is the same. This algorithm independence makes implicit differentiation modular, and is also its weakness, because it assumes you have the exact solution.

Argmin sensitivity

The most important case in learning is when x∗(θ)\vb{x}^*(\theta) solves not an arbitrary equation but an optimization problem: x∗(θ)=arg min⁡xg(x,θ)\vb{x}^*(\theta) = \argmin_{\vb{x}} g(\vb{x}, \theta). The idea is to view the first-order condition as an equation. At an interior minimum, ∇xg(x∗,θ)=0\grad_{\vb{x}} g(\vb{x}^*, \theta) = \vb{0}: this is F(x,θ)=∇xg(x,θ)F(\vb{x}, \theta) = \grad_{\vb{x}} g(\vb{x}, \theta), and its Jacobian with respect to x\vb{x} is the Hessian ∇xx2g\grad^2_{\vb{x}\vb{x}}g.

This argmin sensitivity formula underlies bilevel optimization and optimization layers. Its proof—apply the implicit function theorem to ∇xg\grad_{\vb{x}}g and verify that the resulting branch remains a branch of minima—is the second guided exercise. Two hypotheses do all the work: the positive-definite Hessian provides both the invertibility required by the theorem and that the branch consists of minima (by continuity, the Hessian remains positive definite nearby). If the Hessian is singular or there are multiple minimizers, the formula does not make sense; a final exercise gives an explicit example.

Hypergradients: ridge without magic formulas

Ridge regression with training data (X,y)(\mat{X}, \vb{y}) minimizes

Ltr(w,λ)=12∥Xw−y∥2+λ2∥w∥2,\Loss_{\text{tr}}(\vb{w}, \lambda) = \tfrac12\norm{\mat{X}\vb{w} - \vb{y}}^2 + \tfrac{\lambda}{2}\norm{\vb{w}}^2,

and the choice of λ\lambda is judged by validation loss Lval(w)\Loss_{\text{val}}(\vb{w}) on other data. This is bilevel optimization: minimize Lval(w∗(λ))\Loss_{\text{val}}(\vb{w}^*(\lambda)) subject to w∗(λ)\vb{w}^*(\lambda) minimizing Ltr(⋅,λ)\Loss_{\text{tr}}(\cdot, \lambda). The outer function’s gradient, dLval/dλd\Loss_{\text{val}}/d\lambda, is called a hypergradient.

With H=X⊤X\mat{H} = \mat{X}\T\mat{X} and b=X⊤y\vb{b} = \mat{X}\T\vb{y}, the first-order condition is the normal equations (H+λI)w=b(\mat{H} + \lambda\mat{I})\vb{w} = \vb{b}. Hessian H+λI\mat{H} + \lambda\mat{I} is positive definite for λ>0\lambda > 0, and the cross-derivative is ∇wλ2Ltr=w\grad^2_{\vb{w}\lambda}\Loss_{\text{tr}} = \vb{w}. The argmin formula gives

dw∗dλ=−(H+λI)−1w∗,\frac{d\vb{w}^*}{d\lambda} = -(\mat{H} + \lambda\mat{I})^{-1}\vb{w}^*,

and the hypergradient in adjoint mode,

(H+λI) v=∇Lval(w∗),dLvaldλ=⟨∇Lval(w∗),dw∗dλ⟩=−v⊤w∗.(\mat{H} + \lambda\mat{I})\,\vb{v} = \grad\Loss_{\text{val}}(\vb{w}^*), \qquad \frac{d\Loss_{\text{val}}}{d\lambda} = \Big\langle \grad\Loss_{\text{val}}(\vb{w}^*), \frac{d\vb{w}^*}{d\lambda}\Big\rangle = -\vb{v}\T\vb{w}^*.

Note the intermediate form: the hypergradient is the inner product of the validation gradient and the path velocity λ↦w∗(λ)\lambda \mapsto \vb{w}^*(\lambda). It vanishes when the path is tangent to a validation level curve.

InteractiveRegularization hypergradient
Weight plane (w1,w2)(w_1, w_2)
Validation loss versus log⁡10λ\log_{10}\lambda
  • validation loss
  • tangent (hypergradient)
  • path w∗(λ)\vb{w}^*(\lambda)
  • velocity ∂w∗/∂log⁡10λ\partial\vb{w}^*/\partial\log_{10}\lambda (×0.5)
  • −∇Lval-\nabla L_{\text{val}} and current contour
  • validation minimum
−1.30 (λ = 0.050)
w∗(λ)\vb{w}^*(\lambda)(1.844, −0.860)
Implicit dw∗/dλd\vb{w}^*/d\lambda(−1.8183, 1.9302)
dw∗/dλd\vb{w}^*/d\lambda by finite differences(−1.8183, 1.9302)
Lval(w∗(λ))L_{\text{val}}(\vb{w}^*(\lambda))0.7797
Hypergradient dLval/dλdL_{\text{val}}/d\lambda (adjoint)−0.60198
By finite differences−0.60198
Relative difference2.0e−11
Angle between ∇Lval\nabla L_{\text{val}} and the path108.9°
Ridge regression with two weights and synthetic data (12 training and 400 validation examples; generation described in the code). Left, path w∗(λ)\vb{w}^*(\lambda) goes from least squares (λ→0\lambda \to 0) to the origin (λ→∞\lambda \to \infty) among validation level curves; the orange arrow is path velocity from implicit differentiation, and magenta is −∇Lval-\nabla\Loss_{\text{val}}. Right, validation loss with tangent whose slope is the hypergradient. Compare implicit and finite-difference readouts, and press ‘Descent in log λ’: the method stops where the orange arrow and magenta level curve are tangent.

The path does not pass through the validation minimum (gray circle): a single parameter cannot reach every point in the plane, and the best λ\lambda offers is the path point touching the lowest level curve. With one scalar hyperparameter, a grid search would suffice. Implicit differentiation becomes indispensable with many: one regularization coefficient per weight, per-training-example weights, parameters of a network generating data augmentations. Lorraine, Vicol and Duvenaud (2020) tune millions of hyperparameters this way, approximating the inverse-Hessian product with a truncated Neumann series; the gradient-free alternative is Bayesian optimization.

Regular level sets

The implicit function theorem has a geometric interpretation beyond solving for variables. A sphere {x∈R3:∥x∥2=1}\{\vb{x} \in \R^3 : \norm{\vb{x}}^2 = 1\}, the rotation group, the set of fixed-rank matrices or the manifold of permitted positions of a constrained robot are level sets F−1(c)F^{-1}(\vb{c}), and what enables calculus on them is that near each point they are graphs of smooth functions.

Proof

Since DF(p)∈Rm×nDF(\vb{p}) \in \R^{m\times n} has rank mm, it has mm linearly independent columns. Reorder coordinates to make them first and write x=(u,v)\vb{x} = (\vb{u}, \vb{v}) with u∈Rm\vb{u} \in \R^m and v∈Rn−m\vb{v} \in \R^{n-m}: block ∂F/∂u(p)\partial F/\partial\vb{u}(\vb{p}) is invertible. The implicit function theorem applied to F(u,v)−c=0F(\vb{u}, \vb{v}) - \vb{c} = \vb{0}, with u\vb{u} as unknown and v\vb{v} as parameter, gives a neighborhood where MM is the graph u=ϕ(v)\vb{u} = \phi(\vb{v}) of a function C1C^1. Thus MM is a submanifold of dimension n−mn - m.

If γ\gamma is a curve in MM with γ(0)=p\gamma(0) = \vb{p}, then F(γ(t))=cF(\gamma(t)) = \vb{c} for all tt and, differentiating at t=0t = 0, DF(p)γ′(0)=0DF(\vb{p})\gamma'(0) = \vb{0}: TpM⊆null⁡DF(p)T_{\vb{p}}M \subseteq \nullsp DF(\vb{p}). Conversely, for each w∈Rn−m\vb{w} \in \R^{n-m}, curve t↦(ϕ(v0+tw),v0+tw)t \mapsto (\phi(\vb{v}_0 + t\vb{w}), \vb{v}_0 + t\vb{w}) lies in MM and has velocity (Dϕ(v0)w,w)(D\phi(\vb{v}_0)\vb{w}, \vb{w}). These velocities form a subspace of dimension n−mn - m (the second component already spans all Rn−m\R^{n-m}) contained in TpM⊆null⁡DF(p)T_{\vb{p}}M \subseteq \nullsp DF(\vb{p}), and by the rank-nullity theorem dim⁡null⁡DF(p)=n−m\dim\nullsp DF(\vb{p}) = n - m. Equality holds throughout. The final assertion is that the orthogonal complement of a matrix’s null space is the column space of its transpose, whose columns are gradients ∇Fi(p)\grad F_i(\vb{p}).

∎

This result, regular level sets as submanifolds, is the gateway to calculus on manifolds. Three examples clarify:

  • The sphere. F(x)=∥x∥2F(\vb{x}) = \norm{\vb{x}}^2 has DF(x)=2x⊤≠0DF(\vb{x}) = 2\vb{x}\T \neq \vb{0} on the unit sphere: Sn−1S^{n-1} is a submanifold of dimension n−1n - 1, with TpSn−1={v:p⊤v=0}T_{\vb{p}}S^{n-1} = \{\vb{v} : \vb{p}\T\vb{v} = 0\} and normal generated by p\vb{p}.
  • The orthogonal group. F(Q)=Q⊤QF(\mat{Q}) = \mat{Q}\T\mat{Q} maps Rn×n\R^{n\times n} to the space of symmetric matrices, dimension n(n+1)/2n(n+1)/2, and DF(Q)H=Q⊤H+H⊤QDF(\mat{Q})\mat{H} = \mat{Q}\T\mat{H} + \mat{H}\T\mat{Q}. It is surjective at each orthogonal Q\mat{Q}: given symmetric S\mat{S}, H=QS/2\mat{H} = \mat{Q}\mat{S}/2 satisfies DF(Q)H=SDF(\mat{Q})\mat{H} = \mat{S}. Thus O(n)=F−1(I)O(n) = F^{-1}(\mat{I}) has dimension n2−n(n+1)/2=n(n−1)/2n^2 - n(n+1)/2 = n(n-1)/2, and its tangent at I\mat{I} consists of skew-symmetric matrices, H+H⊤=0\mat{H} + \mat{H}\T = \mat{0}. These are infinitesimal rotation generators used in robotics.
  • A counterexample. Cone x2+y2−z2=0x^2 + y^2 - z^2 = 0 is not a submanifold at its vertex, where the gradient vanishes. Again the condition is only sufficient: (x2+y2−1)2=0(x^2 + y^2 - 1)^2 = 0 describes the circle, which is a submanifold, although the gradient of that FF vanishes everywhere on it.

Spheres, rotation groups and robot configuration manifolds, all regular level sets, are the spaces on which geometric learning works; they generalize there to abstract manifolds and their tangent spaces.

Frontier: implicit layers

All of the above has become a way to design networks in which the forward pass solves a problem and the backward pass applies the implicit function theorem.

Deep equilibrium models. Bai, Kolter and Koltun (2019) observed that a network with the same weights in every layer, zk+1=fθ(zk,x)\vb{z}_{k+1} = f_\theta(\vb{z}_k, \vb{x}), often converges to a fixed point, and proposed defining output directly as z∗=fθ(z∗,x)\vb{z}^* = f_\theta(\vb{z}^*, \vb{x}), computed using a root-finding method (Broyden in the original paper). With F(z,θ)=z−fθ(z,x)F(\vb{z}, \theta) = \vb{z} - f_\theta(\vb{z}, \vb{x}), adjoint mode gives

(I−J⊤) u=∇zL,∇θL=(∂fθ∂θ)⊤u,J=∂fθ∂z(z∗,x).(\mat{I} - \mat{J}\T)\,\vb{u} = \grad_{\vb{z}}L, \qquad \grad_\theta L = \Big(\pd{f_\theta}{\theta}\Big)\T\vb{u}, \qquad \mat{J} = \pd{f_\theta}{\vb{z}}(\vb{z}^*, \vb{x}).

Backward memory does not depend on forward iteration count: it is that of a single layer. The paper reports memory reductions of up to 88% with the same quality as similarly sized explicit language models.

InteractiveA layer as a fixed point
Iterates zk+1=tanh⁡(Wzk+x)\vb{z}_{k+1} = \tanh(\mat{W}\vb{z}_k + \vb{x})
Errors on a logarithmic scale
  • ‖z_k − z*‖ (forward)
  • relative error of dL/dx unrolling K
  • input x\vb{x} (draggable)
  • iterates zk\vb{z}_k
  • fixed point z∗\vb{z}^* (red if unstable)
  • unrolled gradient error
0.90
10
k = 40
ρ(J)\rho(\mat{J}) at z∗\vb{z}^*, with J=diag⁡(1−z∗2)W\mat{J} = \operatorname{diag}(1 - \vb{z}^{*2})\mat{W}0.701
Residual ∥zK−f(zK)∥\|\vb{z}_K - f(\vb{z}_K)\|1.1e−2
Implicit dL/dxdL/d\vb{x}(0.5127, −0.9662)
dL/dxdL/d\vb{x} unrolling K=10K = 10(0.5210, −0.9509)
Relative unrolling error1.6e−2
Numbers stored for backward: unrolled (KdK d) versus implicit (dd)20 versus 2
∥W∥2≤1\|\mat{W}\|_2 \le 1 and tanh⁡\tanh is 1-Lipschitz: the layer is a contraction and the fixed point is unique. Errors ≈ρ(J)k\approx \rho(\mat{J})^k with ρ=0.70\rho = 0.70.
Layer z∗=tanh⁡(Wz∗+x)\vb{z}^* = \tanh(\mat{W}\vb{z}^* + \vb{x}) in dimension 2, with W=s W0\mat{W} = s\,\mat{W}_0 and ∥W0∥2=1\norm{\mat{W}_0}_2 = 1. Play iteration from z0=0\vb{z}_0 = \vb{0} and drag input x\vb{x}. The logarithmic plot shows forward error ∥zk−z∗∥\norm{\vb{z}_k - \vb{z}^*} and relative gradient error dL/dxdL/d\vb{x} (with L=c⊤z∗L = \vb{c}\T\vb{z}^*) obtained by unrolling KK iterations versus implicit: both fall with the same slope, log⁡ρ(J)\log\rho(\mat{J}), while unrolling memory grows with KK. Increase ss above 1: the contraction guarantee is lost, but iteration still converges until ρ(J)\rho(\mat{J}) crosses 1 (around s≈1.25s \approx 1.25 with the initial input). Beyond this, the fixed point exists but iteration does not find it.

The figure isolates two distinct conditions needed by a DEQ. For the implicit gradient to exist, it suffices that I−J\mat{I} - \mat{J} be invertible, i.e. 1 is not an eigenvalue of J\mat{J}. For the iterative forward pass to work, more is needed: ρ(J)<1\rho(\mat{J}) < 1 at the fixed point for local convergence, and something like ∥W∥2<1\norm{\mat{W}}_2 < 1 for global contraction, because tanh⁡\tanh is 1-Lipschitz. Practical DEQs therefore control weight norms (with spectral normalization or Jacobian regularization) and use more robust root-finding methods than simple iteration, such as Anderson acceleration.

Optimization layers. OptNet (Amos and Kolter, 2017) uses as a layer the solution of a quadratic problem with linear constraints, z∗=arg min⁡z 12z⊤Qz+q⊤z\vb{z}^* = \argmin_{\vb{z}}\ \frac12\vb{z}\T\mat{Q}\vb{z} + \vb{q}\T\vb{z} subject to Az=b\mat{A}\vb{z} = \vb{b} and Gz≤h\mat{G}\vb{z} \le \vb{h}, with coefficients depending on the preceding layer. The backward pass implicitly differentiates the KKT system at the solution, which is F(z,λ,ν;θ)=0F(\vb{z}, \vb{\lambda}, \vb{\nu}; \theta) = \vb{0}, using a batched GPU interior-point solver. In one experiment the network learns rules of 4×44\times 4 sudoku solely from examples.

Implicit meta-learning. iMAML (Rajeswaran, Finn, Kakade and Levine, 2019) adapts meta-parameters θ\theta to each task using regularized problem ϕ∗(θ)=arg min⁡ϕL^(ϕ)+λ2∥ϕ−θ∥2\phi^*(\theta) = \argmin_\phi \hat{\Loss}(\phi) + \frac{\lambda}{2}\norm{\phi - \theta}^2. The argmin formula gives dϕ∗/dθ=(I+1λ∇2L^(ϕ∗))−1d\phi^*/d\theta = \big(\mat{I} + \frac1\lambda\grad^2\hat{\Loss}(\phi^*)\big)^{-1}, and the meta-gradient is computed using conjugate gradients and Hessian-vector products. Memory does not depend on the number of inner-loop steps, precisely what limited MAML.

Modular implicit differentiation. Blondel et al. (2022) show that specifying the optimality condition FF (zero gradient, a proximal-step fixed point, KKT) suffices for a library to differentiate any solver with adjoint mode and autograd on FF; their JAX implementation was JAXopt.

Implementation from scratch

First, the inverse function theorem proof as an algorithm, for f(z)=z2f(z) = z^2 around a=(1,0.5)\vb{a} = (1, 0.5): contraction φy\varphi_{\vb{y}} versus Newton, and verification that the inverse derivative is the inverse of the derivative.

[ ]The contraction from the proofBrowser
import numpy as np

def f(p):
    x, y = p
    return np.array([x * x - y * y, 2 * x * y])

def Df(p):
    x, y = p
    return np.array([[2 * x, -2 * y], [2 * y, 2 * x]])

a = np.array([1.0, 0.5])
A = Df(a)
nA_inv = np.linalg.norm(np.linalg.inv(A), 2)          # solo para imprimir la constante
r = 1 / (4 * nA_inv)                                  # paso 1: ‖Df(x) − A‖ = 2‖x − a‖ ≤ 1/(2‖A⁻¹‖)
print(f"‖A⁻¹‖ = {nA_inv:.4f}   radio r = {r:.4f} (= |a|/2)   radio de V = {r / (2 * nA_inv):.4f} (= |a|²/2)")

def inversa_local(y, x0, A, tol=1e-14, max_iter=100):
    """Punto fijo de φ(x) = x + A⁻¹(y − f(x)): la contracción de la demostración."""
    x, hist = x0.copy(), []
    for _ in range(max_iter):
        x = x + np.linalg.solve(A, y - f(x))
        hist.append(np.linalg.norm(f(x) - y))
        if hist[-1] < tol:
            break
    return x, hist

def newton(y, x0, tol=1e-14, max_iter=50):
    x, hist = x0.copy(), []
    for _ in range(max_iter):
        x = x + np.linalg.solve(Df(x), y - f(x))
        hist.append(np.linalg.norm(f(x) - y))
        if hist[-1] < tol:
            break
    return x, hist

y = f(a) + np.array([0.3, -0.2])                      # un punto de V: ‖y − f(a)‖ = 0.36 < 0.625
x_c, h_c = inversa_local(y, a, A)
x_n, h_n = newton(y, a)
print("preimagen (contracción):", x_c, "  iteraciones:", len(h_c))
print("preimagen (Newton):     ", x_n, "  iteraciones:", len(h_n))
print("cocientes de errores sucesivos (contracción):", np.round(np.array(h_c[1:6]) / np.array(h_c[:5]), 3))
print("residuos de Newton:", ["%.1e" % e for e in h_n])
print("‖I − A⁻¹Df(x*)‖ =", round(np.linalg.norm(np.eye(2) - np.linalg.solve(A, Df(x_c)), 2), 4), "(tasa asintótica)")

# la derivada de la inversa es la inversa de la derivada
g = lambda yy: inversa_local(yy, a, A)[0]
h = 1e-6
Dg_fd = np.column_stack([(g(y + h * e) - g(y - h * e)) / (2 * h) for e in np.eye(2)])
print("Dg(y) por diferencias:\n", np.round(Dg_fd, 6))
print("Df(g(y))⁻¹:\n", np.round(np.linalg.inv(Df(x_c)), 6))

Contraction needs 16 iterations and Newton 4, with Newton residuals squaring at each step. The ratio of successive contraction errors stabilizes at 0.1430.143, exactly ∥I−A−1Df(x∗)∥\norm{\mat{I} - \mat{A}\inv Df(\vb{x}^*)} (here norm equals spectral radius because the matrix is a multiple of a rotation): the rate the proof bounds by 12\frac12 throughout the ball is much better near a\vb{a}. The inverse Jacobian, measured with finite differences on the algorithm itself, matches Df(g(y))−1Df(g(\vb{y}))\inv to all six printed digits. Note that the matrix is a multiple of a rotation, as befits the inverse of z↦z2z \mapsto z^2, a complex square root.

Now Kepler’s equation: implicit derivative versus finite differences and algorithm independence.

[ ]Kepler: differentiate without solving explicitlyBrowser
import numpy as np

def kepler_newton(M, e, tol=1e-15):
    """Resuelve E − e·sin E = M por Newton (0 ≤ e < 1)."""
    E = M if e < 0.8 else np.pi
    for _ in range(50):
        dE = (E - e * np.sin(E) - M) / (1 - e * np.cos(E))
        E -= dE
        if abs(dE) < tol:
            break
    return E

def kepler_biseccion(M, e):
    """El mismo problema con otro algoritmo: bisección en [M − e, M + e]."""
    lo, hi = M - e, M + e
    for _ in range(80):
        mid = 0.5 * (lo + hi)
        if mid - e * np.sin(mid) - M > 0:
            hi = mid
        else:
            lo = mid
    return 0.5 * (lo + hi)

M, e = 1.0, 0.6
E = kepler_newton(M, e)
F_E = 1 - e * np.cos(E)                   # ∂F/∂E
dE_dM = 1 / F_E                           # −(∂F/∂E)⁻¹ ∂F/∂M, con ∂F/∂M = −1
dE_de = np.sin(E) / F_E                   # con ∂F/∂e = −sin E
h = 1e-6
fd_M = (kepler_newton(M + h, e) - kepler_newton(M - h, e)) / (2 * h)
fd_e = (kepler_newton(M, e + h) - kepler_newton(M, e - h)) / (2 * h)
print(f"E = {E:.12f}   (bisección: {kepler_biseccion(M, e):.12f})")
print(f"dE/dM: implícita {dE_dM:.10f}   diferencias {fd_M:.10f}")
print(f"dE/de: implícita {dE_de:.10f}   diferencias {fd_e:.10f}")

# la fórmula solo usa la solución: da lo mismo con qué algoritmo se haya obtenido
Eb = kepler_biseccion(M, e)
print(f"dE/de con la solución de bisección: {np.sin(Eb) / (1 - e * np.cos(Eb)):.10f}")

The ridge hypergradient, now with 30 correlated features and 40 examples. There is still only one hyperparameter, so a fine grid will provide an optimum reference. Compare with finite differences and the alternative without this theorem: unroll TT gradient-descent steps on training loss and differentiate through them (here in forward mode, propagating dwt/dλd\vb{w}_t/d\lambda together with wt\vb{w}_t).

[ ]Ridge hypergradient from scratchBrowser
import numpy as np

rng = np.random.default_rng(0)
n, n_val, d = 40, 400, 30
w_true = rng.normal(size=d) * (rng.random(d) < 0.3)          # pocos coeficientes no nulos
Sigma = 0.7 ** np.abs(np.subtract.outer(np.arange(d), np.arange(d)))   # características correladas
Lc = np.linalg.cholesky(Sigma)
X = rng.normal(size=(n, d)) @ Lc.T
Xv = rng.normal(size=(n_val, d)) @ Lc.T
y = X @ w_true + 1.0 * rng.normal(size=n)
yv = Xv @ w_true + 1.0 * rng.normal(size=n_val)
H, b = X.T @ X, X.T @ y

def w_star(lam):
    return np.linalg.solve(H + lam * np.eye(d), b)

def val_loss(w):
    r = Xv @ w - yv
    return 0.5 * r @ r / n_val

def hipergradiente(lam):
    """dL_val/dλ con un único sistema adjunto: (H + λI) v = ∇L_val(w*), dL/dλ = −vᵀw*."""
    w = w_star(lam)
    g = Xv.T @ (Xv @ w - yv) / n_val
    v = np.linalg.solve(H + lam * np.eye(d), g)
    return -v @ w, w

lam = 3.0
hg, w = hipergradiente(lam)
eps = 1e-5 * lam
fd = (val_loss(w_star(lam + eps)) - val_loss(w_star(lam - eps))) / (2 * eps)
print(f"λ = {lam}:  hipergradiente implícito {hg:.10f}   diferencias finitas {fd:.10f}")

# desenrollar T pasos de descenso por gradiente sobre la pérdida de entrenamiento (modo directo)
def hipergradiente_desenrollado(lam, T):
    A = H + lam * np.eye(d)
    alpha = 1.0 / np.linalg.eigvalsh(A)[-1]
    w, dw = np.zeros(d), np.zeros(d)
    for _ in range(T):
        w, dw = w - alpha * (A @ w - b), dw - alpha * (A @ dw + w)   # derivada de la recurrencia
    g = Xv.T @ (Xv @ w - yv) / n_val
    return g @ dw

ev = np.linalg.eigvalsh(H + lam * np.eye(d))
print(f"número de condición de H + λI: {ev[-1] / ev[0]:.0f}   tasa de GD 1 − μ/L = {1 - ev[0] / ev[-1]:.4f}")
for T in [10, 100, 1000, 5000]:
    hu = hipergradiente_desenrollado(lam, T)
    print(f"T = {T:5d}:  desenrollado {hu: .8f}   error relativo {abs(hu - hg) / abs(hg):.1e}")

# optimizar log λ con el hipergradiente
t, pasos = np.log(1e-2), 0
for it in range(100):
    g, _ = hipergradiente(np.exp(t))
    paso = np.clip(3.0 * np.exp(t) * g, -0.5, 0.5)    # dL/d log λ = λ dL/dλ, paso acotado
    t -= paso
    pasos += 1
    if abs(paso) < 1e-8:
        break
lam_opt = np.exp(t)
print(f"descenso en log λ: {pasos} pasos")
grid = np.logspace(-3, 3, 601)
lam_grid = grid[np.argmin([val_loss(w_star(l)) for l in grid])]
print(f"λ por hipergradiente: {lam_opt:.4f}   λ por rejilla de 601 valores: {lam_grid:.4f}")
print(f"pérdida de validación: λ = 0.01 → {val_loss(w_star(1e-2)):.4f},  óptimo → {val_loss(w_star(lam_opt)):.4f}")

The implicit hypergradient agrees with finite differences except for the final printed digit (relative error 4⋅10−94\cdot 10^{-9}, that of the differences themselves). Unrolling is instructive: with 10 steps the hypergradient has the wrong sign, and with 100 it has the right sign but is almost ten times too small, because it differentiates wT\vb{w}_T, which for small TT has barely begun to move, not w∗\vb{w}^*. With condition number 90, descent rate is 0.9890.989 per step, and roughly a thousand steps are needed for unrolling to resemble implicit, which costs one linear system. Descent in log⁡λ\log\lambda reaches the optimum in 44 hypergradient evaluations and matches the 601-point grid within its resolution.

Finally, a fixed-point layer z∗=tanh⁡(Wz∗+Ux+b)\vb{z}^* = \tanh(\mat{W}\vb{z}^* + \mat{U}\vb{x} + \vb{b}) with hidden dimension 40, its implicit backward pass (by linear system and adjoint iteration), and comparison with backpropagation through KK unrolled iterations.

[ ]Equilibrium layer with implicit backward passBrowser
import numpy as np

rng = np.random.default_rng(1)
d, p = 40, 10                                    # dimensión oculta y de entrada
W = rng.normal(size=(d, d))
W *= 0.9 / np.linalg.norm(W, 2)                  # ‖W‖₂ = 0.9: contracción garantizada
U = rng.normal(size=(d, p)) / np.sqrt(p)
bias = 0.1 * rng.normal(size=d)
x = rng.normal(size=p)
target = rng.normal(size=d) * 0.5

def f(z, W, x):
    return np.tanh(W @ z + U @ x + bias)

def forward(W, x, tol=1e-12, max_iter=1000):
    z = np.zeros(d)
    for k in range(max_iter):
        z_new = f(z, W, x)
        if np.linalg.norm(z_new - z) < tol:
            return z_new, k + 1
        z = z_new
    return z, max_iter

def loss(z):
    return 0.5 * np.sum((z - target) ** 2)

def backward_implicito(z, W, gz, metodo="solve", tol=1e-12):
    """u = (I − Jᵀ)⁻¹ gz con J = diag(1 − z²) W; devuelve dL/dW, dL/dx y las iteraciones usadas."""
    Dg = 1 - z ** 2
    J = Dg[:, None] * W
    if metodo == "solve":
        u, its = np.linalg.solve(np.eye(d) - J.T, gz), 0
    else:                                         # punto fijo u ← Jᵀu + gz, misma tasa que el forward
        u, its = gz.copy(), 0
        while True:
            u_new = J.T @ u + gz
            its += 1
            if np.linalg.norm(u_new - u) < tol:
                u = u_new
                break
            u = u_new
    a = Dg * u                                    # gradiente respecto de la preactivación
    return np.outer(a, z), U.T @ a, its

z, k_fw = forward(W, x)
gW, gx, _ = backward_implicito(z, W, z - target)
_, gx_fp, k_bw = backward_implicito(z, W, z - target, metodo="punto fijo")
print(f"forward: {k_fw} iteraciones   backward por punto fijo: {k_bw} iteraciones")
print(f"|gx(solve) − gx(punto fijo)| = {np.linalg.norm(gx - gx_fp):.1e}")

# comprobación con diferencias finitas (re-resolviendo el punto fijo)
h = 1e-6
fd_x = np.array([(loss(forward(W, x + h * e)[0]) - loss(forward(W, x - h * e)[0])) / (2 * h) for e in np.eye(p)])
E = np.zeros_like(W); E[3, 7] = 1
fd_W37 = (loss(forward(W + h * E, x)[0]) - loss(forward(W - h * E, x)[0])) / (2 * h)
print(f"dL/dx: error relativo frente a diferencias {np.linalg.norm(gx - fd_x) / np.linalg.norm(fd_x):.1e}")
print(f"dL/dW[3, 7]: implícito {gW[3, 7]:.10f}   diferencias {fd_W37:.10f}")

# desenrollar K iteraciones y retropropagar a través de todas ellas
def desenrollado(W, x, K):
    zs = [np.zeros(d)]
    for _ in range(K):
        zs.append(f(zs[-1], W, x))                # guarda K activaciones de tamaño d
    gz, gx = zs[-1] - target, np.zeros(p)
    for k in range(K, 0, -1):
        a = gz * (1 - zs[k] ** 2)
        gx += U.T @ a
        gz = W.T @ a
    return gx, K * d

rho = max(abs(np.linalg.eigvals((1 - z ** 2)[:, None] * W)))
print(f"radio espectral de J en z*: {rho:.3f}")
for K in [5, 10, 20, 40, 80]:
    g_u, mem = desenrollado(W, x, K)
    print(f"K = {K:3d}: error relativo {np.linalg.norm(g_u - gx) / np.linalg.norm(gx):.1e}   activaciones guardadas {mem:5d}   (implícito: {d})")

Forward and adjoint iteration need almost the same number of iterations (27 and 29), as predicted by both converging at rate ρ(J)=0.37\rho(\mat{J}) = 0.37, and give the same gradient as the linear system to 10−1310^{-13}. Finite differences confirm it. Unrolling converges to the implicit gradient at the same rate, but stores K⋅dK\cdot d activations instead of dd; here ρ\rho is small and 30 iterations suffice to reach 10−1310^{-13}, but near the stability edge, with ρ=0.95\rho = 0.95, about 600 would be needed (0.95600≈4⋅10−140.95^{600} \approx 4\cdot 10^{-14}).

With libraries: a DEQ layer in PyTorch

In PyTorch the pattern is a custom autograd function. Forward solves the fixed point without a graph (torch.no_grad), so the dynamic graph stores no iterations. Backward reconstructs one layer application with a graph and solves adjoint system u=g+J⊤u\vb{u} = \vb{g} + \mat{J}\T\vb{u} by fixed point, obtaining each J⊤u\mat{J}\T\vb{u} as an autograd VJP without ever forming J\mat{J}. Finally another VJP carries u\vb{u} to parameters. The cell checks backward with gradcheck, compares memory with unrolling 60 iterations, and trains the model on a synthetic classification problem.

[ ]DEQ layer with implicit backward pass in PyTorchLocal GPU
import math
import time
import warnings
import numpy as np
import torch
import torch.nn as nn

warnings.filterwarnings("ignore", message="Attempting to run cuBLAS")
torch.manual_seed(0)
dev = torch.device("cuda" if torch.cuda.is_available() else "cpu")

def solve_punto_fijo(g, z0, tol=1e-6, max_iter=200):
    """Itera z ← g(z) hasta que el residuo relativo baja de tol."""
    z = z0
    for k in range(max_iter):
        z_new = g(z)
        if (z_new - z).norm() <= tol * (1e-8 + z_new.norm()):
            return z_new, k + 1
        z = z_new
    return z, max_iter

ITERS = []                                            # iteraciones de cada forward y cada backward

class PuntoFijo(torch.autograd.Function):
    """z* = tanh(z* Wᵀ + inj): forward sin grafo, backward implícito resolviendo u = g + Jᵀu."""

    @staticmethod
    def forward(ctx, inj, W):
        with torch.no_grad():
            z, k = solve_punto_fijo(lambda z: torch.tanh(z @ W.T + inj), torch.zeros_like(inj))
        ctx.save_for_backward(z, inj, W)
        ITERS.append(k)
        return z

    @staticmethod
    def backward(ctx, grad_z):
        z, inj, W = ctx.saved_tensors
        with torch.enable_grad():
            z = z.detach().requires_grad_()
            inj_ = inj.detach().requires_grad_()
            W_ = W.detach().requires_grad_()
            fz = torch.tanh(z @ W_.T + inj_)           # una sola aplicación de la capa, con grafo
            # u = grad_z + Jᵀu, con Jᵀu calculado como VJP de f respecto de z
            vjp = lambda u: torch.autograd.grad(fz, z, u, retain_graph=True)[0]
            u, k = solve_punto_fijo(lambda u: grad_z + vjp(u), grad_z)
            ITERS.append(k)
            g_inj, g_W = torch.autograd.grad(fz, (inj_, W_), u)
        return g_inj, g_W

class DEQ(nn.Module):
    def __init__(self, d_in, d, n_cls, implicito=True, K=None):
        super().__init__()
        self.U = nn.Linear(d_in, d)
        self.W = nn.Parameter(torch.randn(d, d) * 0.5 / math.sqrt(d))
        self.head = nn.Linear(d, n_cls)
        self.implicito, self.K = implicito, K

    def capa(self, x):
        inj = self.U(x)
        if self.implicito:
            return PuntoFijo.apply(inj, self.W)
        z = torch.zeros_like(inj)
        for _ in range(self.K):                       # desenrollado: autograd guarda las K iteraciones
            z = torch.tanh(z @ self.W.T + inj)
        return z

    def forward(self, x):
        return self.head(self.capa(x))

    @torch.no_grad()
    def proyectar(self, cota=0.9):
        """Mantiene ‖W‖₂ ≤ cota para que la capa siga siendo una contracción."""
        s = torch.linalg.matrix_norm(self.W, ord=2)
        if s > cota:
            self.W.mul_(cota / s)

# 1) el backward implícito pasa gradcheck (en doble precisión)
m = DEQ(2, 16, 3).double().to(dev)
x = torch.randn(8, 2, dtype=torch.double, device=dev)
inj = m.U(x).detach().requires_grad_()
W = m.W.detach().clone().requires_grad_()
ok = torch.autograd.gradcheck(lambda a, b: PuntoFijo.apply(a, b), (inj, W), eps=1e-6, atol=1e-4)
print("gradcheck del backward implícito:", ok)

# 2) memoria: implícito frente a desenrollar K = 60 iteraciones (lote 1024, d = 1024)
def pico_memoria(implicito):
    torch.manual_seed(0)
    net = DEQ(64, 1024, 10, implicito=implicito, K=60).to(dev)
    xb = torch.randn(1024, 64, device=dev)
    yb = torch.randint(0, 10, (1024,), device=dev)
    torch.cuda.synchronize(); torch.cuda.reset_peak_memory_stats()
    base = torch.cuda.memory_allocated()
    t0 = time.perf_counter()
    loss = nn.functional.cross_entropy(net(xb), yb)
    loss.backward()
    torch.cuda.synchronize()
    dt = time.perf_counter() - t0
    pico = (torch.cuda.max_memory_allocated() - base) / 2**20
    return pico, dt, net.W.grad.clone()

if dev.type == "cuda":
    pico_memoria(True)                                 # calentamiento
    mem_i, t_i, g_i = pico_memoria(True)
    mem_u, t_u, g_u = pico_memoria(False)
    cos = torch.nn.functional.cosine_similarity(g_i.flatten(), g_u.flatten(), dim=0).item()
    print(f"memoria pico: implícito {mem_i:.0f} MiB   desenrollado K=60 {mem_u:.0f} MiB")
    print(f"tiempo forward+backward: implícito {t_i*1e3:.0f} ms   desenrollado {t_u*1e3:.0f} ms")
    print(f"similitud coseno entre los dos gradientes de W: {cos:.6f}")
else:
    print("sin GPU: se omite la medida de memoria")

# 3) entrenar en tres espirales entrelazadas (datos sintéticos)
def espirales(n, ruido=0.15, seed=0):
    g = np.random.default_rng(seed)
    X, Y = [], []
    for c in range(3):
        t = np.sqrt(g.random(n)) * 3.5
        ang = t + 2 * np.pi * c / 3
        X.append(np.c_[t * np.cos(ang), t * np.sin(ang)] + ruido * g.normal(size=(n, 2)))
        Y.append(np.full(n, c))
    return torch.tensor(np.vstack(X), dtype=torch.float32), torch.tensor(np.concatenate(Y))

Xtr, Ytr = espirales(400, seed=0)
Xte, Yte = espirales(400, seed=1)
Xtr, Ytr, Xte, Yte = Xtr.to(dev), Ytr.to(dev), Xte.to(dev), Yte.to(dev)
torch.manual_seed(0)
net = DEQ(2, 64, 3).to(dev)
opt = torch.optim.Adam(net.parameters(), lr=1e-2)
t0 = time.perf_counter()
ITERS.clear()
for it in range(300):
    opt.zero_grad()
    loss = nn.functional.cross_entropy(net(Xtr), Ytr)
    loss.backward()
    opt.step()
    net.proyectar()
iters = ITERS[::2]                                    # forward y backward se registran alternados
with torch.no_grad():
    acc = (net(Xte).argmax(1) == Yte).float().mean().item()
    s = torch.linalg.matrix_norm(net.W, ord=2).item()
print(f"300 pasos en {time.perf_counter() - t0:.1f} s   iteraciones del forward: {iters[0]} al principio, {iters[-1]} al final")
print(f"pérdida final {loss.item():.3f}   exactitud en test {acc:.3f}   ‖W‖₂ = {s:.3f}")
This cell needs the local lab (PyTorch with your GPU). Start it with npm run lab and open the connection link.

Three things to observe in the output. Peak memory for unrolling is around 60 times one activation (1024×10241024 \times 1024 four-byte numbers, 4 MiB each), whereas implicit memory does not depend on iteration count. The two gradients agree (cosine similarity 1 to six digits), because with small ∥W∥2\norm{\mat{W}}_2 60 iterations are more than enough. During training forward goes from about 15 iterations to about 40, because the optimizer pushes ∥W∥2\norm{\mat{W}}_2 against the projection bound: the layer becomes more expressive and simultaneously slower to solve, the tension real DEQs manage by regularizing the Jacobian.

Common mistakes

Exercises

NumericSlope of the folium
Descartes' folium x3+y3=3xyx^3 + y^3 = 3xy passes through (3/2,3/2)(3/2, 3/2). Calculate the curve's slope dy/dxdy/dx there.
QuizWhere y = g(x) fails on the lemniscate
At which points of lemniscate (x2+y2)2=x2−y2(x^2 + y^2)^2 = x^2 - y^2 can the curve not be expressed as graph y=g(x)y = g(x) in any neighborhood?
NumericDeterminant of the local inverse
Let f(x,y)=(x2−y2,2xy)f(x, y) = (x^2 - y^2, 2xy) and gg be the local inverse of ff defined near f(1,2)=(−3,4)f(1, 2) = (-3, 4) with g(−3,4)=(1,2)g(-3, 4) = (1, 2). Calculate det⁡Dg(−3,4)\det Dg(-3, 4).
NumericDerivative of scalar ridge
A ridge regression with one feature has ∑ixi2=4\sum_i x_i^2 = 4 and ∑ixiyi=6\sum_i x_iy_i = 6, so w∗(λ)=6/(4+λ)w^*(\lambda) = 6/(4 + \lambda). Calculate dw∗/dλdw^*/d\lambda at λ=2\lambda = 2 using the argmin formula, without differentiating the closed form.
ProofThe implicit function from the inverse
Prove: Let F:Rn×Rp→RnF: \R^n \times \R^p \to \R^n be of class C1C^1 with F(x0,θ0)=0F(\vb{x}_0, \theta_0) = \vb{0} and ∂F/∂x(x0,θ0)\partial F/\partial\vb{x}(\vb{x}_0, \theta_0) invertible. Then a function C1C^1, x(θ)\vb{x}(\theta), exists near θ0\theta_0, with x(θ0)=x0\vb{x}(\theta_0) = \vb{x}_0, F(x(θ),θ)=0F(\vb{x}(\theta), \theta) = \vb{0}, unique near x0\vb{x}_0, and Dx=−[∂F/∂x]−1∂F/∂θD\vb{x} = -[\partial F/\partial\vb{x}]^{-1}\partial F/\partial\theta.
0
Consider augmented map G:Rn×Rp→Rn×RpG: \R^n \times \R^p \to \R^n \times \R^p, G(x,θ)=(F(x,θ),θ)G(\vb{x}, \theta) = (F(\vb{x}, \theta), \theta).

Step 1 of 5. Why can the inverse function theorem be applied to GG at (x0,θ0)(\vb{x}_0, \theta_0)?

ProofThe argmin derivative
Prove: Let g:Rn×Rp→Rg: \R^n \times \R^p \to \R be of class C2C^2 and x∗(θ)\vb{x}^*(\theta) a minimizer of g(⋅,θ)g(\cdot, \theta) with ∇xx2g(x∗(θ0),θ0)\grad^2_{\vb{x}\vb{x}}g(\vb{x}^*(\theta_0), \theta_0) positive definite. Then, near θ0\theta_0, dx∗/dθ=−[∇xx2g]−1∇xθ2gd\vb{x}^*/d\theta = -[\grad^2_{\vb{x}\vb{x}}g]^{-1}\grad^2_{\vb{x}\theta}g.
0
Write x0=x∗(θ0)\vb{x}_0 = \vb{x}^*(\theta_0).

Step 1 of 4. Which equation does the minimizer satisfy?

QuizWhen the Hessian vanishes
Let g(x,θ)=x44−θx22g(x, \theta) = \frac{x^4}{4} - \frac{\theta x^2}{2}. For θ<0\theta < 0 the unique minimizer is x∗=0x^* = 0. What happens on crossing θ=0\theta = 0?
QuizBackward pass of an equilibrium layer
A layer computes z∗=fθ(z∗,x)\vb{z}^* = f_\theta(\vb{z}^*, \vb{x}) and training uses the implicit gradient. Which statements are correct?

More than one answer may be correct.

NumericThe dimension of O(4)
Orthogonal group O(n)={Q∈Rn×n:Q⊤Q=I}O(n) = \{\mat{Q} \in \R^{n\times n} : \mat{Q}\T\mat{Q} = \mat{I}\} is a regular level set of F(Q)=Q⊤QF(\mat{Q}) = \mat{Q}\T\mat{Q}, with values in symmetric matrices. What is the dimension of O(4)O(4) as a submanifold of R16\R^{16}?
CodeImplicit gradient with an adjoint system
Implement implicit_grad(F, x_star, theta, dL_dx). F(x, theta) returns an array of shape (n,), x_star (shape (n,)) satisfies F(x_star, theta) = 0, and dL_dx is the gradient of a scalar loss with respect to x. Return dL/dθdL/d\theta (shape (p,)) for implicit function x∗(θ)\vb{x}^*(\theta), computing Jacobians ∂F/∂x\partial F/\partial\vb{x} and ∂F/∂θ\partial F/\partial\theta by centered finite differences and solving one adjoint linear system without inverting matrices. Tests compare with finite differences of loss obtained by re-solving the system with scipy.optimize.root, in linear and nonlinear systems with p≠np \neq n.
import numpy as np

def implicit_grad(F, x_star, theta, dL_dx):
  """dL/dθ para x*(θ) definido por F(x*, θ) = 0, con un único sistema lineal adjunto."""
  x_star = np.asarray(x_star, dtype=float)
  theta = np.asarray(theta, dtype=float)
  # tu código: jacobianos numéricos ∂F/∂x (n×n) y ∂F/∂θ (n×p), sistema adjunto y VJP
  return np.zeros_like(theta)
Shift+Enter to run

Summary

Key idea
If the linear part of an equation is invertible, the equation can be solved locally and its solution differentiated by solving a linear system with that same linear part: ∂x∗/∂θ=−Fx−1Fθ\partial\vb{x}^*/\partial\theta = -\mat{F}_{\vb{x}}^{-1}\mat{F}_\theta, which in adjoint mode is one system Fx⊤u=∇L\mat{F}_{\vb{x}}\T\vb{u} = \nabla L, regardless of how the solution was obtained or how many parameters there are.
  • Inverse function. If ff is C1C^1 and Df(a)Df(\vb{a}) invertible, ff is a local diffeomorphism around a\vb{a} with Dg=(Df∘g)−1Dg = (Df\circ g)^{-1}. The proof is a contraction, x↦x+Df(a)−1(y−f(x))\vb{x} \mapsto \vb{x} + Df(\vb{a})^{-1}(\vb{y} - f(\vb{x})), also Newton’s method with a frozen Jacobian. The result is local: z↦z2z \mapsto z^2 and z↦ezz \mapsto e^z show this.
  • Implicit function. If F(x0,θ0)=0F(\vb{x}_0, \theta_0) = \vb{0} and ∂F/∂x\partial F/\partial\vb{x} is invertible, the equation defines a unique x(θ)\vb{x}(\theta) of class C1C^1 near (x0,θ0)(\vb{x}_0, \theta_0). It follows from the previous theorem applied to (x,θ)↦(F,θ)(\vb{x}, \theta) \mapsto (F, \theta). In the plane, curve F=0F = 0 is locally y=g(x)y = g(x) where Fy≠0F_y \neq 0, with slope −Fx/Fy-F_x/F_y; the condition is sufficient, not necessary.
  • Implicit differentiation. Tangent mode solves with Fx\mat{F}_{\vb{x}} and adjoint mode with Fx⊤\mat{F}_{\vb{x}}\T. The matrix is never inverted or formed: Jacobian-vector products suffice, and solutions must converge or the gradient is biased.
  • Argmin. Applied to ∇xg=0\nabla_{\vb{x}}g = \vb{0} with positive-definite Hessian: dx∗/dθ=−[∇xx2g]−1∇xθ2gd\vb{x}^*/d\theta = -[\grad^2_{\vb{x}\vb{x}}g]^{-1}\grad^2_{\vb{x}\theta}g. This is the hypergradient of ridge, iMAML and bilevel optimization; optimal value is even easier to differentiate (envelope).
  • Regular level sets. If DFDF has maximal rank on F=cF = \vb{c}, the set is a submanifold of dimension n−mn - m with tangent null⁡DF\nullsp DF and normal generated by gradients: the basis of Lagrange multipliers.
  • Implicit layers. DEQ, OptNet and hypergradients trade iteration-proportional memory for a linear system at the solution. Gradient existence requires I−J\mat{I} - \mat{J} invertible; iterative forward convergence also requires ρ(J)<1\rho(\mat{J}) < 1.