0% found this document useful (0 votes)
66 views

20bce7453 Matlab12 1

This document contains the solutions to 7 problems in a calculus lab assignment for engineers. The problems involve calculating derivatives, integrals, finding extrema of functions, and determining maxima, minima and saddle points. Visualizations are provided for some solutions. The document demonstrates skills in symbolic calculus, solving equations, and applying concepts like Lagrange multipliers to optimization problems.

Uploaded by

Pranav
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
66 views

20bce7453 Matlab12 1

This document contains the solutions to 7 problems in a calculus lab assignment for engineers. The problems involve calculating derivatives, integrals, finding extrema of functions, and determining maxima, minima and saddle points. Visualizations are provided for some solutions. The document demonstrates skills in symbolic calculus, solving equations, and applying concepts like Lagrange multipliers to optimization problems.

Uploaded by

Pranav
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 5

CALCULUS FOR ENGINEERS

NAME:- CHIRAG GUPTA


REG NO:- 20BCE7453

Lab problem solution


LAB-1
1.)Let f(t) = 1 t for t not equal to zero. Find the average rate of change of f
with respect to t over the intervals (a) from t=2 to t=3, (b) from t=2 to t=T.
Sol- (a) syms t
f(t) = 1/t;
t=2; t=3;
f(3)-f(2)/3-2
disp(t)
(b) syms t
syms T
f(t)=1/t;
t=2;
t=T;
f(T)-f(2)/T-2
disp(t)

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

4) Check whether the function w(x, y) = sin(px) + sin(py) is solution of


(? 2w /?x2 )+ (? 2w/ ?y2 )= 0?
Sol-
syms x y
f=sin(pi*x)+sin(pi*y);
fx = diff(f,x);
fy = diff(f,y);
fxx = diff(fx,x);
fyy = diff(fy,y);
sum=(fxx+fyy)
if (sum==0)
fprintf("it is not a solution")
else
fprintf("it is a solution")
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

6) Find the maximum and minimum value of 2x + 4y subject to the constraint x2 + y2


= 4 and visualize it on the coordinate axes.
Sol-
syms x y z k
f=2*x+4*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),yc(j))
fcontour(g)
hold on
fcontour(f)
rotate3d on

7) Find the extremum of function x 2+ y2 - 1 using Lagrange multipliers

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)

2)(a)Find the area between the curves -x 2 + 6 and x 2 - 2x + 2.


(b)Covert the following integral v 1-x2 (x 2 + y 2 ) dydx
in polar form and evaluate it.
Sol-
a)clc
clear all
syms x
plot_range=[-3,3];
f1=-x^2+6;
f2=x^2-2*x+2;
roots_intersect=sort(double(solve(f1-f2)));
area_intersect=int(f1-f2,roots_intersect(1),roots_intersect(2))
range= roots_intersect(1):0.1:roots_intersect(2);
y=subs(f1,range);
area(range,y,'FaceColor''[0,0,1],'LineStyle','none')
hold on;
b)
% x=rcostheta and y=rsintheta
f = @(theta,r) r.*((cos(theta).^2)+(sin(theta).^2));
rmax= @(theta) sqrt(1-(cos(theta).^2));
integral2(f,0,1,0,rmax)

3 Find the area enclosed by the lemniscate r2 = 4 cos 2?.


SOL:-

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)

4)Find the volume of the region D enclosed by the surfaces z = x 2 + 3y 2 and z


= 8 - x 2- y2

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]

You might also like