I filed this issue <https://github.com/sagemath/sage/issues/38529> for your
question.
An analytical solution :
# Potential extrema : points where all first derivatives are zero. PE =
[{u:d[u].n() for u in d.keys()} for d in solve([G(x, y).diff(u) for u in
(x, y)], (x, y), solution_dict=True)] # Actual values of G var("val")
Vals=[d|{val:G(d[x],d[y]).n()} for d in PE] # Actual maxima [d for d in
Vals if d[val]==(Max:=max([d[val] for d in Vals]))]
gives
[{x: 0.500000000000000, y: 0.000000000000000, val: 1.25000000000000}, {x:
0.000000000000000, y: 0.500000000000000, val: 1.25000000000000}]
HTH,
Le lundi 19 août 2024 à 12:35:29 UTC+2, Nicola Sottocornola a écrit :
> Dear all,
>
> we want to find the maximum of the function G over [0,1]x[0,1]. The code
> below gives 0 which is clearly wrong.
>
> Using instead
>
> sage: minimize_constrained(-G, [[0, 1], [0, 1]],[1/2, 1/2])
> seems to provide the right answer...
>
> 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]))
>
--
You received this message because you are subscribed to the Google Groups
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/sage-support/fe15b9a2-ae63-4445-a3e8-a7b4a614314dn%40googlegroups.com.