Why Draw a Dependency Graph?
A composed function can depend on an input in more than one way. An input might appear explicitly in the final formula, affect an intermediate variable, or do both. When the expression has several layers, it is easy to overlook one of these routes or count it twice.
A dependency graph makes the structure visible. Its nodes represent variables or functions, and a directed arrow from one node to another records that the second quantity is defined using the first. To study a derivative with respect to a chosen input, trace the directed routes from that input to the output.
The graph organizes the calculation; it does not replace the derivative rules. A route indicates a possible contribution, while the local derivatives along that route determine its numerical contribution. A route can contribute zero at a particular point, and contributions from different routes can cancel.
Reading Direct and Indirect Dependence
Suppose \(w=g(x,y)\), and the output is \(F=H(x,w)\). The graph has arrows \(x\to w\), \(y\to w\), \(x\to F\), and \(w\to F\). The arrow \(x\to F\) represents the output's explicit use of \(x\), with \(w\) held fixed. The route \(x\to w\to F\) represents the effect of changing \(x\) through \(w\).
Thus \(x\) has both a direct route and an indirect route to \(F\). By contrast, \(y\) has no direct arrow to \(F\), but it can still affect \(F\) through \(w\). This distinction is about the structure of the formula: it does not by itself say whether the derivative is nonzero at a particular point.
For a derivative with respect to a chosen input, include every directed path from that input to the output. For each path, multiply the local derivative factors along its arrows; then add the contributions from all such paths. The local derivative on an arrow is the partial derivative of the destination quantity with respect to the source quantity, holding its other listed inputs fixed.
Worked Example: Two Indirect Routes
Worked Example: Two Indirect Routes
Let \(u=x^2+y\), \(v=xy\), and \(F=u^2+3v\). Find \(F_x\) at \((x,y)=(1,2)\) using the dependency graph.
There is no direct arrow from \(x\) to \(F\). There are two routes from \(x\): one through \(u\), and one through \(v\). The local derivatives are
At \((1,2)\), the intermediate values are
The route through \(u\) contributes \(F_u u_x=(2\cdot3)(2\cdot1)=6\cdot2=12\). The route through \(v\) contributes \(F_v v_x=3\cdot2=6\). Adding the two route contributions gives
Check by substituting the definitions into \(F\): \(F(x,y)=(x^2+y)^2+3xy\). Differentiating gives \(F_x=4x(x^2+y)+3y\), so \(F_x(1,2)=4(1)(3)+3(2)=12+6=18\), as required.
Worked Example: One Direct and One Indirect Route
Worked Example: One Direct and One Indirect Route
Let \(w=x+y\) and \(F=xw+w^2\). Find \(F_x\) at \((1,2)\), separating its direct and indirect contributions.
The term \(xw\) gives \(F\) a direct dependence on \(x\); the route through \(w\) gives an additional indirect dependence. First evaluate \(w=1+2=3\). Holding \(w\) fixed, the direct local derivative is \(F_x=w=3\). The other local derivatives are \(F_w=x+2w=1+2(3)=7\) and \(w_x=1\). Therefore the indirect route contributes \(F_w w_x=7\cdot1=7\), and
As a check, substitute \(w=x+y\): \(F=x(x+y)+(x+y)^2\). Differentiating with respect to \(x\) gives \((x+y)+x+2(x+y)\). At \((1,2)\) this is \(3+1+6=10\). The explicit \(x\) in the first term supplies the direct contribution; the changing value of \(w\) supplies the indirect one.
Worked Example: Several Paths and Their Signs
Worked Example: Several Paths and Their Signs
Let \(p=x+y\), \(q=x-y\), and \(R=pq\). Use the graph to find \(R_y\) at \((2,1)\).
At the point, \(p=2+1=3\) and \(q=2-1=1\). The local derivatives on the two routes are \(p_y=1\), \(R_p=q=1\), \(q_y=-1\), and \(R_q=p=3\). The minus sign on the route through \(q\) matters: increasing \(y\) decreases \(q=x-y\). The route contributions are
Therefore \(R_y(2,1)=1-3=-2\). Check by substitution: \(R=(x+y)(x-y)=x^2-y^2\), so \(R_y=-2y\), and \(R_y(2,1)=-2(1)=-2\). Both routes are present, and their signed contributions add to the derivative.
Why Route Contributions Add
The path bookkeeping follows from the local linear approximation for a differentiable function. Consider the two-stage composition \(F(x)=H(x,w(x))\), where \(w\) is differentiable and \(H\) is differentiable in its two inputs. Write \(h\) for a small change in \(x\), and \(\Delta w=w(x+h)-w(x)\).
Differentiability of \(w\) gives \(\Delta w=w'(x)h+o(h)\). In particular, \(\Delta w\) is of order \(h\) as \(h\to0\).
Differentiability of \(H\) gives \(H(x+h,w+\Delta w)-H(x,w)=H_xh+H_w\Delta w+o(|h|+|\Delta w|)\), with partial derivatives evaluated at \((x,w(x))\).
Since \(\Delta w=w'(x)h+o(h)\), divide the output change by \(h\) and let \(h\to0\). The remainder divided by \(h\) tends to zero, so \(F'(x)=H_x+H_w w'(x)\).
The term \(H_x\) is the direct route \(x\to F\); the product \(H_w w'(x)\) is the indirect route \(x\to w\to F\). This argument explains why direct and indirect changes are added, and why derivatives along an indirect route are multiplied. With more intermediate nodes, the same local bookkeeping follows each arrow and accounts for every route.
Structural Dependence Is Not the Same as a Nonzero Derivative
An arrow records that a variable is used in a formula. It does not guarantee that the corresponding local derivative is nonzero everywhere. For example, if \(w=x^2\), then the graph contains \(x\to w\), even though \(w_x=2x=0\) at \(x=0\). The input has a structural route to \(w\), but its first-order effect vanishes at that point.
Different routes can also cancel. For \(R=(x+y)-(x-y)\), the graph has two routes from \(x\) to \(R\), one through each parenthesized quantity. Their local contributions are \(1\cdot1=1\) and \((-1)\cdot1=-1\), giving \(R_x=0\). Indeed, substitution gives \(R=2y\), which does not vary with \(x\). Thus a graph identifies possible routes; local derivatives and their sum decide the actual derivative.
A Common Mistake: Following Only One Route
In the second worked example, a tempting but incorrect calculation is to include only the indirect route and write \(F_x=F_w w_x=7\). This omits the direct arrow \(x\to F\), whose contribution is \(3\). The corrected calculation includes both: \(F_x=3+7=10\). A graph is useful precisely because it makes the omitted route visible before the calculation begins.
A different mistake is to treat every arrow as a guarantee of a positive contribution. The third example has a negative local derivative \(q_y=-1\), so that route contributes \(-3\), not \(+3\). Preserve the signs of local derivatives when multiplying along a route.
Using a Dependency Graph Reliably
Before differentiating, write down the definitions of the intermediate quantities and the output. Draw an arrow whenever one definition uses another quantity. Then fix the input whose derivative is requested and trace all paths from it to the output. For each path, record the local derivatives in order, multiply them, and add the results. If there is no path, the formula has no structural dependence along the graph on that input. Finally, check the result by substituting the intermediate definitions into the output when that is practical.
These checks are especially useful in longer compositions. A variable can enter at several stages, the same intermediate node can feed into several later quantities, and a derivative can have positive, negative, or zero contributions. Drawing the graph first turns these possibilities into an explicit list rather than leaving them to visual inspection of a long formula.
Check Your Understanding
For each question, identify the relevant routes before calculating.
- If \(u=x+y\) and \(F=u^3\), what route connects \(y\) to \(F\), and what are the local derivatives along it?
- If \(F=xw+w^2\) with \(w=x+y\), which route gives the direct contribution to \(F_x\), and which gives the indirect contribution?
- Can a directed path from an input to an output exist even when the derivative at a particular point is zero? Explain briefly.
- For \(p=x+y\), \(q=x-y\), and \(R=pq\), list the two routes from \(y\) to \(R\). Which route has a negative local derivative?
- Why must contributions from different routes be added with their signs rather than simply counted as positive effects?