Câu 1 đề 1 syms x y a=input(''''nhap a ''''); b=input(''''nhap b ''''); z=(x^2)/(a^2)+(y^2)/(b^2); t=linspace( 5,5); [x,y]=meshgrid(t,t); z=char(z);z=strrep(z,''''*'''','''' *'''');z=strrep(z,''''^'''','''' ^''''); z=eval(z); set(surf(x[.]
Câu đề syms x y a=input('nhap a: '); b=input('nhap b: '); z=(x^2)/(a^2)+(y^2)/(b^2); t=linspace(-5,5); [x,y]=meshgrid(t,t); z=char(z);z=strrep(z,'*','.*');z=strrep(z,'^','.^'); z=eval(z); set(surf(x,y,z),'FaceColor','g','FaceAlpha','0,3','EdgeColor','g'); rotate3d on; câu đề syms x y f=log(2*x+3*y); a=diff(diff(f,x,7),y,3); subs(a,[x y],[-1 1]) câu đề clc clf xlabel ('Ox') ylabel ('Oy') zlabel ('Oz') grid on hold on rotate3d on syms x y real f=x^2+y^2-32*log(x*y) [a b]=solve([char(diff(f,'x')) '=0'],[char(diff(f,'y')) '=0']); % giai dao ham cap a=double(a); b=double(b); % tinh dao ham cap A=diff(f,2,x); B=diff(f,x);B=diff(B,y); C=diff(f,2,y); cd=zeros(0); ct=zeros(0); zcd=zeros(0); zct=zeros(0); n=size(a,1);i=1; while i if sA > % A > la cuc tieu disp('cuc tieu la: ') ct=[ct;a(i) b(i)] disp(' gia tri cuc tieu tai : ') zct=[zct;eval(f)] i=i+1; elseif sA < % A > la cuc dai disp('cuc dai la: ') cd=[cd;a(i) b(i)] disp(' gia tri cuc dai la: ') zcd=[zcd;eval(f)] i=1+i; else end disp('ham so khong co cuc tri ') a(i)=[];b(i)=[]; n=n-1; else a(i)=[];b(i)=[]; n=n-1; end end syms e f c=e^2+f^2-32*log(e*f); a1=a(1);b1=b(1);c1=subs(c,[e f],[a1 b1]); a2=a(2);b2=b(2);c2=subs(c,[e f],[a2 b2]); a3=a(3);b3=b(3);c3=subs(c,[e f],[a3 b3]); a4=a(4);b4=b(4);c4=subs(c,[e f],[a4 b4]); x=linspace(-50,50,100); y=linspace(-50,50,100); [x,y]=meshgrid(x,y); f=x.^2+y.^2-32*log(x*y); set(surf(x,y,f),'facecolor','b','edgecolor','non','facealpha',.3); plot3(a1,b1,c1,'color','r','marker','o','MarkerSize', 20); plot3(a2,b2,c2,'color','r','marker','o','MarkerSize', 20); plot3(a3,b3,c3,'color','g','marker','o','MarkerSize', 20); plot3(a4,b4,c4,'color','g','marker','o','MarkerSize', 20); câu đề syms x y z tpz tpy I int(y,z) a=ans tpz=subs(a,z,1-y)-subs(a,z,0) b=int(tpz,y) tpy=subs(b,z,1)-subs(b,y,x^2) tpy=subs(b,y,1)-subs(b,y,x^2) I=int(tpy,x,-1,1) câu đề syms n s = symsum (n/3^n ,n ,1 ,inf) Câu đề syms x y z a=input('nhap a: '); b=input('nhap b: '); c=input('nhap c: '); [x y z]= ellipsoid(0,0,0,a,b,c); surf(x,y,z,'FaceColor','g','FaceAlpha','0,3','EdgeColor','r'); rotate3d on câu đề syms x y z f=x*y-sinh(z^2-x-y); fx=diff(f,x);fz=diff(f,z); zx=-fx/fz; zn=solve(subs(f,[x y],[0 1])==0,z); zxx=diff(zx,z)*zx+diff(zx,x); subs(zxx,[x y z ],[0 zn(1)]) subs(zxx,[x y z ],[0 zn(2)]) câu đề clc clf hold on grid on xlabel('Truc Ox') ylabel('Truc Oy') zlabel('Truc Oz') rotate3d on syms x y lamda real f=x^2+2*y^2 phi=x^2 +y^2-1 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 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+B*dphi+C*dphi^2; z=eval(f); if (dL > && isreal(m(i))) || ((dphi==inf || dphi==-inf) && C>0)%dao ham cap > => cuc tieu disp([' diem (' num2str(m(i)) ',' num2str(n(i)) ',' num2str(z) ') la diem cuc tieu']) elseif (dL < && isreal(m(i))) || ((dphi==inf || dphi==-inf) && C cuc dai disp([' diem (' num2str(m(i)) ',' num2str(n(i)) ',' num2str(z) ') la diem cuc dai']) end end syms e f c=e^2+2*f^2; a1=m(1);b1=n(1);c1=subs(c,[e f],[a1 b1]); a2=m(2);b2=n(2);c2=subs(c,[e f],[a2 b2]); a3=m(3);b3=n(3);c3=subs(c,[e f],[a3 b3]); a4=m(4);b4=n(4);c4=subs(c,[e f],[a4 b4]); phi=linspace (0,2*pi,100); r=linspace (0,1,100); [r phi]=meshgrid(r,phi); x=r.*cos(phi); y=r.*sin(phi); z=x.^2+2*y.^2; mesh(x,y,z,'FaceColor','b','FaceAlpha',0.5,'EdgeColor','non'); plot3(a1,b1,c1,'color','r','marker','o','MarkerSize', 20); plot3(a2,b2,c2,'color','r','marker','o','MarkerSize', 20); plot3(a3,b3,c3,'color','g','marker','o','MarkerSize', 20); plot3(a4,b4,c4,'color','g','marker','o','MarkerSize', 20); câu đề clc clear all xlabel('Truc Ox') ylabel('Truc Oy') grid on axis equal syms x y tp1 tp2 tp1=int(x*y+2*y,x) tp2=subs(tp1,x,y) tp1=subs(tp1,x,2-y) int(tp1-tp2,y,0,1) X=[0 2]; Y=[0 0]; line(X,Y); hold on fill(X,Y,'r') hold off câu đề syms n s = symsum ((-1)^n/n^2 ,n ,1 ,inf) câu đề clc clf hold on grid on xlabel('Truc ylabel('Truc zlabel('Truc rotate3d on title(' y=0, Ox') Oy') Oz') y=3, z=0, z=1-x^2') %Ve mat z=0,z=1-x^2 y=linspace(0,3,100); x=linspace(-1,1,100); [x y]=meshgrid(x,y); z1=1-x.^2; z2=0*x; mesh(x,y,z1,'FaceColor','r','FaceAlpha',0.5,'EdgeColor','non') mesh(x,y,z2,'FaceColor','m','FaceAlpha',0.5,'EdgeColor','non') %Ve mat y=0, y=3 x=linspace(-1,1,100);z=linspace(0,1,100); [x z]=meshgrid(x,z); y1=0*x; y2=0*x+3; for i=1:length(z) for j=1:length(x) if z(i,j)+ (x(i,j)).^2 > y1(i,j)=NaN; y2(i,j)=NaN; end end end mesh(x,y2,z,'facecolor','c','edgecolor','non','facealpha',.3) mesh(x,y1,z,'facecolor','g','edgecolor','non','facealpha',.3) câu đề syms x y t f=exp(3*x+2*y); ft=subs(f,[x y],[sin(t) t^2]); a=diff(ft,t); subs(a,t,0) câu đề function GTLNGTNN syms x y lamda real f=x^2-y^2;f=sym(f); x0=0;y0=0;r=5; %tim cuc tri mien D [p q]=solve(diff(f,'x'),diff(f,'y')); [p q]=loai(p,q); p=double(p);q=double(q); A=[]; for i=1:length(p) if (p(i)-x0)^2+(q(i)-y0)^2 < r^2 A(i,2)=p(i); A(i,3)=q(i); A(i,1)=subs(f,[x y],[p(i) q(i)]); end end if isempty(A) k=0; else k=size(A,1); end %tim cuc tri tren duong D phi=(x-x0)^2+(y-y0)^2-r^2; L=f+lamda*(phi); Lx=diff(L,'x'); Ly=diff(L,'y'); [l m n]=solve(Lx,Ly,phi,'x','y','lamda');%giai he dao ham cap voi: l lamda , m x , n y [m n]=loai(m,n); m=double(m);n=double(n);l=double(l); %chuyen sang dang double for i=1:length(m) A(i+k,2)=m(i); A(i+k,3)=n(i); A(i+k,1)=subs(f,[x y],[m(i) n(i)]); end %ve thi [x,y]=meshgrid(x0-r:.1:x0+r,y0-r:.1:y0+r); z=[char(f) '+0.*x'];z=strrep(z,'^','.^');z=strrep(z,'*','.*'); z=eval(z); z(~isreal(z))=NaN; set(surf(x,y,z),'facecolor','b','edgecolor','non','facealpha',.3) hold on t=linspace(0,2*pi,50); x=r*cos(t)+x0; y=r*sin(t)+y0; z=[char(f) '+0.*x']; z=eval(f); if size(z,2)~=size(x,2) z=x; z(:,:)=double(f); end plot3(x,y,z,'r') if isempty(A) disp('khong co GTLN va GTNN') return end a=max(A(:,1)); b=min(A(:,1)); if a==b if a>subs(f,[x y],[x0+0.12 y0+0.12]) disp(['GTLN f(' num2str(A(1,2)) ',' num2str(A(1,3)) ')= ' num2str(A(1,1))]) else disp(['GTNN f(' num2str(A(1,2)) ',' num2str(A(1,3)) ')= ' num2str(A(1,1))]) end return end GTLN='GTLN la '; GTNN='GTNN la f('; for i=1:size(A) if A(i,1)==a GTLN=[GTLN 'f(' num2str(A(i,2)) ',' num2str(A(i,3)) ')= ']; text(A(i,2),A(i,3),a+1,['(' num2str(A(i,2)) ',' num2str(A(i,3)) ',' num2str(a) ')' ]) elseif A(i,1)==b GTNN=[GTNN 'f(' num2str(A(i,2)) ',' num2str(A(i,3)) ')= ']; text(A(i,2),A(i,3),b-1,['(' num2str(A(i,2)) ',' num2str(A(i,3)) ',' num2str(b) ')' ]) end end GTLN=[GTLN num2str(a)]; GTNN=[GTNN num2str(b)]; disp(GTLN) disp(GTNN) hold off rotate3d on end function [a b]=loai(a,b) for i=1:length(a) if ~isreal(a(i)) || ~isreal(b(i)) a(i,:)=[]; b(i,:)=[]; end end end câu đề clear all clc grid on hold on syms x y Q P dy P=y; Q=x; diff(P,y)-diff(Q,x) disp('vay, tich phan khong phu thuoc duong di nen ta lay theo duong y=x') dy=diff(x,x); I=-int(subs(P,y,x)+subs(Q,y,x)*dy,x,0,1) %lay theo chieu KDH nên C dinh huong am %Ve duong cong C: y=sqrt(2*x-x.^2); set(ezplot(char(y),[0,1,0,1]),'Color','blue','LineWidth',2) câu đề syms n s = symsum (((3*n)-1)/(n*(4^n)) ,n ,1 ,inf) câu đề syms x y f=x*y^2-3*x^4*y^5; u=[1 -2]; f1=diff(f,x)*u(:,1)+diff(f,y)*u(:,2); subs(f1,[x y],[1 1]) câu đề syms x y f=exp(x)*sin(y) taylor(f,[x,y],'order',4) câu đề clc clf hold on grid on xlabel('Truc Ox') ylabel('Truc Oy') zlabel('Truc Oz') rotate3d on syms x y real f=x^3+y^3-3*x*y [a b]=solve([char(diff(f,'x')) '=0'],[char(diff(f,'y')) '=0']); % giai dao ham cap a=double(a); b=double(b); % tinh dao ham cap A=diff(f,2,x); B=diff(f,x);B=diff(B,y); C=diff(f,2,y); cd=zeros(0); ct=zeros(0); zcd=zeros(0); zct=zeros(0); n=size(a,1);i=1; while i if sA > % A > la cuc tieu disp('cuc tieu la: ') ct=[ct;a(i) b(i)] disp(' gia tri cuc tieu tai : ') zct=[zct;eval(f)] i=i+1; elseif sA < % A > la cuc dai disp('cuc dai la: ') cd=[cd;a(i) b(i)] disp(' gia tri cuc dai la: ') zcd=[zcd;eval(f)] i=1+i; else disp('ham so khong co cuc tri ') a(i)=[];b(i)=[]; n=n-1; end else a(i)=[];b(i)=[]; n=n-1; end end syms x y f= x^3+y^3-3*x*y; a1=a(1);b1=b(1);c1=subs(f,[x y],[a1 b1]); syms x y z= x^3+y^3-3*x*y; t=linspace(-2,2); [x,y]=meshgrid(t,t); z=char(z);z=strrep(z,'*','.*');z=strrep(z,'^','.^'); z=eval(z); set(surf(x,y,z),'FaceColor','g','FaceAlpha','0,3','EdgeColor','g'); plot3(a1,b1,c1,'color','r','marker','o','MarkerSize', 20); câu đề syms x y z t f dl x=t; y=x; z=sqrt(x^2+y^2); f=z*y-2*x; dl=sqrt(diff(x,t)^2+diff(y,t)^2+diff(z,t)^2) int(f,t,0,3/sqrt(2)) cậu đề syms n s = symsum (((-1)^n)/((3^n)*(2*n+1)) ,n ,1 ,inf) câu đề syms x y z f=80/(1+x^2+2*y^2+3*z^2); u=[1 -2]; fx=subs(diff(f,x),[x y z],u); fy=subs(diff(f,y),[x y z],u); fz=subs(diff(f,z),[x y z],u); gradient=[fx fy fz] câu đề syms x y z f=x+y-z-exp(z-x-y) fx=diff(f,x); fz=diff(f,z); zx=-fx/fz câu đề function GTLNGTNN syms x y lamda real f=(y^2-x^2)*exp(1-x^2-y^2);f=sym(f); x0=0;y0=0;r=2; %tim cuc tri mien D [p q]=solve(diff(f,'x'),diff(f,'y')); [p q]=loai(p,q); p=double(p);q=double(q); A=[]; for i=1:length(p) if (p(i)-x0)^2+(q(i)-y0)^2 < r^2 A(i,2)=p(i); A(i,3)=q(i); A(i,1)=subs(f,[x y],[p(i) q(i)]); end end if isempty(A) k=0; else k=size(A,1); end %tim cuc tri tren duong D phi=(x-x0)^2+(y-y0)^2-r^2; L=f+lamda*(phi); Lx=diff(L,'x'); Ly=diff(L,'y'); [l m n]=solve(Lx,Ly,phi,'x','y','lamda');%giai he dao ham cap voi: l lamda , m x , n y [m n]=loai(m,n); m=double(m);n=double(n);l=double(l); %chuyen sang dang double for i=1:length(m) A(i+k,2)=m(i); A(i+k,3)=n(i); A(i+k,1)=subs(f,[x y],[m(i) n(i)]); end %ve thi [x,y]=meshgrid(x0-r:.1:x0+r,y0-r:.1:y0+r); z=[char(f) '+0.*x'];z=strrep(z,'^','.^');z=strrep(z,'*','.*'); z=eval(z); z(~isreal(z))=NaN; set(surf(x,y,z),'facecolor','b','edgecolor','non','facealpha',.3) hold on t=linspace(0,2*pi,50); x=r*cos(t)+x0; y=r*sin(t)+y0; z=[char(f) '+0.*x']; z=eval(f); if size(z,2)~=size(x,2) z=x; z(:,:)=double(f); end plot3(x,y,z,'r') if isempty(A) disp('khong co GTLN va GTNN') return end a=max(A(:,1)); b=min(A(:,1)); if a==b if a>subs(f,[x y],[x0+0.12 y0+0.12]) disp(['GTLN f(' num2str(A(1,2)) ',' num2str(A(1,3)) ')= ' num2str(A(1,1))]) else disp(['GTNN f(' num2str(A(1,2)) ',' num2str(A(1,3)) ')= ' num2str(A(1,1))]) end return end GTLN='GTLN la '; GTNN='GTNN la f('; for i=1:size(A) if A(i,1)==a GTLN=[GTLN 'f(' num2str(A(i,2)) ',' num2str(A(i,3)) ')= ']; text(A(i,2),A(i,3),a+1,['(' num2str(A(i,2)) ',' num2str(A(i,3)) ',' num2str(a) ')' ]) elseif A(i,1)==b GTNN=[GTNN 'f(' num2str(A(i,2)) ',' num2str(A(i,3)) ')= ']; text(A(i,2),A(i,3),b-1,['(' num2str(A(i,2)) ',' num2str(A(i,3)) ',' num2str(b) ')' ]) end end GTLN=[GTLN num2str(a)]; GTNN=[GTNN num2str(b)]; disp(GTLN) disp(GTNN) hold off rotate3d on end function [a b]=loai(a,b) for i=1:length(a) if ~isreal(a(i)) || ~isreal(b(i)) a(i,:)=[]; b(i,:)=[]; end end end câu đề clc clf hold on grid on xlabel('Truc Ox') ylabel('Truc Oy') zlabel('Truc Oz') rotate3d on syms x y z px qy rz tpz tpy tpx I px=diff(y+z,x); qy=diff(x-z,y); rz=diff(z+1); a=int(px+qy+rz,z) tpz=simplify(subs(a,z,sqrt(4-x^2-y^2))-subs(a,z,0)) syms r phi b=subs(tpz,x,sqrt(r^2-y^2)) I=int(int(b,r,0,2),phi,0,2*pi) %Ve mat cong: syms x y z phi teta p t r phi=linspace(0,2*pi,360);teta=linspace(0,pi/2,360); [p, t]=meshgrid(phi, teta); x=2*sin(t).*cos(p); y=2*sin(t).*sin(p); z=2*cos(t); mesh(x,y,z,'FaceColor','c', 'FaceAlpha',0.5,'EdgeColor','non'); câu đề syms n s = symsum ((2^n - 5)/factorial(n) ,n ,1 ,inf) câu đề x=linspace(-10,10,100); z=linspace(-10,10,100); [x z]=meshgrid(x,z); y=z.^2-x.^2; mesh(x,y,z,'FaceColor','g','FaceAlpha',0.7,'EdgeColor','non') rotate3d on câu đê syms x y u; f=exp(u^2); subs(f,u,sin(x*y)); a=subs(f,u,sin(x*y)); fx=diff(a,x) fy=diff(a,y) câu đề clc clf hold on grid on xlabel('Truc Ox') ylabel('Truc Oy') zlabel('Truc Oz') rotate3d on syms x y lamda real f=2*x^2+12*x*y+y^2 phi=x^2 +4*y^2-25 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 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+B*dphi+C*dphi^2; z=eval(f); if (dL > && isreal(m(i))) || ((dphi==inf || dphi==-inf) && C>0)%dao cap > => cuc tieu disp([' diem (' num2str(m(i)) ',' num2str(n(i)) ',' num2str(z) ') diem cuc tieu']) elseif (dL < && isreal(m(i))) || ((dphi==inf || dphi==-inf) && C cuc dai disp([' diem (' num2str(m(i)) ',' num2str(n(i)) ',' num2str(z) ') diem cuc dai']) end end syms e f c=2*e^2+f^2+12*e*f; a1=m(1);b1=n(1);c1=subs(c,[e f],[a1 b1]); a2=m(2);b2=n(2);c2=subs(c,[e f],[a2 b2]); a3=m(3);b3=n(3);c3=subs(c,[e f],[a3 b3]); a4=m(4);b4=n(4);c4=subs(c,[e f],[a4 b4]); syms x y z=2*x^2+y^2+12*x*y t=linspace(-6,6); [x,y]=meshgrid(t,t); z=char(z);z=strrep(z,'*','.*');z=strrep(z,'^','.^'); z=eval(z); set(surf(x,y,z),'FaceColor','b','FaceAlpha','0,3','EdgeColor','g'); plot3(a1,b1,c1,'color','r','marker','o','MarkerSize', 20); plot3(a2,b2,c2,'color','r','marker','o','MarkerSize', 20); plot3(a3,b3,c3,'color','r','marker','o','MarkerSize', 20); plot3(a4,b4,c4,'color','r','marker','o','MarkerSize', 20); câu đề ham la %dao la clc clf xlabel ('Ox') ylabel ('Oy') zlabel ('Oz') grid on hold on title('x^2+y^2=2*x, x+y+z=3, z=0') syms x y z r t P=2*x+y; Q=2*y+z; R=2*z+x; z=eval(3-x-y); a=diff(z,x); b=diff(z,y); x=r*cos(t); y=r*sin(t); I=int(int(eval(P)*eval(a)+eval(Q)*eval(b)-eval(R),r,0,2*cos(t)),t,-pi/2,pi/2) %Ve mat phang x+y+z=3 nam mat tru tron xoay x^2+y^2=2*x phi=linspace(0,2*pi,30); r=linspace(0,1,30); [r phi]=meshgrid(r,phi); x=r.*cos(phi)+1; y=r.*sin(phi); z=3-x-y; mesh(x,y,z,'FaceColor','y','EdgeColor','w','FaceAlpha',1); %Ve mat tru tron xoay phi=linspace(0,2*pi,500); t=linspace(0,4,500); [phi t]=meshgrid(phi,t); x=cos(phi)+1; y=sin(phi); z=t; for i=1:length(phi); for j=1:length(t); if x(i,j)+y(i,j)+z(i,j)>3 x(i,j)=NaN;y(i,j)=NaN;z(i,j)=NaN; end end end mesh(x,y,z,'FaceColor','c','FaceAlpha',0.5,'EdgeColor','non'); view(130,18); rotate3d on câu đề syms n s = symsum (1/(((3*n)+1)*(n-2)) ,n ,3 ,inf) câu đề syms x y a b f=x^2+sin(x*y); M=[1 0]; u=[a b]; fx=subs(diff(f,x),[x y ],M); fy=subs(diff(f,y),[x y ],M); f1=a*fx+b*fy-1; f2=a^2+b^2-1; nghiem=solve(f1,f2,[a b]); A=nghiem.a; B=nghiem.b; u1=[A(1) B(1)] u2=[A(2) B(2)] câu đề syms x y; f=1/(2*x +3*y); taylor(f,[x,y],[1,2],'order',2) câu đề clc clf hold on grid on xlabel('Truc Ox') ylabel('Truc Oy') zlabel('Truc Oz') rotate3d on syms x y real f= x^4 + y^4 -x^2 -y^2-2*x*y [a b]=solve([char(diff(f,'x')) '=0'],[char(diff(f,'y')) '=0']); % giai dao ham cap a=double(a); b=double(b); % tinh dao ham cap A=diff(f,2,x); B=diff(f,x);B=diff(B,y); C=diff(f,2,y); cd=zeros(0); ct=zeros(0); zcd=zeros(0); zct=zeros(0); n=size(a,1);i=1; while i if sA > % A > la cuc tieu disp('cuc tieu la: ') ct=[ct;a(i) b(i)] disp(' gia tri cuc tieu tai : ') zct=[zct;eval(f)] i=i+1; elseif sA < % A > la cuc dai disp('cuc dai la: ') cd=[cd;a(i) b(i)] disp(' gia tri cuc dai la: ') zcd=[zcd;eval(f)] i=1+i; else disp('ham so khong co cuc tri ') a(i)=[];b(i)=[]; n=n-1; end else a(i)=[];b(i)=[]; n=n-1; end end syms x y f= x^4 + y^4 -x^2 -y^2-2*x*y a1=a(1);b1=b(1);c1=subs(f,[x y],[a1 b1]); a2=a(2);b2=b(2);c2=subs(f,[x y],[a2 b2]); syms x y z= x^4 + y^4 -x^2 -y^2-2*x*y; t=linspace(-2,2); [x,y]=meshgrid(t,t); z=char(z);z=strrep(z,'*','.*');z=strrep(z,'^','.^'); z=eval(z); set(surf(x,y,z),'FaceColor','g','FaceAlpha','0,3','EdgeColor','g'); plot3(a1,b1,c1,'color','r','marker','o','MarkerSize', 20); plot3(a2,b2,c2,'color','r','marker','o','MarkerSize', 20); cẫu đề clc clf hold on grid on xlabel('Truc Ox') ylabel('Truc Oy') zlabel('Truc Oz') rotate3d on syms x y z r t z=sqrt(x^2+y^2); a=diff(z,x); b=diff(z,y); x=r*cos(t); y=r*sin(t); z=eval(sqrt(x^2+y^2)); ds=eval(sqrt(1+a^2+b^2)); I=int(int(simplify((x+z)*sqrt(x^2+y^2)*ds),r,0,1),t,0,2*pi) %Ve mat cong S: %Vat the gioi han boi duong 0