Computes a full Jacobian with forward-mode autodiff by sweeping over input directions. It returns the same values as jacrev(), but is usually better for tall Jacobians, where outputs outnumber inputs. section 4.2.5 section 4.3.2
Treat it as the forward-mode counterpart to jacrev(): one forward pass per input variable, with each pass contributing one Jacobian column. The treatment stops short of autodiff implementation internals. section 4.3.2 section 4.4
Use it when the Jacobian shape suggests forward mode fits better:
- tall matrices, where outputs are significantly more numerous than inputs. section 4.2.5
- near-square matrices, where it is described as probably better. section 4.2.5
- functions with several inputs passed separately, using argnums to choose which parameter to differentiate. section 4.2.5
Vector-valued function Jacobian
For a two-output, three-input function, jacfwd(f)(jnp.array([3.0, 4.0, 5.0])) matches jacrev(f) and is measured faster in the example.
From Jacobian columns to Hessians
A Hessian can be built from jacfwd(grad(f)) or jacfwd(jacrev(f)), showing jacfwd() as a building block for higher-order derivatives.
