With Out Name
With Out Name
Matlab code:
clc
clear all
% Set up the region
x = linspace(0, 3, 100);
y = linspace(0, sqrt(2), 100);
[X, Y] = meshgrid(x, y);
Output:
problem 2:
Matlab code:
% Define the surface function
f = @(x, y, z) x.^2.*y + 2*x.*z.^2 - 8;
Output:
Normal vector at (1,0,2): 8 1 8
Directional derivative at (1,0,2) in the direction of v: 7.8144
>>
problem 3:
Matlab code:
clc
clear all
% Define the vector function F
syms x y z
F = [x+y, y-z, z];
problem 4:
Matlab code:
Output:
Line integral: -0.029753 -0.05673 -0.082345 -0.10555 -0.12546
-0.1414 -0.15295 -0.15995 -0.16253 -0.16105 -0.1561
-0.14842 -0.13888 -0.12838 -0.11782 -0.10804 -0.099802
-0.093721 -0.09027 -0.089761 -0.092344 -0.098017 -0.10663
-0.11793 -0.13152 -0.14696 -0.16373 -0.18128 -0.19903
-0.2164 -0.23284 -0.24782 -0.26084 -0.27146 -0.27931
-0.28406 -0.28547 -0.28338 -0.27767 -0.26832 -0.25538
-0.23896 -0.21926 -0.1965 -0.171 -0.14311 -0.11323
-0.081793 -0.049257 -0.016107 0.017165 0.050061 0.082093
0.11279 0.14169 0.16839 0.1925 0.2137 0.23171
0.2463 0.25733 0.2647 0.2684 0.2685 0.26511 0.25845
0.24878 0.23645 0.22185 0.20545 0.18774 0.16926
0.15058 0.13227 0.11488 0.098958 0.084994 0.073413
0.064552 0.058641 0.055782 0.055937 0.058912 0.064355
0.071763 0.080489 0.089769 0.098758 0.10656 0.11231
0.11519 0.11451 0.10975 0.10063 0.087103 0.069408
0.048042 0.023743 -0.0025472
>>
problem 5:
Matlab code:
clc
clear all
% (ii)
[x, y] = meshgrid(-3:0.5:3, -3:0.5:3);
u = -y;
v = x;
quiver(x, y, u, v, 'LineWidth', 1.5);
axis([-3 3 -3 3]);
xlabel('x'); ylabel('y'); title('Vector Field F(x,y)');
Output:
problem 6:
Matlab code:
% Define the limits for the polar coordinates
r_min = 0;
r_max = 1;
theta_min = 0;
theta_max = pi/2;
Output:
1/12
problem 7:
Matlab code:
% De ne the function f(x,y)
f = @(x,y) x.^2.*y - y.^3;
% De ne the gradient of f
grad_f = @(x,y) [2*x*y; x.^2 - 3*y.^2];
Output:
fi
fi
ff
fi
problem 8:
Matlab code:
% Define the vector field components
syms x y z % Declare symbolic variables x, y, z
P = y^2*z^3;
Q = 2*x*y*z^3;
R = 3*x*y^2*z^2;
if all(curlF(:) == 0)
disp('The vector field is conservative.');
else
disp('The vector field is not conservative.');
end
Output:
The vector field is conservative.