function lab2soln2ZZ3 % 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(' ') syms xs ys; Fxs = sin(ys)*cos(xs)+0.5; Fys = sin(xs)*cos(ys)+0.2; phis = sin(xs)*sin(ys)+0.5*xs+0.2*ys; Fx = matlabFunction(Fxs); Fy = matlabFunction(Fys); phi = matlabFunction(phis); k = [1 2 3]; l = [1 2 3]; [K,L] = meshgrid(k,l); x = linspace(0,4,100); y = x; [X,Y] = meshgrid(x,y); figure('Name','A conservative vector field and its potential function'); title(['F(x,y) = < sin y cos x + 1/2, sin x cos y + 1/5 >' char(10) ... 'and its potential function \phi = sin x sin y + x/2 + y/5']); hold on; grid on; set(gca,'PlotBoxAspectRatio',[1 1 1]); quiver(K, L, Fx(K,L), Fy(K,L)); contour( X, Y, phi(X,Y), sort(phi(K,L)) ); disp(' ') disp(' ------------------------------------------------ ') disp(' ') disp(' ') disp(' ') disp(' ') disp(' ---------- Solution to Question #2 ---------- ') disp(' ') % (a) phi = @(x,y,z) x.^2 + x.*y + x.*y.*z; Answer1 = phi(1,2,1) - phi(0,0,0); % (b) syms x y z t; Fxs = 2*x + y + y*z; Fys = x + x*z; Fzs = x*y; Fs = [Fxs Fys Fzs]; rxs = sin(pi*t/2); rys = 2*t; rzs = t^2; rs = [rxs rys rzs]; Fdrs = subs(Fs,[x y z],rs)*diff(rs,t)'; Fdr = matlabFunction(Fdrs); Answer2 = quadl(Fdr,0,1); 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 % User's Functions Space is below --------------------------