Automatic Differentiation of Algorithms