Question: (PLEASE USE MATLAB IN THIS QUESTION) We will now display a contour plot along with the gradient vector field. To display a vector field we
(PLEASE USE MATLAB IN THIS QUESTION)
We will now display a contour plot along with the gradient vector
field. To display a vector field we use the command ``quiver''
and to display a contour line we use the command ``contour''.
Let f(x, y) = xy-x^3/3. Then f_x(x, y) = y-x^2 and f_y = x. We shall
display the gradient
vector field and the level curves of f over the square
[-2, 2]x[-2, 2]. Run the script
f=inline('x.*y-(x.^3)/3','x','y')
fx=inline('y-x.^2','x','y')
fy=inline('x','x','y')
x=-2:.05:2;y=x;
% this is the ne mesh for the level curves.
[X,Y]=meshgrid(x,y);
Z=f(X,Y);
% We choose the level curves.
levels = [-6:.5:6];
contour(X,Y,Z,levels)
hold on
xx=-2:.2:2; yy=xx;
% This is the coarse mesh for the arrows
[XX,YY]=meshgrid(xx,yy);
U=fx(XX,YY); V=fy(XX,YY);
quiver(XX,YY,U,V)
axis equal
What is the relation between the level curves and the arrows?
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6. Repeat problem 5 for f(x, y) = x^2 + 4 y^2.
Use the same square but you will need to
consider a different set of level curves.
I am having difficulty considering a different set of level curves which would satisfy the function f(x). Can someone explain the logic behind choosing a set of level curves to me?
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
