Automatic Differentiation: Applications, Theory, and Implementations