Solutions to MATLAB #4! 1/5 >> clear all; >> close all; >> % Problem 1 >> clear all; >> syms s t real; >> % Problem 1a >> % Using cylindrical coordinates, the hyperboloid is written as: >>% z^2 = r^2 - 1 >> % We know that r>0 so we can solve for r explicitly: >> % r = sqrt(z^2 + 1) >> % We can substitute the expression of r in terms of z into the standard >> % cylindrical coordinates transformation: >> % x = sqrt(z^2 + 1)*cos(theta) >> % y = sqrt(z^2 + 1)*sin(theta) >> % z = z >> % In addition to the -2<=z<=2 bounds we also have 0<=theta<=2*pi. >> figure; >> ezmesh(sqrt(s^2+1)*cos(t),sqrt(s^2+1)*sin(t),s,[-2 2 0 2*pi]); 2 2 x = cos(t) sqrt(s +1.0), y = sin(t) sqrt(s +1.0), z = s 2 1.5 1 z 0.5 0 −0.5 −1 −1.5 −2 3 2 4 1 2 0 0 −1 −2 −2 y >> >> >> >> >> >> −3 −4 x % Problem 1b % The surface of revolution is given by: % r(s,t) = (s, cos(s)*cos(t), cos(s)*sin(t)) % for -pi/2<=s<=pi/2 and 0<=t<=2*pi figure; ezmesh(s,cos(s)*cos(t),cos(s)*sin(t),[-pi/2 pi/2 0 2*pi]); Solutions to MATLAB #4! 2/5 x = s, y = cos(s) cos(t), z = cos(s) sin(t) 1 z 0.5 0 −0.5 −1 1 2 0.5 1 0 0 −0.5 y >> >> >> >> >> >> >> >> >> >> >> −1 −1 % Problem 2 clear all; syms x y real; S1(x,y)=(2+cos(y))*cos(x); S2(x,y)=(2+cos(y))*sin(x); S3(x,y)=sin(y); S=[S1,S2,S3]; % Problem 2a figure; ezmesh(S1,S2,S3,[0 2*pi 0 2*pi]); axis equal; −2 x Solutions to MATLAB #4! 3/5 x = cos(x) (cos(y)+2.0), y = sin(x) (cos(y)+2.0), z = sin(y) z 0.5 0 −0.5 2 3 1 2 0 1 0 −1 −2 y >> >> >> >> >> >> −1 −2 x % Problem 2b Sx=diff(S,x); Sy=diff(S,y); Sx_cross_Sy=cross(Sx(x,y),Sy(x,y)); norm_Sx_cross_Sy=sqrt(dot(Sx_cross_Sy,Sx_cross_Sy)); I_2b=int(int(norm_Sx_cross_Sy,x,0,2*pi),y,0,2*pi) I_2b = 8*pi^2 % Problem 3 [X,Y]=meshgrid(-10:10,-5:5); M=X./(X.^2+Y.^2); N=1./(X.^2+Y.^2); figure; quiver(X,Y,M,N); Solutions to MATLAB #4! 4/5 6 4 2 0 −2 −4 −6 −15 −10 −5 0 % Problem 4 clear all; % Define the curve syms t real; r1=cos(t); r2=-2*t; r3=sin(3*t); r=[r1,r2,r3]; a=0; b=pi; % Define the vector field syms x y z real; M(x,y,z)=exp(y); N(x,y,z)=x^2*y; P(x,y,z)=x*z^3; F=[M,N,P]; % Setup and evaluate the integral I_4=int(dot(F(r1,r2,r2),diff(r,t)),t,a,b) I_4 = - exp(-2*pi)/5 - (41*pi^2)/4 - 1/5 5 10 15 Solutions to MATLAB #4! 5/5 % Problem 5 clear all; syms t real; r1=sin(2*t); r2=sin(t); r=[r1,r2]; a=0; b=pi; % Problem 5a figure; ezplot(r1,r2,[a,b]); x = sin(2 t), y = sin(t) 1.2 1 0.8 y 0.6 0.4 0.2 0 −0.2 −0.8 −0.6 −0.4 −0.2 0 x 0.2 0.4 0.6 0.8 % The region is the diamond like area bounded by the curve % Problem 5b % By integrating the vector field, F, over the closed curve C, we can see % by Green's theorem that the result will be the area of the region. % F = x*j syms x y real; % Define the vector field F(x,y)=[0,x]; % Setup and evaluate the integral area=int(dot(F(r1,r2),diff(r,t)),t,a,b) area = 4/3