I'm experimenting with running Gradient Descent (GD) on polynomials of some low degree - say 3 - with n variables, on a domain constrained by a hypercube [-1,1]^n. I want to compare the termination point of GD with the actual KKT point calculated with Sympy. For example, I have a Sympy expression with 3 variables a, b and c (that is n=3) like this:
0.2*a**3 - 0.1*a**2*b - 0.9*a**2*c + 0.5*a**2 - 0.1*a*b**2 - 0.4*a*b*c + 0.5*a*b - 0.6*a*c**2 - 0.5*a*c - 0.6*a - 0.1*b**3 + 0.4*b**2*c - 0.4*b**2 + 0.7*b*c**2 - 0.4*b*c + 0.9*b + 0.09*c**3 - 0.6*c**2 + 0.4*c + 0.22
What is the best, quickest way of finding all KKT points for this expressions with the constraints:
-1 <= a <= 1
-1 <= b <= 1
-1 <= c <= 1
(ideally the search would be limited only to the vicinity of the GD termination point to save computation time but I'm not sure how to do that rigorously)
Pre-compile the expression and its Jacobian to function objects, then pass them into
minimize. Note that it attempts to be somewhat smarter than your intended gradient descent which may or may not be helpful; this defaults to Kraft's sequential least-squares programming method.If you really want a symbolic solution to
awherebandcare equal to -1, you can then work backward, substitutingbandcinto the first Jacobian component and solving fora.