Professional Documents
Culture Documents
2) Make a table of values of the average rate of change of f with respect to t over
the interval [2, T], for some values of T ap
Sol-
syms f(t); f(t)=1/t;
avg2=(f(2.1)-f(2))/(2.1-2 )
avg3=(f(2.01)-f(2))/(2.01-2)
avg4=(f(2.001)-f(2))/(2.001-2)
avg5=(f(2.0001)-f(2))/(2.0001-2)
avg6=(f(2.00001)-f(2))/(2.00001-2)
avg7=(f(2.000001)-f(2))/(2.000001-2)
T=[2.1;2.01;2.001;2.0001;2.00001;2.000001];
average=[avg2;avg3;avg4;avg4;avg5;avg6;avg7];
table(T,average)
3) Find the maximum and minimum values of the function x 3 - 3x + 3xy2 and also
find saddle point of the function.
Sol- syms x y
f=(x^3)+(3*x)+(3*x*y^2);
fx = diff(f,x);
fy = diff(f,y);
[xc,yc] = solve([fx,fy],[x y]);
fxx = diff(fx,x);
fyy = diff(fy,y);
fxy = diff(fx,y);
r=subs(fxx,{x,y},{xc,yc});
D = fxx*fyy - fxy^2;
D=subs(D,{x,y},{xc,yc});
c=1;
for i=1:length(D)
if(D(i)>0)
if(r(i)>0)
fprintf('(%f,%f) is a minima\n',xc(i),yc(i));
elseif(r(i)<0)
fprintf('(%f,%f) is a maxima\n',xc(i),yc(i));
end
elseif(D(i)<0)
fprintf('(%f,%f) is a sadddle point\n',xc(i),yc(i));
else
fprintf('at (%f,%f) test is inconclusive \n',xc(i),yc(i));
end
c=c+1;
end
5) Find local maxima, local minima and saddle point for the function f(x, y)=10xye
^ -(x 2+y 2)
Sol- clc
close all
clear all
syms x y
f=10xyexp(-(x^2+y^2))
fx=diff(f,x)
fy=diff(f,y)
[xc,yc]=solve([fx,fy],[x,y])
fxx = diff(fx,x);
fxy = diff(fx,y);
fyy = diff(fy,y);
r = subs(fxx,{x,y},{xc,yc});
D = fxxfyy - fxy^2;
D=subs(D,{x,y},{xc,yc});
c=1;
for i=1: length(D)
if D(i)>0
if r(i)>0
fprintf('(%f,%f) is a point of minima\n',xc(i),yc(i));
elseif r(i)<0
fprintf('(%f,%f) is a point of maxima\n',xc(i),yc(i));
end
else if D(i)<0
fprintf('(%f,%f) is a saddle point\n',xc(i),yc(i));
else
fprintf('(%f,%f) test is incloncusive needs further investigation\n',xc(i),yc(i));
end
c=c+1;
end
SOL:-
clear all
syms x y z k
f= x*y;
g=x^2+y^2-1;
F=f+k*g;
Fx=diff(F,x);
Fy=diff(F,y);
Fk=diff(F,k);
[xc yc,k]=solve([Fx,Fy,Fk],[x,y,k])
f_val=subs(f,{x,y},{xc,yc})
[maxv i]=max(f_val)
[minv j]=min(f_val)
fprintf('The function has a point of maxima at (%f,%f)\n',xc(i),yc(i))
fprintf('The function has a point of minima at (%f,%f)\n',xc(j),xc(j))
LAB-2
1) Find the area of the region bounded below by the line y = 2 - x and above by the
curve y = v 2x - x 2.
Sol-
syms x y
f=sqrt(2*x*-x^2);
g=2-x;
areal=int(int(1,y,2-x,sqrt(2*x-x^2)))
fplot(f)
hold on
fplot(g)
clc
clear all
theta = 0:0.01:2*pi;
r= sqrt(4*cos(2*theta));
polarplot(theta,r);
syms r theta
area1=4*int(int(r,0,sqrt(4*cos(2*theta))),theta,0,pi/4)
Sol-clc
clear all
syms x y z
z1=8-x^2-y^2;
z2=x^2+3*y^2;
ry=solve(z1-z2,y);
ylim1=ry(1);
ylim2=ry(2);
rx=solve(ry(1),x);
xlim1=rx(1);
xlim2=rx(2);
volume=int(int(int(1,z,z2,z1),y,ylim1,ylim2),x,xlim1,xlim2)
volume1=vpa(volume)
viewSolid(z,z2,z1,ylim1,ylim2,x,-2,2)
rotate3d on
5)Find the volume, centre of mass, moments of inertia of the region bounded by the
paraboloids z = 4 - x 2 - y 2 and z = x 2 + y 2 whose density is d = 1 + x.
Sol-clc
syms x y z
z1=8-x^2-y^2;
z2=x^2+3*y^2;
ry=solve(z1-z2,y);
ylim1=ry(1);
ylim2=ry(2);
rx=solve(ry(1),x);
xlim1=rx(1);
xlim2=rx(2);
volume=int(int(int(1,z,z2,z1),y,ylim1,ylim2),x,xlim1,xlim2);
volume1=vpa(volume)
d=1+x;
M=vpaintegral(vpaintegral(int(d,z,z2,z1),y,ylim1,ylim2),x,xlim1,xlim2);
Myz=vpaintegral(vpaintegral(int(d*x,z,z2,z1),y,ylim1,ylim2),x,xlim1,xlim2);
Mxz=vpaintegral(vpaintegral(int(d*y,z,z2,z1),y,ylim1,ylim2),x,xlim1,xlim2);
Mxy=vpaintegral(vpaintegral(int(d*z,z,z2,z1),y,ylim1,ylim2),x,xlim1,xlim2);
CM=[Myz/M Mxz/M Mxy/M]
Mx=vpaintegral(vpaintegral(int(d*(y^2+z^2),z,z2,z1),y,ylim1,ylim2),x,xlim1,xlim2);
My=vpaintegral(vpaintegral(int(d*(x^2+z^2),z,z2,z1),y,ylim1,ylim2),x,xlim1,xlim2);
Mz=vpaintegral(vpaintegral(int(d*(x^2+y^2),z,z2,z1),y,ylim1,ylim2),x,xlim1,xlim2);
MI=[Mx,My,Mz]