You are on page 1of 9

EXPERIMENT 3A&3B

NAME: Anand Kholwadiya


REG NO: 21BEC2166
CLASS SLOT: L9 +L10
FACULTY: Ezhilmaran.D

Exp - 3A
(1)
AIM:
The highway department is planning to build a picnic area for motorists along a
major highway. It is to be rectangular with an area of 5,000 square yards and is
to be fenced off on the three sides not adjacent to the highway. What is the
least amount of fencing that will be needed to complete the job?
3x^2+4xy+6y^2=140

MATLAB COMMAND:
St_pts:
St_pts is a variable of type double
Fun_Val:
Fun_Val is a variable of type double.

MATLAB CODE:
clear
clc
syms x y z L
f(x,y)=2*y +x; % Function
g(x,y)=x*y-5000; % Constraint
F=f+L*g;
Fx=diff(F,x);Fy=diff(F,y);
S=solve(g,Fx,Fy,'Real',true); %Solving only for Real x and y
St_pts=[S.x,S.y]; % Stationary points
St_pts=double(St_pts)
Fun_Val=f(S.x,S.y); % Function values at Stationary points
Fun_Val=double(Fun_Val)
% Visualization of Function and constraint
X=linspace(min(S.x)-3,max(S.x)+3,20);X=double(X); % X data
Y=linspace(min(S.y)-3,max(S.y)+3,20);Y=double(Y); % Y data
[X,Y]=meshgrid(X,Y);
Z=f(X,Y);Z=double(Z);
surf(X,Y,Z);hold on; % Function surface
xlabel('x');ylabel('y');zlabel('f(x,y)');
gv=fimplicit(g,'b'); % Constraint curve
hold on;
xv=get(gv,'XData');
yv=get(gv,'YData');
fv=f(xv,yv);fv=double(fv)

OUTPUT:
St_pts = -100 -50 100 50 Fun_Val = -200 200

VISUAL OUT
(2)
AIM:
Find the minimum of f(x, y) = x^2*y^2 subject to the constraint 2x+4y-40.

MATLAB COMMAND:
St_pts:
St_pts is a variable of type double
Fun_Val:
Fun_Val is a variable of type double.
fimplicit(FUN,LIMS) uses the given limits. LIMS can be [XMIN XMAX YMIN YMAX]
or [XYMIN XYMAX] with XYMIN <= X <+ XYMAX and XYMIN <= Y <= XYMAX.
fimplicit(...,'LineSpec') plots with the given line specification.

MATLAB CODE:
Clear
clc
syms x y z L
f(x,y)=x^2*y^2; % Function
g(x,y)=2*x+4*y-40; % Constraint
F=f+L*g;
Fx=diff(F,x);Fy=diff(F,y);
S=solve(g,Fx,Fy,'Real',true); %Solving only for Real x and y
St_pts=[S.x,S.y]; % Stationary points
St_pts=double(St_pts)
Fun_Val=f(S.x,S.y); % Function values at Stationary points
Fun_Val=double(Fun_Val)
% Visualization of Function and constraint
X=linspace(min(S.x)-3,max(S.x)+3,20);X=double(X); % X data
Y=linspace(min(S.y)-3,max(S.y)+3,20);Y=double(Y); % Y data
[X,Y]=meshgrid(X,Y);
Z=f(X,Y);Z=double(Z);
surf(X,Y,Z);hold on; % Function surface
xlabel('x');ylabel('y');zlabel('f(x,y)');
gv=fimplicit(g,'b'); % Constraint curve
hold on;
xv=get(gv,'XData');
yv=get(gv,'YData');
fv=f(xv,yv);fv=double(fv);
plot3(xv,yv,fv,'-r'); %Constrained extrema on the Function surface

OUTPUT:
St_pts = 0 10 20 0 10 5 Fun_Val = 0 0 2500
VISUAL OUTPUT:
(3)
AIM:
Find the dimension of rectangular box with the largest possible
volume with an open top and one portion to be constructed from
162 sq. inches of cardboard. (Note: The amount of the material used
in construction of box is. xy+2xz+2yz=162)

MATLAB COMMAND:
St_pts:
St_pts is a variable of type double
Fun_Val:
Fun_Val is a variable of type double.

MATLAB CODE:
clear
clc
syms x y z L
f(x,y,z)=x*y*z; % Function
g(x,y,z)= x*y + 2*x*z+ 2*y*z-162; % Constraint
F=f+L*g;
Fx=diff(F,x);Fy=diff(F,y); Fz=diff(F,z);
S=solve(g,Fx,Fy,Fz,'Real',true); %Solving only for Real x,y and z
St_pts=[S.x,S.y, S.z]; % Stationary points
St_pts=double(St_pts)
Fun_Val=f(S.x,S.y,S.z); % Function values at Stationary points
Fun_Val=double(Fun_Val)

OUTPUT: -

St_pts =

-7.3485 -7.3485 -3.6742


7.3485 7.3485 3.6742

Fun_Val =

-198.4087
198.4087
Exp - 3B
(1)
AIM:
Find the volume of the solid S that is bounded by the elliptic paraboloid x ^22y^2  z 16, the
planes x  2 and y  2, and the three coordinate planes

MATLAB COMMAND:
view Solid is a version for MATLAB of the routine on page 161 of
"Multivariable Calculus and Mathematica" for viewing the region bounded by two
surfaces for the purpose of setting up triple integrals. The arguments are
entered from the inside out.

MATLAB CODE:
clc
clear all
syms x y z
viewSolid(z, 0+0*x+0*y, 16-x^2-2*y^2,y,0+0*x,2+0*x,x,0,2)
int(int(16-x^2-2*y^2,x,0,2),y,0,2)

OUTPUT:
ans = 48

VISUAL OUTPUT:
(2)
AIM:
Evaluate  R sin x cos y dA where R  [0, / 2][0, / 2]

MATLAB COMMAND:
viewSolid is a version for MATLAB of the routine on page 161
of "Multivariable Calculus and Mathematica" for viewing the
region bounded by two surfaces for the purpose of setting up
triple integrals. The arguments are entered from the inside
out.
MATLAB CODE:
clc
clear all
syms x y z
viewSolidone(z, 0+0*x+0*y, x^2+y^2,x,y/2,sqrt(y),y,0,4)
int(int(x^2+y^2,x,y/2,sqrt(y)),y,0,4)

OUTPUT:
ans = 1

VISUAL OUTPUT:

You might also like