Dear all, I'm trying to find the maximum of a polynomial function G numerically over [0,1]x[0,1]. I used the simple code below and I got 0, which is clearly wrong as one can easily check plotting the surface z=G(x,y). Any help? Thanks, Nicola

var('x,y')
c1(x,y)=x
c2(x,y)=y
c3(x,y)=1-x
c4(x,y)=1-y

G(x,y) = -(56*x^2*y^2 - 4*x^2*y - 4*x*y^2 - 4*x^2 - x*y - 4*y^2 - x - y - 1)*(x - 1)*(y - 1)

M = minimize_constrained(-G(x,y), [c1(x,y),c2(x,y),c3(x,y),c4(x,y)],[0.5,0.5])

print(G(M[0],M[1]))

edit retag close merge delete

Sort by ยป oldest newest most voted

This is probably a bug in constraints handling of minimize_constrained :

sage: minimize_constrained(-G, [c1,c2,c3,c4],[1/2, 1/2])
(1.0, 0.5)


but

sage: minimize_constrained(-G, [[0, 1], [0, 1]],[1/2, 1/2])
(0.22201537463122323, 0.22201537463122367)


Could you report it to [sage-support)(https://groups.google.com/g/sage-support), and possibly file a ticket on Github ?

EDIT : Never mind : I filed a new issue related to this problem, where you can find an analytical solution to your problem.

more