A Case Study of Computational Differentiation Applied to Neutron Scattering.
In a neutron scattering application, an unconstrained nonlinear minimization problem is used for the fitting of model parameters to experimental data. Automatic differentiation enables, in a completely mechanical fashion, algorithmic changes by switching from a quasi-Newton method, where first order derivatives are approximated by finite differences, to a modified Gauss-Newton method using exact first order derivatives. Compared to the original code, the code generated by this black box approach produces reliable results rather than results of dubious quality and is also faster in terms of execution time. Its performance is improved further by replacing the most time-consuming subroutine involved in the derivative evaluation by a surprisingly simple, hand-coded implementation of the corresponding analytic expression.