f=@(x,y) 25+15*(x+0.5).^4+20*(y-0.5).^4;
f1=@(x,y) 60*(x+0.5).^3;
f2=@(x,y) 80*(y-0.5).^3;
g=@(x,y) f(0,0)+f1(0,0).*x+f2(0,0).*y;
[x,y]=meshgrid(0:0.05:0.6,-0.6:0.05:0);
z=f(x,y);
surf(x,y,z)
hold on
[x,y]=meshgrid([0 0.6],[-0.6 0]);
surf(x,y,zeros(size(x)),55*ones(size(x)))
axis([-0.05 0.8 -0.8 0.05 0 80])
alpha(0.9)
shading interp
rotate3D on
grid off
z=g(x,y);
surf(x,y,z,70*ones(size(x)))
surf(x,y,f(0,0)*ones(size(x)),57*ones(size(x)))
plot3([0 0 0.6 0.6 0],[0 -0.6 -0.6 0 0],[0 0 0 0 0])
z=0:2:f(0,0);
x=zeros(size(z));
y=zeros(size(z));
plot3(x,y,z,':','Linewidth',1.5)
z=0:2:f(0,0);
x=zeros(size(z));
y=-0.6*ones(size(z));
plot3(x,y,z,':','Linewidth',1.5)
z=g(0,-0.6):2:f(0,-0.6);
x=zeros(size(z));
y=-0.6*ones(size(z));
plot3(x,y,z,':','Linewidth',1.5)
plot3([0 0],[-0.6 -0.6],[f(0,0),g(0,-0.6)],'Linewidth',1.5)
z=0:2:f(0,0);
x=0.6*ones(size(z));
y=zeros(size(z));
plot3(x,y,z,':')
z=g(0.6,0):2:f(0.6,0);
x=0.6*ones(size(z));
y=zeros(size(z));
plot3(x,y,z,':','Linewidth',1.5)
plot3([0.6 0.6],[0 0],[f(0,0),g(0.6,0)],'Linewidth',1.5)
z=0:2:f(0,0);
x=0.6*ones(size(z));
y=-0.6*ones(size(z));
plot3(x,y,z,':','Linewidth',1.5)
z=g(0.6,-0.6):2:f(0.6,-0.6);
x=0.6*ones(size(z));
y=-0.6*ones(size(z));
plot3(x,y,z,':','Linewidth',1.5)
plot3([0.6 0.6],[-0.6 -0.6],[f(0,0),g(0.6,-0.6)],'Linewidth',1.5)
x=0:0.05:0.6;
y=zeros(size(x));
plot3(x,y,f(x,y))
x=0:0.05:0.6;
y=-0.6*ones(size(x));
plot3(x,y,f(x,y))
y=-0.6:0.05:0;
x=0.6*ones(size(x));
plot3(x,y,f(x,y))
y=-0.6:0.05:0;
x=zeros(size(x));
plot3(x,y,f(x,y))
text(0,0,3,'(a,b)')
text(0,0,f(0,0)-3,'(a,b,f(a,b)')
text(0,-0.6,3,'(a,y)')
text(0,-0.62,(g(0,0)+g(0,-0.6))/2-0.5,'f_2(a,b)(y-b)')
text(0.6,0,3,'(x,b)')
text(0.62,0,(g(0,0)+g(0.6,0))/2-0.5,'f_1(a,b)(x-a)')
text(0.6,-0.6,3,'(x,y)')
text(0.62,-0.62,(g(0,0)+g(0.6,-0.6))/2,'f_1(a,b)(x-a)+f_2(a,b)(y-b)')
text(0.4,-0.4,g(0.4,-0.4)+3,'tangentplanet')
text(0.5,-0.5,f(0.5,-0.5)-2,'z=f(x,y)')
hold off



