Gradient divergence curl (1)
Gradient divergence curl (1)
Mathematical form:
""""⃗𝟏 (x, y) + 𝒇
""⃗=𝒇
Draw the two dimensional vector field for the vector 𝑭 """"⃗𝟐 (x,y)
• """"⃗𝟏 (x,y,z)+ 𝒇
""⃗=𝒇
Draw the three dimensional vector field for the vector 𝑭 """"⃗𝟐 (x,y,z)
""""⃗𝟑 (x,y,z)
+𝒇
• Find the gradient vector for the following function F(x,y) at the point (x1,y1) .
let the given function be f(x,y). grad (f)=(∂f/∂x)𝚤⃗ +(∂f/∂y)𝚥⃗. Then [grad (f)] at (a,b) is
(∂f/∂x) (a,b) 𝚤⃗ + (∂f/∂y) (a,b)𝚥⃗.
• Find the directional derivative of the function F(x,y,z) in the direction of the vector 𝑉 "⃗ =
V1𝚤⃗ + V2𝑗 + V3𝑘 "⃗ the point (x1,y1,z1).
Let the given function be F(x,y,z). Find[ grad f] at (x1,y1,z1). Find the unit tangent
normal by """""⃗
[𝑉 /|𝑉|] at(x1,y1,z1). Then directional derivative is given by
(gradf).( """""⃗
[𝑉 /|𝑉|].
Example 1:
Draw the two dimensional vector field for the vector 𝒙.⃗ +𝒚0⃗
MATLAB Code:
clc
clear all
syms x y
F=input( 'enter the vector as i, and j order in vector form:');
P = inline(vectorize(F(1)), 'x', 'y');
Q = inline(vectorize(F(2)), 'x', 'y');
x = linspace(-1, 1, 10);
y = x;
[X,Y] = meshgrid(x,y);
U = P(X,Y);
V = Q(X,Y);
quiver(X,Y,U,V,1)
axis on
xlabel('x')
ylabel('y')
Output:
In the Command window:
1.2
0.8
0.6
y
0.4
0.2
-0.2
-0.2 0 0.2 0.4 0.6 0.8 1 1.2
x
Example 2:
"⃗
Draw the three dimensional vector field for the vector 𝒙.⃗ -𝒚0⃗ +𝒛𝒌
MATLAB Code:
syms x y z
F=input( 'enter the vector as i,j and korder in vector form:')
P = inline(vectorize(F(1)), 'x', 'y','z');
Q = inline(vectorize(F(2)), 'x', 'y','z');
R = inline(vectorize(F(3)), 'x', 'y','z');
x = linspace(-1, 1, 5); y = x;
z=x;
[X,Y,Z] = meshgrid(x,y,z);
U = P(X,Y,Z);
V = Q(X,Y,Z);
W = R(X,Y,Z);
quiver3(X,Y,Z,U,V,W,1.5)
axis on
xlabel('x')
ylabel('y')
zlabel('z')
Output:
In the Command Window:
F =[ x, -y, z]
1.
1!
0.
z! 0!
-0.5!
-1!
-1.5!
1!
0. 2!
0! 1!
0!
-0.5! -1!
y! -1! -2!
x!
!
Example 3:
Find the gradient vector field of (𝑥, 𝑦) = 𝑥 $ 𝑦 − 𝑦 % . Plot the gradient vector field together with
a contour map of f. How are they related?
MATLAB Code:
clc
clear all
syms x y
f=input( 'enter the function f(x,y):');
F=gradient(f)
P = inline(vectorize(F(1)), 'x', 'y');
Q = inline(vectorize(F(2)), 'x','y');
x = linspace(-2, 2, 10);
y = x;
[X,Y] = meshgrid(x,y);
U = P(X,Y);
V = Q(X,Y);
quiver(X,Y,U,V,1)
axis on
xlabel('x')
ylabel('y')
hold on
ezcontour(f,[-2 2])
Output:
Command Window:
x^2*y-y^3
Inference:
The gradient vectors are orthogonal to the contours.
Example 4
Find (a) the curl and (b) the divergence of the vector field.
Matlab code
clc
clear all
syms x y z real
F=input( 'enter the vector as i, j and k order in vector form:')
curl_F = curl(F, [x y z])
div_F = divergence(F, [x y z])
Output:
x*z^2 - x*y^2
y*x^2 - y*z^2
- z*x^2 + z*y^2
div_F =
6*x*y*z
Example 5
Matlab code
clc
clear all
syms x y z real
F=input( 'enter the vector as i,j and k order in vector form:')
curl_F = curl(F, [x y z])
if (curl_F ==[0 0 0])
f = potential(F, [x y z])
else
sprintf('curl_F is not equal to zero')
end
Output:
curl_F =
0
0
0
f =
x*y^2*z^3
Exercise
1. Plot the gradient vector field of f together with a contour map of f . Explain how they are
related to each other
(a) 𝑓 = 𝑠𝑖𝑛(𝑥) + 𝑠𝑖𝑛(𝑦) (b) 𝑓 = 𝑠𝑖𝑛(𝑥 + 𝑦) (c) 𝑓 = 𝑥 $ + 𝑦 $