Tested Gradient function with LD0. Fixed typo in analytic gradient