This post covers the mathematical foundation of Backpropagation Calculus, explaining step-by-step how gradients flow backwards through a neural network using the multivariable chain rule.

Table of contents
Open Table of contents
What is Backpropagation Calculus?

Backpropagation is the foundational algorithm that computes the gradient of the cost function . The entries of this gradient vector represent the partial derivatives of the cost function with respect to every weight () and bias () throughout the network:
Calculating these partial derivatives quantifies how sensitive the networkโs total error is to small perturbations in each parameter, enabling Gradient Descent to systematically update parameters in the direction of steepest descent: (where is the learning rate).
1. Simple Case: One Neuron per Layer
To understand the calculus intuitively, consider a simplified network where each layer contains a single neuron.
Figure 1: A simplified neural network architecture with one neuron per layer.
Figure 2: Parameters ( and ) defining connections and activation thresholds between consecutive neurons.
For a single training sample with desired target output :
- Weighted Input:
- Activation Output: (where is the activation function)
- Sample Cost: (the squared error loss)
The Chain Rule Breakdown
Figure 3: Computational dependency graph illustrating how determine , which computes activation , ultimately yielding cost .
To determine how a small change in weight impacts the cost , we apply the Multivariable Chain Rule:
Figure 4: Decomposing the partial derivative into three constituent derivative ratios.
Computing the Three Factors
-
Previous Activation Sensitivity:
(Reflects Hebbian learning: higher activation amplifies the weight changeโs effect on the weighted input).
-
Activation Function Gradient:
(Measures the local derivative/slope of the non-linear activation function).
-
Output Error Sensitivity:
(Proportional to the raw prediction error; larger errors induce steeper gradient updates).
Combining the Partial Derivatives
Multiplying these three factors yields the exact sensitivity for a single weight:
Similarly, for the bias , since :
2. Propagating Backwards to Hidden Layers
To compute gradients for parameters in earlier hidden layers (e.g., ), we first evaluate the costโs sensitivity to the previous activation :
By computing , we backward propagate the error signal layer-by-layer, efficiently evaluating derivatives for all preceding weights and biases.
3. Cost Over All Training Examples
The overall cost function across a full dataset of samples is the arithmetic mean:
By the linearity of differentiation, the derivative of total cost with respect to any parameter is the average of individual sample derivatives:
4. Generalizing to Multineuron Layers
In a general deep network with multiple neurons per layer:
- : Activation of neuron in layer .
- : Activation of neuron in layer .
- : Weight connecting neuron in layer to neuron in layer .
Figure 5: Indexing activations and alongside weight matrix entry across dense layers.
The weighted sum for neuron is:
Multiple Paths of Computational Influence
In fully connected layers, a single neuron in layer influences every neuron in layer . Consequently, changing affects the cost through multiple computation paths. By multivariate calculus, we sum the chain rule across all output neurons in layer :
Conclusion
Figure 6: Complete mathematical summary of backpropagation calculus formulas across layers.
Backpropagation boils down to three core principles:
- Chain Rule Engine: Applies the multivariable chain rule to calculate how sensitive the cost function is to every weight and bias.
- Backward Error Flow: Computes error signals starting from the output layer and propagates them backward through hidden layers.
- Vectorized Optimization: Aggregates partial derivatives into a gradient vector (), enabling modern frameworks to update parameters efficiently using Gradient Descent.