DIGITAL ASSIGNMENT-1(DA-1)
(ANSWER-1)
KANISHK Dwivedi(23BPS1161)
clc
clear all
syms x y real
y1=input('ENTER THE first(f) curve');
y2=input('ENTER THE second(g) curve');
fg=figure;
ax=axes;
t=solve(y1-y2);
k=double(t)
n=length(k)
m1=min(k)
m2=max(k)
ez1=ezplot(y1,[m1-1,m2+1]);
hold on
TA=0;
ez2=ezplot(y2,[m1-1,m2+1]);
if n>2
for i=1:n-1
A=int(y1-y2,t(i),t(i+1))
TA= TA+abs(A)
x1 = linspace(k(i),k(i+1));
yy1 =subs(y1,x,x1);
yy2 = subs(y2,x,x1);
x1 = [x1,fliplr(x1)];
yy = [yy1,fliplr(yy2)];
fill(x1,yy,'g')
grid on
end
else
A=int(y1-y2,t(1),t(2))
TA=abs(A)
x1 = linspace(k(1),k(2));
yy1 =subs(y1,x,x1);
yy2 = subs(y2,x,x1);
x1 = [x1,fliplr(x1)];
yy = [yy1,fliplr(yy2)];
fill(x1,yy,'g')
end
INPUT- Kanishk
Dwivedi(23BPS1161)
OUTPUT- Kanishk Dwivedi(23BPS1161)
(ANSWER-2) Kanishk
Dwivedi(23bps1161)
clc
clear all
syms x y k T3 real
f = input('Enter the function f(x,y): ');
fx = diff(f,x);
fy = diff(f,y);
[ax ay] = solve(fx,fy);
fxx = diff(fx,x);
D = fxx*diff(fy,y) - diff(fx,y)^2;
r=1;
for k=[Link]size(ax)
if((imag(ax(k))==0)&&(imag(ay(k))==0))
ptx(r)=ax(k);
pty(r)=ay(k);
r=r+1;
end
end
a1=max(double(ax))
a2=min(double(ax))
b1=max(double(ay))
b2=min(double(ay))
ezsurf(f,[a2-.5,a1+.5,b2-.5,b1+.5])
colormap('summer');
shading interp
hold on
for r1=[Link](r-1)
T1=subs(subs(D,x,ptx(r1)),y,pty(r1));
T2=subs(subs(fxx,x,ptx(r1)),y,pty(r1));
if(double(T1) == 0)
sprintf('The point (x,y) is (%d,%d) and
need further investigation',
double(ptx(r1)),double(pty(r1)))
elseif(double(T1) < 0)
T3=subs(subs(f,x,ptx(r1)),y,pty(r1))
sprintf('The point (x,y) is (%d,%d) a
saddle point',
double(ptx(r1)),double(pty(r1)))
plot3(double(ptx(r1)),double(pty(r1)),doubl
e(T3),'b.','markersize',30);
else
if(double(T2) < 0)
sprintf('The maximum point(x,y) is (%d,
%d)', double(ptx(r1)),double(pty(r1)))
T3=subs(subs(f,x,ptx(r1)),y,pty(r1))
sprintf('The value of the function is %d',
double(T3))
plot3(double(ptx(r1)),double(pty(r1)),doubl
e(T3),'r+','markersize',30);
else
sprintf('The minimum point(x,y) is (%d,
%d)', double(ptx(r1)),double(pty(r1)))
T3=subs(subs(f,x,ptx(r1)),y,pty(r1))
sprintf('The value of the function is %d',
double(T3))
plot3(double(ptx(r1)),double(pty(r1)),doubl
e(T3),'m*','markersize',30);
end
end
end
INPUT-
Kanishk Dwivedi(23BPS1161)
OUTPUT- Kanishk
Dwivedi(23BPS1161)