Forward-mode differentiation is a method used in automatic differentiation. It is a technique that computes numerical derivatives by simultaneously performing elementary derivative operations while evaluating the function. The chain rule is used to update the derivative values at each step.
Let's now understand this concept with an example.
In order to break down functions into elementary steps, evaluation traces are constructed. These traces can be thought of as a record of the individual steps taken to obtain the final results. Let's take the following function as an example:
To construct the evaluation trace, we will substitute some variables inside the function at each step. To start with, let's substitute
The equation becomes:
Let's now substitute
The equation now becomes:
Finally, we substitute
Let’s now evaluate the function when
Let's set the initial conditions for the derivatives:
By setting the seed values for the derivatives of the variables (in this case,
Let's suppose we want to compute the partial derivative of
Let’s try to calculate the partial derivative of
Note: We will be using the following two expressions to represent the partial derivative of
: or .
substituting
substituting
The results of the partial derivatives of
For each intermediate variable, we calculate its derivative by applying derivative rules. Remember that the value of each intermediate variable depends only on the derivatives and values of previous variables.
Free Resources