Eng.
mathematics
University of duhok
College of engineering
Electrical and computer department
Title: Vector Field With Trajectory
Name : Gashbin Salahadin Omer
Teacher : Mr.Seamand
Data : 11-12-2024
1
Eng.mathematics
Graph the vector field with the given trajectory:
⃗⃗F (𝑥,𝑦,𝑧) = (𝑦)𝑖 − (𝑥)𝑗 +(𝑧)𝑘 , r(𝑡) = 〈sin𝑡,cos𝑡,𝑒 〉 , 0 ≤ 𝑡 ≤ 6π
1-Plot the vector field :
Represent the vector field 𝐅(𝐱, 𝐲, 𝐳) by plotting vectors at sample points in the (x,y,z)
space .
2-plot the trajectory :
the trajectory 𝐫(𝒕) traces a 3D curve as t varies from 0 to 6𝛑 .This can be superimposed
onto the vector field .
the graph created by using matlab :
2
Eng.mathematics
the graph is constructed in the following steps :
% Define the vector field F(x, y, z)
F = @(x, y, z) [y, -x, z];
% Define the parameterized curve r(t)
r = @(t) [sin(t), cos(t), exp(t)];
% Define the parameter range
t_start = 0;
t_end = 6*pi;
% Number of points for evaluation
num_points = 1000;
t = linspace(t_start, t_end, num_points);
% Evaluate r(t), r'(t), and F(r(t)) along the curve
r_values = arrayfun(@(t) r(t), t, 'UniformOutput', false);
r_values = cell2mat(r_values')';
dr_dt = diff(r_values, 1, 2)./diff(t);
F_values = arrayfun(@(i) F(r_values(1, i), r_values(2, i), r_values(3, i)), 1:size(r_values, 2)-1,
'UniformOutput', false);
F_values = cell2mat(F_values')';
% Compute the dot product F(r(t)) · dr/dt
dot_product = sum(F_values .* dr_dt, 1);
% Line integral (sum over parameter t)
line_integral = sum(dot_product .* diff(t));
disp(['Line integral: ', num2str(line_integral)]);
% Plot the vector field and the curve
[X, Y, Z] = meshgrid(-1:0.5:1, -1:0.5:1, -1:1:1);
3
Eng.mathematics
U = Y; V = -X; W = Z;
figure;
quiver3(X, Y, Z, U, V, W, 0.5);
hold on;
% Plot the curve
plot3(r_values(1, :), r_values(2, :), r_values(3, :), 'r', 'LineWidth', 2);
title('Vector Field and Curve');
xlabel('x'); ylabel('y'); zlabel('z');
legend('Vector Field', 'Curve r(t)');
grid on;