%%%% % Example Octave commands % Plot the flow field in phase space for a gradient system % X'= - grad V(X) % with potential function V, including the level curves of V %%% DO THIS FIRST: % Initialize the grid in phase space where arrows will % indicate the flow X'=(x',y') at position X=(x,y): p=-2:0.5:2; [x,y]=meshgrid(p,p); % 2-D grid ral = 0.4; % Relative arrow length % Define the flow field and potential function dx = sin(y); dy = x.*cos(y); dd = sqrt(dx.*dx + dy.*dy) + 0.01; % Raw speeds, nonzero dy = dy./dd; dx = dx./dd; % Normalized unit arrows V= -x.*sin(y); % potential function, so X'= -grad V(X) clf; % clear any previous graphic quiver(x,y,dx,dy,ral); % Phase portrait = flow field hold on; % superimpose the next graphic contour(x,y,V); % contour plot = level curves title("Example 7.2.1, p.223");