Backpropagation computes for a layered model by applying the chain-rule from the output backwards.

With and :

Cost is about one extra forward pass, because each reuses . The result feeds gradient-descent for neural-networks.