#! /usr/bin/env python # def sag ( x ): #*****************************************************************************80 # ## sag is a test function with a minimizer near x=7. # # Licensing: # # This code is distributed under the GNU LGPL license. # # Modified: # # 01 October 2019 # # Input: # # real x: the argument. # # Output: # # real value: the function value. # import numpy as np value = x**2 * np.cos ( ( x + 3.0 * np.pi ) / 4.0 ) return value def sag_df ( x ): #*****************************************************************************80 # ## sag_df returns the derivative of the sag() function. # # Licensing: # # This code is distributed under the GNU LGPL license. # # Modified: # # 01 October 2019 # # Input: # # real x: the argument. # # Output: # # real value: the derivative value. # import numpy as np value = 2.0 * x * np.cos ( ( x + 3.0 * np.pi ) / 4.0 ) \ - x**2 * np.sin ( ( x + 3.0 * np.pi ) / 4.0 ) / 4.0 return value