clf
figure(1)
f=@(x,y,z) x.^2-2*y.^2+3*z.^2;
[X1,Y1]=meshgrid(-8:0.4:8,-5:0.4:8);
Z1=5-Y1;
%isosurface(X,Y,Z,W,0)
%alpha(0.6),hold on
[X,Y,Z]=meshgrid(-8:0.2:8);
W1=f(X1,Y1,Z1);
%isosurface(X,Y,Z,W,-5)
%grid
surf(X1,Y1,Z1,W1)
shading interp
hold on
title('$f(x,y,z)=x^2-2y^2+3z^2$','FontSize',13 ,'Interpreter','latex')
plot3(1,3,2,'*')
text(-0.9,2.9,1.7,'$(1,3,2)$','FontSize',13 ,'Interpreter','latex')
quiver3(1,3,2,2,-12,12,0.4,'Color','black','LineWidth',1.5)
[X2,Z2]=meshgrid(0:0.4:2,0:0.4:8);
Y2=9-6*X2;
W2=f(X2,Y2,Z2);
surf(X2,Y2,Z2,W2)
shading interp
%pause
%colorbar
%contourslice(X,Y,Z,f(X,Y,Z),X2,Y2,Z2,30)
%alpha(0.9)
hold on
%quiver3(1,3,2,2,-12,12,'Color','black','LineWidth',1.5)
%pause
axis equal
colorbar 
rotate3D on

figure(2)
[X,Y,Z]=meshgrid(-8:0.6:8,0:0.6:8,-8:0.6:8);
W=f(X,Y,Z);
isosurface(X,Y,Z,W,f(1,3,2))
alpha(0.5),hold on
title('$f(x,y,z)=x^2-2y^2+3z^2$','FontSize',13 ,'Interpreter','latex')
plot3(1,3,2,'*')
quiver3(1,3,2,2,-12,12,0.2,'Color','black','LineWidth',1.5)
isosurface(X,Y,Z,W,f(1,3,2)-30)
alpha(0.5)
isosurface(X,Y,Z,W,f(1,3,2)+30)
alpha(0.5)
rotate3D on
axis equal
%colorbar 
grid
