Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống
1
/ 14 trang
THÔNG TIN TÀI LIỆU
Thông tin cơ bản
Định dạng
Số trang
14
Dung lượng
112,18 KB
Nội dung
TRƯỜNG ĐẠI HỌC BÁCH KHOA T.P HỒ CHÍ MINH KHOA: KHOA HỌC ỨNG DỤNG BỘ MƠN: TỐN ỨNG DỤNG BÁO CÁO BÀI TẬP LỚN GIẢI TÍCH NHĨM: GVHD: TRẦN XUÂN MỸ I CODE LỚN Câu Câu a Câu b function cau1b clc; hold off; syms x y; x=linspace(-2,2,10); z=linspace(-2,2,10); [X,Z]=meshgrid(x,z); Y=Z.^2-X.^2; set(surf(X,Y,Z),'facecolor','g','edgecolor','non','facealpha',.3) end 2 Câu function bai2 warning off syms x y lamda real a b f=input('nhap ham f(x,y)= '); disp('nhap parabol y(x) vd: y=6+4*x^2 ') phi=(x^2/a^2)+(y^2/b^2)-1; a=input('nhap vao a='); b=input('nhap vao b='); phi=eval(phi); hold on L=f+lamda*phi; Lx=diff(L,'x'); Ly=diff(L,'y'); [m n l]=solve(Lx,Ly,phi,'x','y','lamda'); %giai he dao ham cap voi: l lamda , m x , n y m=double(m); m(abs(imag(m))>0.0000000001)=inf;m=m-imag(m)*1i; %loai so phuc n=double(n); n(abs(imag(n))>0.0000000001)=inf;n=n-imag(n)*1i; l=double(l); l(abs(imag(l))>0.0000000001)=inf;l=l-imag(l)*1i; Lxx=diff(Lx,'x');Lyy=diff(Ly,'y');Lxy=diff(Lx,'y'); %dao ham cap phix=diff(phi,'x');phiy=diff(phi,'y'); %dao ham dieu kien k=0; for i=1:length(m) %xet cuc dai, cuc tieu if m(i)==inf || n(i)==inf || l(i)==inf continue end x=m(i); y=n(i); lamda=l(i); dphi=-eval(phix)/eval(phiy); A=eval(Lxx); B=eval(Lxy); C=eval(Lyy); dL=A*dphi^2+2*B*dphi+C*dphi^2; z=eval(f); if (dL > && isreal(m(i))) || ((dphi==inf || dphi==-inf) && C>0) %dao ham cap > => cuc tieu k=k+1; disp([' diem (' num2str(m(i)) ',' num2str(n(i)) ',' num2str(z) ') la diem cuc tieu']) text(x,y,z-1,['cuc tieu (' num2str(m(i)) ',' num2str(n(i)) ',' num2str(z) ')' ]) elseif (dL < && isreal(m(i))) || ((dphi==inf || dphi==-inf) && C cuc dai k=k+1; disp([' diem (' num2str(m(i)) ',' num2str(n(i)) ',' num2str(z) ') la diem cuc dai']) text(x,y,z+1,['cuc dai (' num2str(m(i)) ',' num2str(n(i)) ',' num2str(z) ')' ]) end end %ve thi if k~=0 x=linspace(min(m)-2,max(m)+2,20); y=sqrt(5-x.^2); [x,y]=meshgrid(x,y); z=char(f);z=strrep(z,'*','.*');z=strrep(z,'^','.^'); z=eval(f); [x y z]=khu(x,y,z); set(surf(x,y,z),'facecolor','b','edgecolor','non','facealpha',.2); x=linspace(min(m)-2,max(m)+2,20); y=sqrt(5-x.^2); z=eval(f); plot3(x,y,z,'color','r') else disp('ham da cho ko co cuc tri dieu kien') x=linspace(-2,2,20); y=sqrt(5-x.^2); [x,y]=meshgrid(x,y); z=char(f);z=strrep(z,'*','.*');z=strrep(z,'^','.^'); z=eval(f); [x y z]=khu(x,y,z); set(surf(x,y,z),'facecolor','b','edgecolor','non','facealpha',.2) hold on x=linspace(-2,2,20); y=sqrt(5-x.^2); z=eval(f); plot3(x,y,z,'color','r') end hold off rotate3d on end %loai cac diem bat dinh function [x y f]=khu(x,y,f) % chuong trinh loai bo cac diem khong ton tai cua ham f for i=1:length(x) for j=1:length(y) if ~isreal(f(i,j)) f(i,j)=NaN;x(i,j)=NaN;y(i,j)=NaN; end end end end Kết nhap ham f(x,y)= x^2+3*x*y+3*y^2 nhap parabol y(x) vd: y=6+4*x^2 nhap vao a=1 nhap vao b=4 diem (-48.7539,0.12466,2358.7525) la diem cuc tieu diem (-0.24613,-0.9922,3.7466) la diem cuc tieu diem (-48.7539,-0.12466,2395.2196) la diem cuc dai diem (-0.24613,0.9922,2.2813) la diem cuc tieu Câu3 function cau3 clc syms x y z real f=input('nhap ham f(x,y,z)= '); f=sym(f); [x, y, ~] = ellipsoid(0,0,1,1,1,1); z=1+0.*x; z1=-sqrt(1-(x.^2+y.^2))+1; set(surf(x,y,z),'facecolor','g','edgecolor','non','facealpha',.1) hold on set(surf(x,y,z1),'facecolor','b','edgecolor','non','facealpha',.1) hold off rotate3d on syms theta phi p x=p*cos(phi)*sin(theta); y=p*sin(phi)*sin(theta); z=1+p*cos(theta); f=eval(f); I=int(int(int(f*p^2*sin(theta),'p',0,1),'phi',0,2*pi),'theta',pi/2,pi); I=double(I); disp(['tich phan can tinh la I= ' num2str(I)]) end Kết nhap ham f(x,y,z)= x^2+y^2+z^2 tich phan can tinh la I= 1.7802 Câu function bai4 %tinh tich phan syms x y z phi r real f=x^2; f=sym(f); %do vai tro cua x y z la nhu bieu thuc cua duong tron C nen % I= 1/3*int( x^2+y^2+z^2, dl) % C nằm mặt cầu, x^2+y^2+z^2=4; % chieu C xuong mp Oxy ta tính I theo miên D: 0 f=x^2+3*x*y+y^2; >> Fxx=diff(f,'x',2); >> Fxy=diff(diff(f,'x'),y); >> subs(Fxx,[1 2],[x y]) ans = >> subs(Fxy,[1 2],[x y]) ans = Tọa độ DESCARTES >> syms x y >> f=x+y+3*x*y; >> int(int(f,'x',0,sqrt(y)),'y',0,1) ans = 23/20 Tọa độ cực >> syms x y phi r >> f=x+y+3*x*y; >> x=r*cos(phi); >> y=r*sin(phi); >> f=eval(f); >> int(int(f,'r',0,1),'phi',0,2*pi) ans = Tọa độ cầu >> syms x y r phi teta >> f=x^2; >> f=x; >> x=r*sin(teta)*cos(phi); >> y=r*sin(teta)*sin(phi); >> z=r*cos(teta); >> f=eval(f)*(r^2)*sin(teta); >> I=int(int(int(f,'r',0,1),'teta',0,pi/4),'phi',0,2*pi) I= Câu >> syms x y z; >> f=2*x*y+y^2+x^2; >> fx=diff(f,'x'); >> fy=diff(f,'y'); >> X=(subs(fx,[x y],[0 1])); >> Y=subs(fy,[x y],[0 1]); >> garadien=[X Y] garadien = 2 Câu >> syms x y z; >> u=u/norm(u); >> u=u/norm(u); >> f=2*x*y+y^2+x^2; >> fx=diff(f,'x'); >> fy=diff(f,'y'); >> X=(subs(fx,[x y],[0 1])); >> Y=subs(fy,[x y],[0 1]); >> garadien=[X Y] garadien = 2 >> fu=dot(garadien,u) fu = 2.6833 Câu ... I= int(int(int(f *p^ 2* sin(theta), 'p' ,0,1),'phi',0 ,2* pi),'theta',pi /2, pi); I= double (I) ; disp(['tich phan can tinh la I= ' num2str (I) ]) end K? ?t nhap ham f(x,y,z)= x ^2+ y ^2+ z ^2 tich phan can tinh la I= 1.78 02 Câu function bai4 %tinh... set(surf(x,y,z1),'facecolor','b','edgecolor','non','facealpha',.1) hold off rotate3d on syms theta phi p x =p* cos(phi)*sin(theta); y =p* sin(phi)*sin(theta); z=1 +p* cos(theta); f=eval(f); I= int(int(int(f *p^ 2* sin(theta), 'p' ,0,1),'phi',0 ,2* pi),'theta',pi /2, pi);... n( i) ==inf || l( i) ==inf continue end x=m (i) ; y =n( i) ; lamda =l( i) ; dphi=-eval(phix)/eval(phiy); A=eval(Lxx); B=eval(Lxy); C=eval(Lyy); dL=A*dphi ^2+ 2*B*dphi+C*dphi ^2; z=eval(f); if (dL > && isreal(m (i) ))