EXPERIMENT 3-A
1. Draw the surface of the function f (x, y) = ex+ey using ezsurf.
Solution:
syms x y
f=exp(x)+exp(y)
ezsurf(f)
colormap
cool
Input and Output:
2. Draw the 3-D plot for the function f(t)= (t, t2, t3), where 0≤t≤ 100.
Solution:
t=linspace(0,100);
x=t;
y=t.^2;
z=t.^3;
comet3(x,y,z);
plot3(x,y,z);
xlabel('x-axis');
ylabel('y-axis');
zlabel('x-axis');
title('3D Curve')
Output:
3. Using ‘surf’ plot the surface f (x, y) = x(x2+y2).
Solution:
[x,y]=meshgrid(-2:.2:2);
f=x.*(x.^2 + y.^2);
surf(x,y,f)
Output:
4. Expand f (x, y) = ex ln(1+y) in terms of x and y up to the terms of 3rd degree
using Taylor series.
Solution:
clear
clc
close all
syms x y
f=input('Enter the function f(x,y): ');
I=input('Enter the point[a,b] at which Taylor series is sought: ');
a=I(1);b=I(2);
n=input('Enter the order of series:');
tayser=taylor(f,[x,y],[a,b],'order',n)
subplot(1,2,1);
ezsurf(f);
subplot(1,2,2);
ezsurf(tayser);
Input:
Output:
5. Expand exy in Taylor series the neighbourhood of (1,1).
Solution:
clear
clc
close all
syms x y
f=input('Enter the function f(x,y): ');
I=input('Enter the point[a,b] at which Taylor series is sought: ');
a=I(1);b=I(2);
n=input('Enter the order of series:');
tayser=taylor(f,[x,y],[a,b],'order',n)
subplot(1,2,1);
ezsurf(f);
subplot(1,2,2);
ezsurf(tayser);
Input and Output:
exp(1) + exp(1)*(x - 1) + exp(1)*(y - 1) + (exp(1)*(x - 1)^2)/2 + (exp(1)*(x -
1)^3)/6 + (exp(1)*(x - 1)^4)/24 + (exp(1)*(y - 1)^2)/2 + (exp(1)*(y - 1)^3)/6
+ (exp(1)*(y - 1)^4)/24 + (7*exp(1)*(x - 1)^2*(y - 1)^2)/4 + 2*exp(1)*(x -
1)*(y - 1) + (3*exp(1)*(x - 1)^2*(y - 1))/2 + (3*exp(1)*(x - 1)*(y - 1)^2)/2 +
(2*exp(1)*(x - 1)^3*(y - 1))/3 + (2*exp(1)*(x - 1)*(y - 1)^3)/3
EXPERIMENT 3-B
Theory:
Let z f (x, y) be the given function. Critical points are points in the xy plane
where the tangent plane is horizontal. The tangent plane is horizontal, if its
normal vector points in the z direction. Hence, critical points are solutions of
the equations: f x (x, y) 0 and f y (a, b) 0.
Find the maxima and minima for the following functions
1. f (x, y) = x4+y4-x2-y2+1
syms x y
f(x,y)=input('Enter the function f(x,y):');
p=diff(f,x); q=diff(f,y);
[ax,ay]=solve(p,q);
ax=double(ax);ay=double(ay);
r=diff(p,x); s=diff(p,y); t=diff(q,y);D=r*t-s^2;
figure
fsurf(f);
legstr={'Function Plot'};
for i=1:size(ax)
T1=D(ax(i),ay(i));
T2=r(ax(i),ay(i));
T3=f(ax(i),ay(i));
if(double(T1)==0)
sprintf('At (%f,%f) further investigation is required',ax(i),ay(i))
legstr=[legstr,{'Case of Further investigation'}];
mkr='ko';
elseif (double(T1)<0)
sprintf('The point (%f,%f) is a saddle point', ax(i),ay(i))
legstr=[legstr,{'Saddle Point'}];
else
if (double(T2) < 0)
sprintf('The maximum value of the function is f(%f,%f)=%f', ax(i),ay(i), T3)
legstr=[legstr,{'Maximum value of the function'}];
mkr='g+';
else
sprintf('The minimum value of the function is f(%f,%f)=%f', ax(i),ay(i), T3)
legstr=[legstr,{'Minimum value of the function'}];
mkr='r*';
end
end
hold on
plot3(ax(i),ay(i),T3,mkr,'Linewidth',4);
end
legend(legstr,'Location','Best');
Input:
Enter the function f (x, y):
x^4+y^4-x^2-y^2+1
Output:
2. f (x, y) = x3+3xy2-15x2-15y2+72x
syms x y
f(x,y)=input('Enter the function f(x,y):');
p=diff(f,x); q=diff(f,y);
[ax,ay]=solve(p,q);
ax=double(ax);ay=double(ay);
r=diff(p,x); s=diff(p,y); t=diff(q,y);D=r*t-s^2;
figure
fsurf(f);
legstr={'Function Plot'};
for i=1:size(ax)
T1=D(ax(i),ay(i));
T2=r(ax(i),ay(i));
T3=f(ax(i),ay(i));
if(double(T1)==0)
sprintf('At (%f,%f) further investigation is required',ax(i),ay(i))
legstr=[legstr,{'Case of Further investigation'}];
mkr='ko';
elseif (double(T1)<0)
sprintf('The point (%f,%f) is a saddle point', ax(i),ay(i))
legstr=[legstr,{'Saddle Point'}];
else
if (double(T2) < 0)
sprintf('The maximum value of the function is f(%f,%f)=%f', ax(i),ay(i), T3)
legstr=[legstr,{'Maximum value of the function'}];
mkr='g+';
else
sprintf('The minimum value of the function is f(%f,%f)=%f', ax(i),ay(i), T3)
legstr=[legstr,{'Minimum value of the function'}];
mkr='r*';
end
end
hold on
plot3(ax(i),ay(i),T3,mkr,'Linewidth',4);
end
legend(legstr,'Location','Best');
Input:
Enter the function f(x,y):
x^3+3*x*(y^2)-15*(x^2)-15*(y^2)+72*x
Output: