Giáo án Giải tích 2: Các lệnh mẫu Matlab BTL cá nhân môn - Năm học 2016

Tính đạo hàm:

Ví dụ bài 6

>> syms x y z

>> f=log(exp(x)+exp(z))-log(exp(x)+exp(y));

>> A=5*diff(f,x,1)-2*diff(f,y,1)+diff(f,z,1);

>> subs(A,[x y z],[0 0 0])

ans =

    1.5000

Tính vi phân:

Ví dụ bài 4

>> Syms x y dx dy

>> f=x*log(x*y+1);

>> fxx=diff(f,x,2);

>> fyy=diff(f,y,2);

>> fxy=diff(diff(f,x),y);

>> A=subs(fxx,[x y],[1 0]);

>> B=subs(fyy,[x y],[1 0]);

>> C=subs(fxy,[x y],[1 0]);

>> d2f = A*dx^2 + B*dy^2 + 2*C*dx*dy

d2f =

    - dy^2 + 4*dx*dy

docx 9 trang xuanthi 26/12/2022 1940
Bạn đang xem tài liệu "Giáo án Giải tích 2: Các lệnh mẫu Matlab BTL cá nhân môn - Năm học 2016", để tải tài liệu gốc về máy hãy click vào nút Download ở trên.

File đính kèm:

  • docxgiao_an_giai_tich_2_cac_lenh_maumatlabbtl_ca_nhan_mon_nam_ho.docx

Nội dung text: Giáo án Giải tích 2: Các lệnh mẫu Matlab BTL cá nhân môn - Năm học 2016

  1. For internal use only >> M=[1 -1]; >> l=u/norm(u); %norm là độ lớn >> gradf=[diff(f,x) diff(f,y)]; >> diffu=dot(gradf,l); %dot là nhân 2 véc tơ >> diffu=subs(diffu,[x y],M) diffu = -0.7071 Tính tích phân đường loại 1 Ví dụ bài 21 >> syms x y >> y=exp(x); >> f=y^2; >> dl=sqrt(diff(x)^2+diff(y)^2); >> int(f*dl,x,1,3) ans = (exp(6) + 1)^(3/2)/3 - (exp(2) + 1)^(3/2)/3 Ví dụ bài 43 2 2 (Ta có miền Doxy x +y =2x) >> syms x y z t >> x=1+cos(t); >> y=sin(t); >> z=x^2+y^2; >> f=2*x-5*y+3*z; >> dl=sqrt(diff(x,t)^2+diff(y,t)^2+diff(z,t)^2); >> int(f*dl,t,0,2*pi) Warning: Explicit integral could not be found. ans = int((cos(t)^2 + sin(t)^2 + (2*cos(t)*sin(t) - 2*sin(t)*(cos(t) + 1))^2)^(1/2)*(2*cos(t) - 5*sin(t) + 3*sin(t)^2 + 3*(cos(t) + 1)^2 + 2), t == 0 2*pi) 2
  2. For internal use only 4.6032 Tìm cực trị Ví dụ bài 55, cực trị tự do >> syms x y >> f=(x+y^2)*exp(x/2); >> diff(f,x) ans = exp(x/2) + (exp(x/2)*(y^2 + x))/2 >> diff(f,y) ans = 2*y*exp(x/2) >> A=diff(f,x,2); >> B=diff(diff(f,x),y); >> C=diff(f,y,2); >> edit % trong cửa sổ edit ta gõ lệnh như sau function F=ctr1(x) F(1)=exp(x(1)/2) + (exp(x(1)/2)*((x(2))^2 + x(1)))/2; F(2)=2*x(2)*exp(x(1)/2); end % với F(1) F(2) là các phương trình của hệ phi tuyến % chuyển ẩn x thành x(1), ẩn y thành x(2) % lưu file trong cửa sổ edit dưới dạng .m >> fun=@ctr1; >> x0=[5 5]; %chọn khoảng nghiệm dương ban đầu giải hpt >> x=fsolve(fun,x0) x = -2.0000 0 %điểm dừng của hàm: (x,y)=(-2,0) >> diemdung1=x; >> x1=[-5 -5]; %chọn khoảng nghiệm âm ban đầu giải hpt >> x=fsolve(fun,x1) 4
  3. For internal use only >> set(A,'color','r'); %đồ thị y1 là màu đỏ >> hold on >> ezplot(y2); >> hold off >> int(2*x*int(1,y1,y2),2,3) ans = 5/6 Ví dụ bài 77 >> clear >> syms x y >> y=x/sqrt(3); >> ezplot(y) >> y=-x/sqrt(3); >> hold on >> ezplot(y) >> x1=sqrt(4*y-y^2); >> x2=-sqrt(4*y-y^2); >> y=linspace(0,4,100); >> x=sqrt(4*y-y.^2); >> x(2,:)=-sqrt(4*y-y.^2); >> plot(x,y) >> x3=sqrt(2*y-y.^2); >> x4=-sqrt(2*y-y.^2); >> x=sqrt(2*y-y.^2); >> x(2,:)=-sqrt(2*y-y.^2); >> plot(x,y) 6
  4. For internal use only >> r=1; >> x=r*cos(theta); >> y=r*sin(theta); >> h=surf(x,y,z); >> set(h,'facecolor','blue','facealpha',0.2); >> y1=sqrt(2-z.^2-x.^2); >> y2=real(y5); >> hold on >> y3=-sqrt(2-z.^2-x.^2); >> y4=real(y7); >> surf(x,y2,z,'facecolor','blue') >> surf(x,y4,z,'facecolor','blue') >> xlabel('Truc x') >> ylabel('Truc y') >> zlabel('Truc z') >> axis([-2 2 -2 2]) %Giới hạn trục x y >> daspect([2 2 2]) %Làm méo dạng đồ thị >> rotate3d on Tính diện tích mặt chiếu xuống Oxy Tính tích phân bội 3 Ví dụ bài 97* >> syms x y >> z=linspace(0,5,50); %vẽ hình minh hoạ để tính tích phân >> theta=linspace(0,2*pi,50); >> [z,theta]=meshgrid(z,theta); >> r=1; >> x=r*cos(theta); >> y=r*sin(theta); >> h=surf(x,y,z); >> set(h,'facecolor','blue','facealpha',0.2); 8