%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Math 275: This is program % matlab_problems_examples.m to for Matlab project %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% clear all %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Section 13.1 # 30 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% t=0.1:1e-3:5; x=t.^2; y=log(t); z=t; figure(1); clf(1) set(gca,'FontSize',12); set(gca,'box','on') plot3(x,y,z) xlabel('x') ylabel('y') zlabel('z') title('Section 13.1 # 30: graph of curve x=t^2, y=log(t), z=t') grid on print -depsc2 problem_13_1_30.eps %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Section 13.1 # 33 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% t=-10:1e-3:10; figure(2); clf(2) set(gca,'FontSize',12); set(gca,'box','on') x=(1+cos(16*t)).*cos(t); y=(1+cos(16*t)).*sin(t); z=(1+cos(16*t)); subplot(2,2,1) plot3(x,y,z,'Linewidth',1) xlabel('x') ylabel('y') zlabel('z') title('Section 13.1 # 33: curve') grid on t=-10:1e-1:10; subplot(2,2,2) x=t; y=t; [X,Y]=meshgrid(x,y); f=inline('sqrt(x.^2+y.^2)','x','y'); mesh(X,Y,f(X,Y)) %xlim([-2 2]) %ylim([-2 2]) %zlim([0 2]) title('Cone z=sqrt(x^2+y^2)') print -depsc2 problem_13_1_33.eps %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Section 13.1 # 40 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% figure(3); clf(3) set(gca,'FontSize',12); set(gca,'box','on') subplot(2,2,1) x=-2:1e-2:2; z=0:1e-2:3; f=inline('x.^2','x','z'); [X3,Z3]=meshgrid(x,z); mesh(X3,f(X3,Z3),Z3) hold on subplot(2,2,2) mesh(X3,f(X3,Z3),Z3) hold on subplot(2,2,1) x=-2:1e-2:2; y=-sqrt(2):1e-2:sqrt(2); f=inline('sqrt(4-x.^2/4-y.^2)','x','y'); [X2,Y2]=meshgrid(x,y); mesh(X2,Y2,f(X2,Y2)) xlabel('x') ylabel('y') zlabel('z') title('Section 13.1: # 40') x=-1:1e-2:1; y=x.^2; z=sqrt(4-x.^4-x.^2/4); plot3(x,y,z,'rd','Linewidth',5) subplot(2,2,2) plot3(x,y,z,'r','Linewidth',4) print -depsc2 problem_13_1_40.eps %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Section 13.2 # 27 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% figure(4); clf(4) set(gca,'FontSize',12); set(gca,'box','on') t=-3:1e-2:3; x1=t; y1=exp(-t); z1=2*t-t.^2; x2=t; y2=1-t; z2=2*t; plot3(x1,y1,z1,'b','Linewidth',2) hold on plot3(x2,y2,z2,'r','Linewidth',2) grid on legend('curve','tangent line') title('Section 13.2: # 27: curve and its tangent line') print -depsc2 problem_13_2_27.eps %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Section 13.3 # 35 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% figure(5); clf(5) set(gca,'FontSize',12); set(gca,'box','on') x=-5:1e-2:5; y=x.^(-2); kappa=6*x.^(-4)./((1+4*x.^(-6)).^(3/2)); plot(x,y,'b','Linewidth',2) hold on plot(x,kappa,'r','Linewidth',2) ylim([0 3]) legend('y(x)','\kappa(x)') title('Section 13.3: # 35') print -depsc2 problem_13_3_35.eps %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Section 14.1 # 51, 52 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% figure(6); clf(6) set(gca,'FontSize',12); set(gca,'box','on') x=-2:1e-2:2; y=x; [X,Y]=meshgrid(x,y); f=inline('exp(-x.^2)+exp(-2*y.^2)','x','y'); g=inline('(1-3*x.^2+y.^2).*exp(1-x.^2-y.^2)','x','y'); subplot(2,2,1) mesh(X,Y,f(X,Y)) xlabel('x') ylabel('y') zlabel('z') title('Section 14.1 # 51: surface plot') subplot(2,2,2) contour(X,Y,f(X,Y)) xlabel('x') ylabel('y') zlabel('z') title('Section 14.1 # 51: contour plot') subplot(2,2,3) mesh(X,Y,g(X,Y)) xlabel('x') ylabel('y') zlabel('z') title('Section 14.1 # 52: surface plot') subplot(2,2,4) contour(X,Y,g(X,Y)) xlabel('x') ylabel('y') zlabel('z') title('Section 14.1 # 52: contour plot') print -depsc2 problem_14_1_51_52.eps %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Section 15.1 # 70 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% figure(7); clf(7) set(gca,'FontSize',12); set(gca,'box','on') x=-1:1e-2:1; y=x; [X,Y]=meshgrid(x,y); f=inline('(x.*y)./(x.^2+y.^2)','x','y'); subplot(2,2,1) mesh(X,Y,f(X,Y)) xlabel('x') ylabel('y') zlabel('z') title('Section 14.1: # 70: close to the origin') subplot(2,2,2) x=-50:1e-1:50; y=x; [X,Y]=meshgrid(x,y); mesh(X,Y,f(X,Y)) xlabel('x') ylabel('y') zlabel('z') title('Section 14.1: # 70: away from the origin') print -depsc2 problem_14_1_70.eps %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Section 14.4 # 8 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% figure(8); clf(8) set(gca,'FontSize',12); set(gca,'box','on') x=-1:1e-2:1; y=x; [X,Y]=meshgrid(x,y); f=inline('atan(x.*y.^2)','x','y'); % surface subplot(2,2,1) mesh(X,Y,f(X,Y)) hold on g=inline('pi/4+(x-1)/2+y-1','x','y'); % tangent plane mesh(X,Y,g(X,Y)) xlabel('x') ylabel('y') zlabel('z') title('Section 14.4: # 8') x2=0.9:1e-3:1.1; y2=x2; [X2,Y2]=meshgrid(x2,y2); subplot(2,2,2) mesh(X2,Y2,f(X2,Y2)) hold on mesh(X2,Y2,g(X2,Y2)) xlabel('x') ylabel('y') zlabel('z') title('Section 14.4: # 8: zoom in') xlim([0.9 1.1]) ylim([0.9 1.1]) print -depsc2 problem_14_4_8.eps