[Maxima] show gradient vectors orthogonal to level curves
G. Jay Kerns
gkerns at ysu.edu
Wed Oct 21 09:02:46 CDT 2009
Dear Maxima list,
I am trying to demonstrate that gradient vectors are orthogonal to
contour lines. I have tried lots of things, but nothing seems to be
exactly right. Here's some of what I tried.
1) I can get plotdf to plot the vector field nicely, but then I can't
seem to add the contour lines to the plot... it is an ODE plot, after
all, which is concerned with trajectories and the like.
2) Using the draw package, I can plot both the vector field and the
contour lines in both 2D and 3D. I can use multiplot_mode to
2a) The axes do not align correctly in 2D because the contour plot
places a legend on the right top corner. There is apparently some
rescaling for that and I cannot get the vector field plot to do
similar rescaling. Furthermore, I cannot get the legend turned off of
the contour plot.
2b) The plots do not line up correctly in 3D because when contour =
base the contour lines are plotted on some low plane parallel to the
xy-plane which is out of reach.
Here is a minimal example of what I am talking about.
f(x,y) := x^2 - y^2;
define(fx(x,y), diff(f(x,y), x));
define(fy(x,y), diff(f(x,y), y));
ex1: apply(gr2d, append([head_length=0.1, color=blue], vect2))$
contour_levels = 15,
contour = map,
surface_hide = true) ;
P.S. You can get what I am looking for in Sage with
plot_vector_field(f.gradient(), (x, -3, 3), (y, -3, 3), aspect_ratio=1) +
contour_plot(f(x,y), (x, -3, 3), (y, -3, 3), fill=False, contours=9)
G. Jay Kerns, Ph.D.
Department of Mathematics & Statistics
Youngstown State University
Youngstown, OH 44555-0002 USA
Office: 1035 Cushwa Hall
Phone: (330) 941-3310 Office (voice mail)
VoIP: gjkerns at ekiga.net
E-mail: gkerns at ysu.edu
More information about the Maxima