Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #7643

Re: How to plot divergence of gradient as contour

From Murray Eisenberg <murray@math.umass.edu>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: How to plot divergence of gradient as contour
Date 2012-01-07 10:30 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <je96st$j93$1@smc.vnet.net> (permalink)
References <201201051100.GAA14785@smc.vnet.net> <201201060919.EAA26925@smc.vnet.net>

Show all headers | View raw


Correction... a standard modern multivariable calculus text would show, 
essentially:

   phi[x_, y_] := Sin[x + y]
   Div[Grad[phi]][x, y]

On 1/6/12 4:19 AM, Murray Eisenberg wrote:
> 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@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

Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread


Thread

Re: How to plot divergence of gradient as contour Murray Eisenberg <murray@math.umass.edu> - 2012-01-07 10:30 +0000

csiph-web