CoCalc Shared FilesMax-Min-Hessien.sagews
Author: Juan Carlos Bustamante
Views : 5

## Exemple

### - Maximiser et minimiser $f$ sur $[0,3]\times [0,2]$.

var('x,y')
f(x,y) = x^4+y^4-4*x*y+1
C= contour_plot(f, (x,-3,3), (y,-3, 3),cmap='hot',contours = 20,linestyles='solid', fill=False, colorbar=True)
show(C)

($\displaystyle x$, $\displaystyle y$)
df = f.gradient()
df(x,y)


f.hessian()(x,y)

$\displaystyle \left(\begin{array}{rr} 12 \, x^{2} & -4 \\ -4 & 12 \, y^{2} \end{array}\right)$
P1 = (1,1)
B1 = (3,0)
B2=(3,3^(1/3))
B3 = (3,2)
B4=(2^(1/3),2)
B5 = (0,2)
B6 = (0,0)
ListePoints = [P1,B1,B2,B3,B4,B5,B6]
ListePoints
[f(P[0],P[1]) for P in ListePoints] # Les valeurs exactes
[f(P[0],P[1]).n(digits = 4) for P in ListePoints] # Une aprox décimale

[($\displaystyle 1$, $\displaystyle 1$), ($\displaystyle 3$, $\displaystyle 0$), ($\displaystyle 3$, $\displaystyle 3^{\frac{1}{3}}$), ($\displaystyle 3$, $\displaystyle 2$), ($\displaystyle 2^{\frac{1}{3}}$, $\displaystyle 2$), ($\displaystyle 0$, $\displaystyle 2$), ($\displaystyle 0$, $\displaystyle 0$)]
[$\displaystyle -1.000$, $\displaystyle 82.00$, $\displaystyle 69.02$, $\displaystyle 74.00$, $\displaystyle 9.440$, $\displaystyle 17.00$, $\displaystyle 1.000$]


C1= contour_plot(f, (x,0,3), (y,0, 2),cmap='hot',contours = 20,linestyles='solid', fill=True, colorbar=True)
C1.show()

cmsel = [colormaps['hot'](i) for i in sxrange(0,1,0.05)]
S = plot3d(f(x,y),(x,0,3),(y,0,2), adaptive = True, color = cmsel)
S.show(frame_aspect_ratio = [40,40,1])

3D rendering not yet implemented