Differentiate
\[\begin{equation*} f(x, y) = (x + y) (y + 3) \end{equation*} \]
at
\[\begin{align*} x & = 1 \\ y & = 2 \end{align*} \]
with respect to \(x\) and \(y\).
Compute forward
\[\begin{align*} a & = x + y = 1 + 2 = 3 \\ b & = y + 3 = 2 + 3 = 5 \\ c & = ab = 3 \cdot 5 = 15 \end{align*} \]
getting
\[\begin{equation*} f(x) = c = 15. \end{equation*} \]
Using cached \(a\), \(b\), and \(c\), we proceed backward:
\[\begin{align*} \pdv{c}{a} & = \pdv{a} ab = \pdv{a} 5a \eval{}_{b = 5} = 5 \\[1ex] \pdv{c}{b} & = \pdv{b} ab = \pdv{b} 3b \eval{}_{a = 3} = 3 \end{align*} \]
\[\begin{align*} \pdv{a}{x} & = \pdv{x} (x + y) = \pdv{x} (x + 2) \eval{}_{y = 2} = 1 \\[1ex] \pdv{a}{y} & = \pdv{y} (x + y) = \pdv{x} (1 + y) \eval{}_{x = 1} = 1 \end{align*} \]
\[\begin{align*} \pdv{b}{x} & = \pdv{x} (y + 3) = \pdv{x} (2 + 3) \eval{}_{y = 2} = 0 \\[1ex] \pdv{b}{y} & = \pdv{y} (y + 3) = \pdv{x} (y + 3) \eval{}_{x = 1} = 1 \end{align*} \]
\[\begin{align*} \pdv{c}{x} & = \pdv{c}{a} \pdv{a}{x} + \pdv{c}{b} \pdv{b}{x} = 5 \cdot 1 + 3 \cdot 0 = 5 \\[1ex] \pdv{c}{y} & = \pdv{c}{a} \pdv{a}{y} + \pdv{c}{b} \pdv{b}{y} = 5 \cdot 1 + 3 \cdot 1 = 8 \end{align*} \]