Bring the mental model from Chain Rule; this page will reuse it instead of restarting from zero.
Calculus
Computation Graphs
A computation graph breaks a calculation into nodes so values flow forward and sensitivities flow backward.

Concept Structure
Computation Graphs
Start with the picture, metaphor, or geometric mechanism.
Make the objects explicit and connect them with notation.
Mirror the equations with runnable implementation details.
Manipulate the mechanism and watch the idea respond.
Learning map
Computation GraphsConceptual Bridge
What should feel connected as you move through this page.
A computation graph breaks a calculation into nodes so values flow forward and sensitivities flow backward.
The next edge should feel earned: use the demo prediction here before following Reverse-Mode Automatic Differentiation.
01
Intuition
Build the mental picture first so the rest of the page has something to attach to.
Suppose one intermediate value gets used twice. If , , and , then affects directly and also through . How should the derivative remember both uses without differentiating one huge expanded formula by hand?
A computation graph makes that bookkeeping visible.
Instead of treating a function as one large expression, we split it into small operations: multiply here, apply a nonlinearity, add there, reuse an intermediate value. Each operation becomes a node, and each dependency becomes an edge.
A computation graph is not just an expression tree. The expanded expression repeats . The graph stores once and records that two later operations depend on that same value.
This matters because the graph gives backpropagation a route. Values move forward through the graph to produce an output or loss. Derivatives move backward through the same graph, using local slopes on each edge. The chain rule stops feeling like one giant symbolic derivative and becomes bookkeeping over small local changes.
02
Math
Translate the story into symbols, assumptions, and a derivation you can inspect.
In this first example, every node is scalar. Let , and draw edges from inputs to the values that depend on them. The graph for one forward pass is a directed acyclic graph: later nodes depend on earlier nodes, not the other way around.
Consider the scalar computation
The graph has inputs , intermediate nodes , and output . The forward pass stores each node value. The important detail is reuse: is stored once, but two later uses depend on it. The backward pass asks how a small change in each node would affect the output.
For any node , write
The output seed is . The final add node sends one unit of sensitivity to both inputs:
The sine branch also sends a local contribution into the same stored node . The important invariant is local: a node's cotangent is the sum of contributions from each immediate downstream use. The demo hides the sine-branch contribution until you predict whether it will lower, preserve, or raise the direct baseline.
The backward pass does not expand every symbolic path; each downstream node has already summarized everything beyond it.
For vector or tensor nodes, the same idea uses Jacobians or local vector-Jacobian product rules. With column-vector cotangents, if and , the reverse update is
Reverse-mode autodiff is the automated version of this bookkeeping: save forward values, then run local backward rules in reverse topological order.
03
Code
Keep the implementation aligned with the notation so the algorithm is legible.
import math
x, y = 2.0, 3.0
# Forward pass: store intermediate node values.
a = x * y
b = math.sin(a)
c = a + b
# Reverse pass bookkeeping: every downstream use appends one local contribution.
bar_c = 1.0
bar_a = 0.0
bar_b = 0.0
bar_x = 0.0
bar_y = 0.0
# c = a + b sends one unit to both inputs.
bar_a += bar_c * 1.0
bar_b += bar_c * 1.0
# b = sin(a) sends another contribution into reused node a.
bar_a += bar_b * math.cos(a)
# a = x * y sends the accumulated sensitivity to x and y.
bar_x += bar_a * y
bar_y += bar_a * x
print("c:", round(c, 4))
print("stored a once:", a)
print("downstream uses of a:", ["direct add edge", "sine edge"])
print("bar_a:", round(bar_a, 4))
print("dc/dx:", round(bar_x, 4))
print("dc/dy:", round(bar_y, 4))
The code is deliberately manual. The += updates are the graph mechanism: a reused node collects every downstream local contribution before sending its accumulated sensitivity to its own inputs.
04
Interactive Demo
Use direct manipulation to connect the explanation to a moving system.
Use the sliders to change and . In Forward mode, watch the stored value feed both and the final add node .
Before switching into the backward numbers, predict whether the hidden accumulated sensitivity at the reused node should land lower than, nearly equal to, or higher than the direct contribution from .
Use Case A and Case B as neutral graph states. Commit first, then reveal how the downstream paths combine before sends sensitivity back to and .
Live Concept Demo
Explore Computation Graphs
The stage is code-native and interactive. Use it to test the explanation against the mechanism.
Manipulate one control and predict the visible change.
Commit to what Computation Graphs should make visible before reading the result.
After The First Pass
Turn the concept into an inspected object.
Once the invariant is visible in the intuition, math, code, and demo, use these panels to inspect the mechanism visually, check source support, practice the idea, and attach a grounded research question.
Mechanism Storyboard
See the idea move before the page explains it
A computation graph breaks a calculation into nodes so values flow forward and sensitivities flow backward.

Start with the picture, metaphor, or geometric mechanism.
Before reading further, choose the kind of change Computation Graphs should make visible.
Visual Inquiry
Make the image answer a mathematical question
A computation graph breaks a calculation into nodes so values flow forward and sensitivities flow backward.
Which visible object should carry the first intuition?
Pick the cue that should make Computation Graphs easier to reason about before the page gives the answer.
Source Grounding
Canonical references for the mechanism on this page.
Grounds computation graphs as the program structure used by automatic differentiation systems.
Open sourceClaim Review
A computation graph breaks a calculation into nodes so values flow forward and sensitivities flow backward.
Claims without a substantive review badge still need exact source-support review.
baydin-2018-ad-survey
Use equation, code, and demo objects to check whether the source support is operational.
Baydin et al. describe AD over evaluation traces of elementary operations, computational graphs for dependency relations, and reverse mode as a forward pass that populates intermediate variables/records graph dependencies followed by reverse adjoint propagation; the page example a=xy instantiates reuse and additive accumulation.
Sources: Automatic differentiation in machine learning: a surveyCovers differentiable primitives in one executed DAG/program trace and local scalar/vector-VJP teaching model, not symbolic simplification, mutation/aliasing, checkpointing policy, nonsmooth primitives, or every static/dynamic control-flow convention.A bounded review summary is present; still check caveats and exact source scope.Checked Baydin et al. for one executed AD trace: programs become elementary-operation traces and graphs of intermediate-variable dependencies; reverse mode runs code forward, populates intermediates, records dependencies, then propagates adjoints backward; a reused variable's adjoint sums downstream contributions before input derivatives are obtained. Local math/code/demo instantiate a=xy,b=sin(a),c=a+b with one stored a, direct + sine-path cotangent accumulation, and propagation to x,y.
Reviewer: codex+oracle; reviewed 2026-05-07Practice Loop
Try the idea before it explains itself
A computation graph breaks a calculation into nodes so values flow forward and sensitivities flow backward.
Before touching the demo, predict one visible change that should happen in Computation Graphs.
Reveal when your model needs a nudge.
Reveal when your model needs a nudge.
Reveal when your model needs a nudge.
A concrete answer is on the canvas.
The answer names why the claim should hold.
It touches the page context or a neighboring idea.
Research Room
Attach the question to an exact object
Pick the concept, equation, source, code witness, claim, misconception, or demo state before asking for help. The handoff stays grounded to that object.Open the draft below to save one note and next action in this browser.
Computation Graphs
What is the smallest example that makes Computation Graphs click without losing the math?
Local action draftNo local draft saved yetExpand only when ready to capture one local next action
This draft stays locally in this browser for concept:calculus/computation-graphs.
- Source ids to inspect: baydin-2018-ad-survey
- Definition, prerequisite, and contrast concept links
- The equation or code witness that makes the concept operational
- One demo state that shows the invariant instead of a slogan
- The learner can state the mechanism in their own words
- The learner can name the prerequisite that would repair confusion
- The learner can predict how the mechanism changes under one perturbation
I am working in Continuous Function's research reading room. Object: concept - Computation Graphs Object key: concept:calculus/computation-graphs Context: Calculus Anchor id: concept/concept-notebook/calculus/computation-graphs Open question: What is the smallest example that makes Computation Graphs click without losing the math? Evidence to inspect: - Source ids to inspect: baydin-2018-ad-survey - Definition, prerequisite, and contrast concept links - The equation or code witness that makes the concept operational - One demo state that shows the invariant instead of a slogan What would resolve this: - The learner can state the mechanism in their own words - The learner can name the prerequisite that would repair confusion - The learner can predict how the mechanism changes under one perturbation Answer as a careful research tutor: stay source-grounded, separate verified evidence from assumptions, name the relevant math objects, and end with one next action.
concept/concept-notebook/calculus/computation-graphs
concept:calculus/computation-graphs