Báo cáo bài tập lớn môn Giải tích 1 tiến hành Viết chương trình tính diện tích miền phẳng D và vẽ miền D minh họa dựa trên bài toán cho miền D trong mặt phẳng giới hạn bởi f=f(x),y=g(x),x=a,x=b (f(x),g(x),a,b, nhập từ bàn phím). Mời các bạn cùng tham khảo báo cáo để nắm chi tiết nội dung nghiên cứu.
Trang 1 CH ƯƠ NG TRÌNH CODE VÀ VÍ D Ụ
đ tài 1: ề
cho mi n D trogn m t ph ng gi i h n b i f=f(x),y=g(x),x=a,x=b (f(x),g(x),a,b, nh p t bàn ề ặ ẳ ớ ạ ở ậ ừ phím). Vi t ch ế ươ ng trình tính di n tích mi n ph ng D và v mi n D minh h a ệ ề ẳ ẽ ề ọ
function detai1
syms x;
f = input('f(x)= ');
g = input('g(x)= ');
disp('[a b]: ');
a = input('a = ');
b = input('b = ');
s = int(abs(fg),a,b);
fprintf('dien tich mien D la: %f\n',s);
x1 = linspace(a,b);
x2 = linspace(b,a);
y1 = subs(f,x,x1);
y2 = subs(g,x,x2);
fill([x1,x2],[y1,y2],'r');
title(sprintf('Area D is: %f',s));
hold off;
end
vd1:
>> detai1
f(x)= 2*x^3+6*x+7
g(x)= 4*x^2+5*x+6
[a b]:
a = 5
b = 6
dien tich mien D la: 871.166667
>>
Trang 2>> detai1
f(x)= x+25
g(x)= 3*x^2+6*x+7
[a b]:
a = 1
b = 10
dien tich mien D la: 1092.469002
>>
đ tài 3: ề
Trang 3Cho hàm f(x) có d ng phân th c. Vi t ch ạ ứ ế ươ ng trình tìm c c tr , ti m c n và v đ th c a ự ị ệ ậ ẽ ồ ị ủ y=f(x) v i đi m c c tr và các đ ớ ể ự ị ườ ng ti m c n trên đ th ệ ậ ồ ị
function detai3
syms x;
f = input('f(x) = ');
fprintf('\n');
% Vertical asymptote
[numerator,denominator] = numden(f);
xV = vpa(solve(denominator));
v_As = [];
for i=xV'
if isreal(i)
l = limit(f^2,x,i);
if l==l1
fprintf('tiem can dung x = %f \n',i);
v_As = [v_As,i];
end;
end;
end;
fprintf('\n');
% Horizontal asymptote
h_As=[limit(f,x,inf), limit(f,x,inf)];
if h_As(1)~=h_As(1)1
fprintf('tiem can ngang y = %f\n',h_As(1));
end
if h_As(2)~=h_As(2)1
if h_As(1)~=h_As(2)
fprintf('tiem can ngang y = %f\n',h_As(2));
end
end
fprintf('\n');
% Diagonal asymptote
aD1 = limit(f/x,x,inf);
bD1 = limit(faD1*x,x,inf);
aD2 = limit(f/x,x,inf);
bD2 = limit(faD2*x,x,inf);
D1(x) = aD1*x + bD1;
D2(x) = aD2*x + bD2;
if aD1~=0 || aD2 ~= 0
if aD1==aD2 && bD1 == bD2
fprintf('tiem can xien y = %fx + %f\n',aD1,bD1);
else
fprintf('tiem can xien y = %fx + %f\n',aD1,bD1);
fprintf('tiem can xien y = %0.4fx + %0.4f\n',aD2,bD2);
end
end
fprintf('\n');
%max min
f1=diff(f);
f2=diff(f,2);
ct=vpa(solve(f1));
hold on;
for i=ct'
if isreal(ct)
if subs(f2,i)>0
fprintf('ham so dat cuc tieu tai x = %f , Fmin = %f\n',i,subs(f,i));
Trang 4plot(i,subs(f,i),'ko'); text(double(i),double(subs(f,i)),' <local min'); elseif subs(f2,i)<0
fprintf('ham so dat cuc dai tai x = %f , Fmax = %f\n',i,subs(f,i)); plot(i,subs(f,i),'ko'); text(double(i),double(subs(f,i)),' <local max'); else
fprintf('ham so co diem uon tai x = %f\n',i);
end
end
end
% Draw
ezplot(f);
for i=v_As
yDraw = [100,100];
xDraw = [i i];
plot(xDraw,yDraw,'r');
end;
for i=h_As
xDraw = [100,100];
yDraw = [i i];
plot(xDraw,yDraw,'r');
end;
xDraw = [100,100];
yDraw = D1(xDraw);
plot(xDraw,yDraw,'r');
yDraw = D2(xDraw);
plot(xDraw,yDraw,'r');
xlabel('x'); ylabel('y'); grid on; hold off;
end
vd1:
>> detai3
f(x) = (4*x^2+5*x+6)/(2*x+3)
tiem can dung x = 1.500000
tiem can xien y = 2.000000x + 0.500000
ham so dat cuc dai tai x = 2.869306 , Fmax = 8.977226
ham so dat cuc tieu tai x = 0.130694 , Fmin = 1.977226
>>
Trang 5>> detai3
f(x) = (x+1)/sqrt(x^2+1)
tiem can ngang y = 1.000000
tiem can ngang y = 1.000000
ham so dat cuc dai tai x = 1.000000 , Fmax = 1.414214
>>
Trang 6đ tài 5: ề
Cho D gi i h n b i y=f(x), y=g(x),x=a,x=b. Vi t ch ớ ạ ở ế ươ ng trình tính th tích v t th t o ra khi ể ậ ể ạ cho mình D quay quanh truc Ox
function detai5
syms x;
f = input('f(x)= ');
g = input('g(x)= ');
disp('[a b]: ');
a = input('a = ');
b = input('b = ');
% Tinh tich phan bang cong thuc Simpson mo rong
m = 300;
h = (ba)/m;
I = 0;
for i=0:m
x = a+h*i;
f = subs(f,x);
g = subs(g,x);
if f*g<=0
y = max(f^2,g^2);
else
y = abs(f^2g^2);
end
if (i==0 || i==m)
I = I + y;
elseif (mod(i,2)==0)
I = I + 2*y;
else
I = I + 4*y;
Trang 7end
I = pi*I*h/3;
fprintf('the tich khoi tron xoay: S = %f\n',I);
end
vd1:
>> detai5
f(x)= x^2+6*x+7
g(x)= 7*x^3+2*x^2+5
[a b]:
a = 1
b = 1
the tich khoi tron xoay: S = 25.132741
>>
vd2:
>> detai5
f(x)= 5*x+55
g(x)= 4*x^2+5*x+3
[a b]:
a = 6
b = 10
the tich khoi tron xoay: S = 656668.262824
>>
đ tài 7: ề
Nh p hàm s y=f(x) liên t c trên (1,+ ậ ố ụ ) (không c n ki m tra tính liên t c). Vi t ch ầ ể ụ ế ươ ng trình
kh o sát s h i t c u tích phân suy r ng lo i 1:. N u tích phân h i t hãy tính di n tích mi n ả ự ộ ụ ả ộ ạ ế ộ ụ ệ ề
D gi ướ ạ i h n b i y=f(x), y=0,x=a. V mi n D. ở ẽ ề
function cau7
syms x
f=input('nhap ham f= ' );
g=0;
t=vpa(int(f,x,1,inf))
if t==t1
fprintf('tich phan phan ki\n\n');
else
fprintf('tich phan hoi tu\n');
a=input('nhap bien tinh dien tich: a= ');
s = int(abs(f),1,a);
fprintf('dien tich mien D la: %f\n',s);
x1 = linspace(1,a);
x2 = linspace(a,1);
y1 = subs(f,x1);
y2 = subs(0,x2);
fill([x1,x2],[y1,y2],'r');
title(sprintf('Area D is: %f',s));
hold off;
end
vd1:
Trang 8nhap ham f= (4*x^2+5*x)/(6*x^3+9*x^2+6*x+1)
t =
Inf
tich phan phan ki
>>
vd2:
>> cau7
nhap ham f= (2+x)/(4*x^3+6*x+7)
t =
0.2796941889421910210732829962181
tich phan hoi tu
nhap bien tinh dien tich: a= 9
dien tich mien D la: 0.249047
>>
đ tài 9: ề
Cho hàm y=y(x) xác đ nh b i ph ị ở ươ ng trình tham s y=y(t), x=x(t) (y=y(t),x=x(t) là các hàm ố phân th c nh p t ban phím). Tìm c c tr b ng cách tính đ p hàm c p 1 và đ o hàm c p 2. V ứ ậ ừ ự ị ằ ạ ấ ạ ấ ẽ hình minh h a ọ
function detai9
syms t
y = input('nhap ham y theo t: y(t)= ');
x = input('nhap ham x theo t: x(t)= ');
Trang 9f1 = diff(y)/diff(x);
f2 = diff(f1)/diff(x);
ct = vpa(solve(f1));
d=0; tmin=[]; tmax=[];
%tim cuc tri
for i=ct'
if isreal(i)
if subs(f2,i)>0
d=1;
fprintf('ham so dat cuc tieu tai x= %f, Fct= %f\n',subs(x,i),subs(y,i));
tmin=[i tmin];
elseif subs(f2,i)<0
d=1;
fprintf('ham so dat cuc dai tai x= %f, Fcd= %f\n',subs(x,i),subs(y,i));
tmax=[i tmax];
else
fprintf('ham so co diem uon tai x= %f',subs(x,i));
end
end
end
if d==0
disp('ham so khong co cuc tri');
end
%ve do thi
%y(x)
subplot(2,1,1)
grid on
fplot(x,y); hold on
%ve diem cuc tri tren y(x)
for i=tmin
plot(subs(x,i),subs(y,i),'ko'); text(double(subs(x,i)),double(subs(y,i)),' <local min');
end
for i=tmax
plot(subs(x,i),subs(y,i),'ko'); text(double(subs(x,i)),double(subs(y,i)),' <local max');
end
title('y=f(x)'); xlabel('x'); ylabel('y(x)');
%x(t) va y(t)
subplot(2,1,2)
grid on
fplot(x,'r'); hold on;
fplot(y,'b'); xlabel('t'); ylabel('x(t) va y(t)');
for i=tmin
plot(i,subs(x,i),'ko'); text(double(i),double(subs(x,i)),' <local x min');
plot(i,subs(y,i),'ko'); text(double(i),double(subs(y,i)),' <local y min');
end
for i=tmax
plot(i,subs(x,i),'ko'); text(double(i),double(subs(x,i)),' <local x max');
plot(i,subs(y,i),'ko'); text(double(i),double(subs(y,i)),' <local y max');
end
title(sprintf('x = %s, y = %s',char(x),char(y)));
legend(char(x),char(y))
end
Trang 10>> detai9
nhap ham y theo t: y(t)= 5*t^3+6*t+7
nhap ham x theo t: x(t)= 400100*t
ham so khong co cuc tri
>>
vd2:
>> detai9
nhap ham y theo t: y(t)= 5*t^2+6*t+7
nhap ham x theo t: x(t)= 10073*t
ham so dat cuc tieu tai x= 143.800000, Fct= 5.200000
>>
Trang 11 PH N COMMAND WINDOW Ầ
ITính Gi i H nớ ạ
Câu 1
>> syms n
>> limit((n+(1)^n)/(n(1)^n), inf)
ans =
1
Câu 3
>> syms n
>> limit(sqrt(n^2 + 4*n) n + 1, inf)
ans =
3
Câu 5
>> syms x
>> limit(((x 3)/(x+2))^(2*x+ 1), inf)
ans =
exp(10)
Câu 7
>> syms x
Trang 12ans =
Inf
Câu 9
>> syms n
>> limit((2*n^3 4^(n+1))/(3^n 2^(2*n1)+ 5*n^7), inf)
ans =
8
II Tính Đ o Hàm:ạ
Câu 11
>> syms x
>> subs(diff((x+sin(x))^x, 1),pi/4)
ans =
log(pi/4 + 2^(1/2)/2)*(pi/4 + 2^(1/2)/2)^(pi/4) + (pi*(2^(1/2)/2 + 1)*(pi/4 + 2^(1/2)/2)^(pi/4 1))/4 Câu 13
>> syms t
>> xt=subs(diff(t^3+ 3*t, 1), 2)
xt =
15
>> yt=subs(diff(log(t+ sqrt(t^2 3)), 1), 2)
yt =
1
>> yx=yt/xt
yx =
1/15
Câu 15
>> syms x
>> subs(diff(log(tan(pi/4+ x/2)), 2), 0)
ans =
0
Câu 17
>> syms x
>> subs(diff(exp(x)/x^2,2), 1)
ans =
3*exp(1)
Câu 19
>> syms x
>> subs(diff(exp(2*x)*sin(3*x), 3), 0)
ans =
9
III. Tính tích phân
Trang 13>> syms x
>> int(x*log(x), 1, 2)
ans =
log(4) ¾
Câu 23
>> syms x
>> int(x*atan(x), 0, 1)
ans =
pi/4 ½
Câu 25
>> syms x
>> int(exp(x^2), 0, inf) ans =
pi^(1/2)/2
Câu 27
>> syms x
>> int(1/(x^3+ 1),0, inf) ans =
(2*pi*3^(1/2))/9
IV Di n Tích Mi n Ph ng:ệ ề ẳ
Câu 29
>> syms x y
>> int(abs(x^2x2), 1, 2) ans =
9/2
Câu 31
>> syms x
>> solve('3/x=4x ')
ans =
1
3
>> int(abs(4x3/x), 1, 3) ans =
4 log(27)
Câu 33
>> syms x
Trang 14x0 =
2
>> int(abs(log(x+2) 2*log(x)), 1/exp(1), x0)
ans =
(829873891399877939*log(2))/9007199254740992 +
(6627126856707895*log(6627126856707895))/9007199254740992
(42655923875671863*log(42655923875671863))/18014398509481984 + 29401670162256073/18014398509481984 Câu 35
>> syms x
>> solve('asin(x)=pi/2 ')
ans =
1
>> int(abs(asin(x)pi/2), 0, 1)
ans =
1
V Tính Di n Tích M t Congệ ặ
Câu 37
>>syms x
>> int(sqrt(1+x^2),0,1)
ans =
log(2^(1/2) + 1)/2 + 2^(1/2)/2
Câu 39
b ch n b i y=4. Tính Sị ắ ở x
>> syms x
>> solve(‘5*x+x^2=4’)
ans =
41^(1/2)/2 5/2
41^(1/2)/2 5/2
>> a=41^(1/2)5/2;
>>b= 41^(1/2)/2 5/2;
>> =int(abs(5*x+x^2),a,b)
ans =
18520397305221071401051528028275585785857/1020847100762815390390123822295304634368
VITính Th Tíchể
Câu 41
>> syms x
>> solve(sqrt(1x^2)==0)
Trang 151
1
>> f=sqrt(1x^2)
f =
(1 x^2)^(1/2)
>> Vx=pi*int(f^2, 1, 1)
Vx =
(4*pi)/3
Câu 43
>> syms x
>> solve(x^2+ 1==5)
ans =
2
2
>> f=x^2+15
f =
x^2 4
>> Vy=2*pi*int(abs(x*f), 0, 2)
Vy =
8*pi
Câu 45
>> syms x
>> Vy=2*pi*int(abs(x*(2*x x^2 3)), 0, 3)
Vy =
(63*pi)/2
VII Tính Đ Dài Độ ường Cong:
bài 47
>> syms x
>> y=sqrt(x^3);
>> A=diff(y)
A =(3*x^2)/(2*(x^3)^(1/2))
>> B=sqrt(1+A^2)
B = ((9*x)/4 + 1)^(1/2)
>> int(B,0,4)
ans = (80*10^(1/2))/27 8/27
bài 49
>> syms x
>> y=log(cos(x))
y = log(cos(x))
>> A=diff(y)
A = sin(x)/cos(x)
>> B=sqrt(1+A^2)
B =(sin(x)^2/cos(x)^2 + 1)^(1/2)
>> int(B,0,pi/4)
Trang 16VIII Gi i Phả ương Trình Vi Phân:
Câu 51
>> syms y(x)
>> y=dsolve(x*diff(y)y==sqrt(x^2+ y^2))
y =
(C19^2*x^2 4)/(4*C19)
x*i
x*i
Câu 53
>> syms y(x)
>> dsolve(diff(y,2)3*diff(y)+2*y==3*exp(2*x),y(0)==1,subs(diff(y),0)==1)
ans =
4*exp(x) 3*exp(2*x) + 3*x*exp(2*x)
Câu 55
>> syms y(x)
>> dsolve(diff(y)+3*y/x==2/x^3, y(1)==0)
ans
2/x^2 2/x^3
IX: Tính Đ o Hàm Trái, Ph i t i x=xạ ả ạ 0 và v đẽ ường cong cùng ti p tuy t t i (xế ế ạ 0,f(x0)) Câu 57
>>syms x
>>f=(exp(x)1)/x;
>>g=x/2;
>>f1=diff(f);
>>g1=diff(g)
g1 =
1/2
>>limit(f1,x,0,'right')
ans =
1/2
>>x1=0:0.01:3;
>>y1=(exp(x1)1)./x1;
>>plot(x1,y1)
Trang 17>>x2=3:0.01:0;
>> y2=x2./2;
>>plot(x2,y2)
>> x3=0:0.01:3;
>>y3=(x32)/2+subs(f,x,2);
>> plot(x3,y3)
H T Ế
****