function lab1soln2ZZ3 % where Name_XXXXXXX_hwN is the name of the file you submit without the extension .m %------------------------------------------------------------------------ %%% ENGINEERING MATHEMATICS IV - MATH 2ZZ3 %%% ASSIGNMENT #5: %%% TRIPLE INTEGRALS, DIVERGENCE THEOREM AND CHANGE OF VARIABLES %------------------------------------------------------------------------ %------------------------------------------------------------------------ % Covers: % - "Numerical Mathematics" by M. Grasselli and D. Pelinovsky, % Sections 7.7--7.8. % "Advanced Engineering Mathematics" by D.G. Zill and W.S. Wright, section 9.15, 9.16, 9.17 %------------------------------------------------------------------------ %------------------------------------------------------------------------ % Instructions: % - Submit your assignment electronically (via Email) to the % address specific to your last name as indicated on the course % website; hardcopy submissions will not be accepted. % - It is obligatory to use the current MATLAB template file available at % http://www.math.mcmaster.ca/gabardo/MATH2ZZ3/frames/template.m; % submissions non compliant with this template will not be accepted. % - Make sure to enter your name and student I.D. number in the % appropriate section of the template. % - Late submissions and submissions which do not comply with % these guidelines will not be accepted. % - All graphs should contain suitable titles and legends. %------------------------------------------------------------------------ % Written by Vladislav Bukshtynov, 2009 clc; close all; clear all; % Student information disp(' ------------ Student Information ------------ ') % Please enter your information here Name = 'Lab 1'; Surname = 'Solutions'; ID = 1234567; fprintf(' Student: %s %s (ID: %d) \n', Name, Surname, ID); disp(' ------------------------------------------------ ') disp(' ') disp(' ') disp(' ') disp(' ') disp(' ---------- Solution to Question #1 ---------- ') disp(' ') % (a) syms T; rxs = (2+3*cos(3*T)).*cos(2*T); rys = (2+3*cos(3*T)).*sin(2*T); rzs = sin(3*T); rs = [rxs rys rzs]; Ts = (rxs^2+rys^2+rzs^2)^(-1/2)*diff(rs,T); Txs = Ts(1); Tys = Ts(2); Tzs = Ts(3); Ns = (Txs^2+Tys^2+Tzs^2)^(-1/2)*diff(Ts,T); Nxs = Ns(1); Nys = Ns(2); Nzs = Ns(3); Bs = cross(Ts,Ns); Bxs = Bs(1); Bys = Bs(2); Bzs = Bs(3); rx = matlabFunction(rxs); ry = matlabFunction(rys); rz = matlabFunction(rzs); Tx = matlabFunction(Txs); Ty = matlabFunction(Tys); Tz = matlabFunction(Tzs); Nx = matlabFunction(Nxs); Ny = matlabFunction(Nys); Nz = matlabFunction(Nzs); Bx = matlabFunction(Bxs); By = matlabFunction(Bys); Bz = matlabFunction(Bzs); t = linspace(0,2*pi,100); tv = 0:pi/3:2*pi; scrsz = get(0,'ScreenSize'); figure('Name','Unit tangent, principal normal, and binormal vectors', ... 'OuterPosition',[1 scrsz(4)/3 2*scrsz(3)/3 2*scrsz(4)/3]); title(['r(t) = (2 + cos 3t)cos 2t \bf{}i\rm{} + ' ... '(2 + cos 3t)sin 2t \bf{}j\rm{} + sin 3t \bf{}k\rm{}' ... char(10) 'and its tangent, normal, and binormal vectors']); hold on; grid on; view(3); plot3(rx(t),ry(t),rz(t)); quiver3(rx(tv),ry(tv),rz(tv),Tx(tv),Ty(tv),Tz(tv)); quiver3(rx(tv),ry(tv),rz(tv),Nx(tv),Ny(tv),Nz(tv)); quiver3(rx(tv),ry(tv),rz(tv),Bx(tv),By(tv),Bz(tv)); legend('\bf{}r\rm{}(t)','unit tangent','principal normal','binormal'); % (b) t = linspace(0,2*pi,151); rps = sqrt(diff(rxs,T)^2+diff(rys,T)^2+diff(rzs,T)^2); rp = matlabFunction(rps); s = zeros(1,151); s(1) = 0; for i = 2:151 s(i) = s(i-1) + quadl(rp,t(i-1),t(i)); end figure('Name','Arc length function'); title('plot of the arc length function for the curve \bf{}r\rm{}'); hold on; grid on; plot(t,s); disp(' ') disp(' ------------------------------------------------ ') disp(' ') disp(' ') disp(' ') disp(' ') disp(' ---------- Solution to Question #2 ---------- ') disp(' ') x = linspace(-4,4,151); y = x; [X,Y] = meshgrid(x,y); figure('Name','3D contour + surface plot'); title('graph of sin(6 \surd(x^2+y^2)+3x)/\surd(x^2+y^2)'); hold on; grid on; view(3); surfc(X,Y,sin(6*sqrt(X.^2+Y.^2)+3*X)./sqrt(X.^2+Y.^2)); disp(' ') disp(' ------------------------------------------------ ') disp(' ') disp(' ') disp(' ') disp(' ') disp(' ---------- Answers ---------- ') disp(' ') % DO NOT TOUCH THIS PART (RESERVED FOR THE INSTRUCTOR'S USE) Name Surname ID Answer1 Answer2 Answer3 Answer4 Answer5 Answer6 % User's Functions Space is below --------------------------