clf
set(0,'defaulttextinterpreter','latex')
f=@(x,y) 4+x+2*y+x.^2+2*x.*y+3*y.^2+x.^4+2*y.^4;
p1=@(x,y) 4+x+2*y;
p2=@(x,y) 4+x+2*y+x.^2+2*x.*y+3*y.^2;
[X,Y]=meshgrid(-0.8:0.04:0.8);
Z=f(X,Y);
eh=surf(X,Y,Z,2.-2.5*ones(size(Z)));
%eh=surf(X,Y,Z);
set(eh,'FaceColor','red','EdgeColor','none','FaceAlpha',0.8);
shading interp
hold on
xlabel('x')
ylabel('y')
zlabel('z')
view([-4 -1 0.5])
te=text(0.8,0.8,13,'\hspace*{-3 cm}$ \bf{z= f(x,y),  f(0,0)=4,  f_{1}(0,0)=1,  f_{2}(0,0)= 2,  f_{11}(0,0)=2,  f_{12}(0,0)=2, f_{22}(0,0)=6} $ ','FontSize',10);
an=plot3([0.8 0.75],[0.8 0.75],[12.5 f(0.75,0.75)],'Color','black');
grid off
plot3(0,0,f(0,0),'*')
plot3(0,0,0,'*')
plot3([0 0],[0 0],[0 f(0,0)],':')
teo=text(-0.25,-0.05,-0.3,'$\bf{(0,0)}$','FontSize',12,'Color','black','Interpreter','latex');
pause

Z=p1(X,Y);
et=surf(X,Y,Z,-2*ones(size(Z)));
%et=surf(X,Y,Z)
set(et,'FaceColor','red','EdgeColor','none','FaceAlpha',0.3);
shading interp
tep1=text(-0.8,0.6,2.5,'\hspace*{-0.4 cm}$ \bf{p_1(x,y)=4+x+2y} $ ','FontSize',13,'Interpreter','latex');
anp1=plot3([-0.8 -0.75],[0.6 0.65],[2.85 p1(-0.75,0.65)],'Color','black');

pause
Z=p2(X,Y);
es=surf(X,Y,Z,1.5*ones(size(Z)));
set(es,'FaceColor','red','EdgeColor','none','FaceAlpha',0.3);

tep2=text(-0.85,0.7,1.25,'\hspace*{-0.4 cm}$ \bf{p_2(x,y)=4+x+2y+x^2+2xy+3y^2} $ ','Color','black','FontSize',13,'Interpreter','latex');
anp2=plot3([-0.85 -0.75],[0.7 0.77],[1.6 p2(-0.75,0.77)],'Color','black');
% an=quiver3(0.7,-0.7,9,0,0,f(0.7,-0.7)-9, 0,'Color','black');
rotate3D on
hold off