Re: How to plot divergence of gradient as contour plot
- To: mathgroup at smc.vnet.net
- Subject: [mg124132] Re: How to plot divergence of gradient as contour plot
- From: Szymon Roziewski <szymon.roziewski at gmail.com>
- Date: Tue, 10 Jan 2012 06:00:20 -0500 (EST)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
- References: <201201051100.GAA14785@smc.vnet.net> <201201060919.EAA26925@smc.vnet.net>
Hello once again, Thank you very much for your ideas! I haven't used that package before, so it's new to me. It's weird that Div, Grad, Curl don't operate on x,y,z but on Xx,Yy,Zz. It seems to be a programmer trick. All best, Szymon Roziewski 2012/1/6 Murray Eisenberg <murray at math.umass.edu> > You need to use the VectorAnalysis package (carefully!), remembering that: > > (i) the default coordinate system is Cartesian[Xx, Yy, Zz]; and > (ii) the result of using that package's Grad, Div, Curl is _not_ > really a "function" of the variables (more about this later). > > In your example: > > > Div[Grad[Sin[Xx + Yy]]] > -2 Sin[Xx + Yy] > > > ContourPlot[ > Div[Grad[Sin[Xx + Yy]]] /. {Xx -> x, Yy -> y}, > {x, -5, 5}, {y, -5, 5}] > > (* or first define a function *) > > f[x_, y_] := Div[Grad[Sin[Xx + Yy]]] /. {Xx -> x, Yy -> y} > ContourPlot[f[x, y], {x, -5, 5}, {y, -5, 5}] > > I find the whole paradigm of the VectorAnalysis package to be > aggravatingly annoying. After all, from a mathematical perspective, if > you're given a scalar-valued function with vector inputs, then its > gradient is just a well-defined vector field -- and that has nothing > whatsoever to do with so-called "coordinate systems". That is, one ought > to be able to do something like this -- just like any standard modern > text on multivariable calculus would show: > > phi[x_, y_] := Sin[x + y] > Div[Grad[phi[x, y]]] > > In Mathematica, with the VectorAnalysis defaults, you'd get 0 as result > there, since you didn't override the default variable names Xx, Yy, Zz. > > Then there's the whole nonsense of the gradient other coordinate > systems. That, to my mind, is a very odd way to think about things. > Mathematically, given a scalar field, it has an associated gradient > vector field. Period. If you want to "express the gradient in terms of" > another coordinate system, you're no longer finding that gradient; > you're finding a composite of functions where you go first from that > other coordinate system to cartesian coordinates, next take the > gradient, and finally go back from cartesian coordinates in the result > to the other coordinate system. > > (I trust others will disagree with the preceding argument!) > > > On 1/5/12 6:00 AM, Szymon Roziewski wrote: > > Hello there, > > > > I am concerning to plot something like that. > > > > ContourPlot[Divergence[Gradient[Sin[x + y]]], {x, -5, 5}, {y, -5, 5}] > > > > Plotting divergence of gradient scalar field. > > How can I manage to do that? > > -- > Murray Eisenberg murray at math.umass.edu > Mathematics & Statistics Dept. > Lederle Graduate Research Tower phone 413 549-1020 (H) > University of Massachusetts 413 545-2859 (W) > 710 North Pleasant Street fax 413 545-1801 > Amherst, MA 01003-9305 > > -- Z wyrazami szacunku, Szymon Roziewski
- References:
- How to plot divergence of gradient as contour plot
- From: Szymon Roziewski <szymon.roziewski@gmail.com>
- Re: How to plot divergence of gradient as contour plot
- From: Murray Eisenberg <murray@math.umass.edu>
- How to plot divergence of gradient as contour plot