# 2. How the backpropagation algorithm works

Activation $a^l_j$ of the neuron in the l layer is related by:
Vectorization will simply it as:
The goal of backpropagation is to compute the partial derivatives of the cost function with respect to any weight or bias in the network.
Two assumptions are the cost function is:
• an average over individual cost function
• a function of the output activations from the neural network.
The error of a neuron is defined as:
where z is the weighted output. We didn’t use to have a simpler math.

## backpropagation based on 4 fundamental equations

1. error in the output layer(last layer): or
2. error connected to next layer:
3. error is the rate of change of the cost with respect to bias:
4. rate of change of the cost with respect to weight:
algorithm:
1. input x: get activation for input layer
2. Feedforward: get weighted input and activation for other layers
3. Output error: compute the error in the last layer by equation 1
4. Backpropagate the error: using equation 2
5. Output: get gradient of the cost function by equation 3 and 4.
The backward movement is a consequence of the fact that the cost is a cunction of outputs from the network.
The backpropagatino algorithm is a clever way of keeping track of small perturbation to the weights/biases as they propagate through the network, reach the output, and then affect the cost.