A robot-model calculation can reuse an intermediate value along several paths. Its derivative must include every path, even when the numerical value was computed only once. Automatic differentiation organizes this accounting by applying local derivative rules to the operations in a computation graph. Forward and reverse modes use the same chain rule, but propagate different kinds of seeds in opposite directions.
The distinction is more specific than saying that one method computes a derivative and the other computes a gradient. A forward seed describes an input direction. A reverse seed describes a weighting of outputs. This article constructs a small smooth polynomial graph so both operations can be checked by ordinary arithmetic. It reports no executed autodiff package, trained robot model, or measured optimization speed.
Define the graph and its values
Let the dimensionless inputs be x and y. Define a = xy, b = x + y, c = a squared, d = a + b, and F = c + d. The intermediate a is used twice: once by the square operation and once by the addition forming d. The resulting function is F(x,y) = x squared times y squared + xy + x + y.
At x = 2 and y = 3, the intermediate values are a = 6, b = 5, c = 36, and d = 11, giving F = 47. These are primal values: the ordinary calculation that is being differentiated. Both derivative passes below use this same evaluation point.
JAX's official guide defines a forward Jacobian-vector product and a reverse vector-Jacobian product. MIT's authored matrix-calculus notes explain derivative propagation and the different input/output dimensional costs. The graph and numerical seeds here are independently chosen rather than copied from either source.
Push an input direction forward
Choose the input tangent seed (x_dot, y_dot) = (1, -2). It describes the infinitesimal direction along the curve x(epsilon) = 2 + epsilon and y(epsilon) = 3 - 2 epsilon. It does not claim that x or y has already changed by those finite amounts.
Apply the product rule at a: a_dot = y x_dot + x y_dot = 3 - 4 = -1. Addition gives b_dot = x_dot + y_dot = -1. At the square node, c_dot = 2a a_dot = 12 times -1 = -12. Then d_dot = a_dot + b_dot = -2, and F_dot = c_dot + d_dot = -14.
One forward pass therefore returns the directional derivative -14. It does not separately return both partial derivatives. To obtain them by scalar forward sweeps, use the two coordinate seeds (1,0) and (0,1). They give 40 and 27 respectively. The original seed combines those results as 40 times 1 + 27 times -2 = -14.
Pull an output weighting backward
For the scalar output, start with F_bar = 1, meaning the objective being differentiated is F itself. The bars denote sensitivities of the final objective to intermediate values. Initialize other adjoints at zero and add each downstream contribution as the graph is traversed backward.
Since F = c + d, c_bar = 1 and d_bar = 1. The node d = a + b contributes 1 to a_bar and 1 to b_bar. The node c = a squared contributes another 2a c_bar = 12 to a_bar. Its total is therefore 13, not 12 and not 1.
Finally, a = xy contributes 13y = 39 to x_bar and 13x = 26 to y_bar. The node b = x + y contributes one more to each. Thus x_bar = 40 and y_bar = 27. Both partial derivatives emerge from this one scalar-output reverse seed.
The shared intermediate makes accumulation essential. Overwriting its adjoint with the most recently visited contribution would discard a valid dependency path. Storing a primal value once does not mean that its influence on the output occurs only once.
A vector output clarifies the dimensions
Add a second output G = x squared + y. At the same point, G = 7 and its gradient is (4,1). The Jacobian of the combined output (F,G), with outputs labeling rows and inputs labeling columns, is [[40,27],[4,1]].
The forward seed (1,-2) now gives J times the seed = (-14,2). The output tangent has two components because there are two outputs. Conversely, choose the output weighting w = (2,-1). Its reverse result is J transpose times w = (76,53). This is the gradient of the scalar combination 2F - G, not the full two-row Jacobian.
A seed of all ones similarly differentiates the sum of outputs. It does not somehow preserve each output's separate row. Explicit seed dimensions prevent a vector-valued function from being silently replaced by an unintended scalar objective.
Work and numerical meaning
To assemble a full Jacobian one direction at a time, forward mode needs input basis directions, while reverse mode needs output basis weightings. This dimensional distinction often favors reverse mode for many inputs and one output. It is not a universal wall-clock guarantee: graph structure, batching, saved intermediates, and implementation overhead also matter.
Forward mode can carry tangents alongside primal operations. Reverse mode normally needs intermediate information from the primal pass, whether saved or recomputed, before local rules can be evaluated backward. The arithmetic in this example makes those values visible instead of presenting an unexplained API result.
Unlike a finite-difference quotient, these passes do not choose a small step size or subtract nearby function evaluations. They apply exact local derivative identities; finite-precision arithmetic can still introduce rounding. They differentiate the specified smooth computation, which does not establish that its equations accurately represent a physical robot. The graph, evaluation point, seed, and desired output are all part of the derivative question.
Sources checked October 24, 2026:
JAX: Forward- and reverse-mode autodiff: https://docs.jax.dev/en/latest/jacobian-vector-products.html
MIT 18.S096: Forward and Reverse-Mode Automatic Differentiation: https://ocw.mit.edu/courses/18-s096-matrix-calculus-for-machine-learning-and-beyond-january-iap-2023/mit18_s096iap23_lec08.pdf
Concept illustration: Generic robot and laptop imagery provides robotics context. It does not depict these invented inputs, an executed algorithm, or a measured system result.