verzija: SageMath 9.4
from sage.plot.plot3d.shapes import *
%display latex
var('y z k')
Odredite lokalne ekstreme i sedlaste točke funkcije $f(x,y)=e^{x-y}\big(x^2-2y^2\big).$
f(x,y)=e^(x-y)*(x^2-2*y^2)
grad_f=f.diff(); grad_f
grad_f.apply_map(lambda t: t.factor())
solve([grad_f[0]==0,grad_f[1]==0],[x,y])
hess_f=f.diff(2); hess_f
hess_f = hess_f.apply_map(lambda t: t.factor()); hess_f
Točka $(0,0)$ je sedlasta točka funkcije $f$.
hess_f(x=0,y=0)
hess_f(x=0,y=0).det()
U točki $(-4,-2)$ funkcija $f$ ima lokalni maksimum koji iznosi $8e^{-2}$.
hess_f(x=-4,y=-2)
hess_f(x=-4,y=-2).det()
f(-4,-2)
Na slici je prikazan graf funkcije $f$ i istaknuta je svjetloplava sedlasta točka i žuta točka lokalnog maksimuma.
ploha1=implicit_plot3d(f(x,y)-z,(x,-5,5),(y,-5,5),(z,-7,7),color='pink',plot_points=60)
tf1=Sphere(0.1,color='yellow').scale(1,1,1.1).translate(-4,-2,f(-4,-2))
tf2=Sphere(0.1,color='cyan').scale(1,1,1.1).translate(0,0,f(0,0))
(ploha1+tf1+tf2).show(viewer='threejs',online=True,aspect_ratio=[1,1,0.8])