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


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

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:17 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <je9632$irj$1@smc.vnet.net> (permalink)
References <201201060917.EAA26871@smc.vnet.net>

Show all headers | View raw


So this proposed solution looks weird to me from a mathematical 
perspective.  In the definitions of grad and div, there's no 'x' or 'y' 
on the left of the SetDelayed ( := ), yet both 'x' and 'y' appear on the 
right.

The difficulty here is that the 'f' on the left is not a function (in 
the mathematical sense) per se, but rather an "expression in x and y".

Surely there should be an easy way to represent in Mathematica grad and, 
more generally, other differential (and more general) operators upon 
functions, so that the result of something like grad[f] would be another 
function.

Here's a start:

   grad[phi_[x_, y_]] :=
     {Derivative[1, 0][phi[x, y]], Derivative[0, 1][phi[x, y]]}

   psi[x_, y_] := Sin[x + y]

   grad[psi]
{Cos[#1 + #2] &, Cos[#1 + #2] &}


On 1/6/12 4:17 AM, Alexei Boulbitch wrote:
> Hi, Szymon,
>
> In principle there is a special package, VectorAnalysis for that, but in this case it may be faster to make it "by hands". If I understand you right, you would like to make 2D vector operations. Let us first define the 2D gradient and divergence:
>
> grad[f_] := {D[f, x], D[ f, y]};
>
> div[{f_, g_}] := D[f, x] + D[ g, y];
>
> and now define your function and plot. Try this:
>
> f = div[grad[Sin[x + y]]];
>
> ContourPlot[f, {x, -5, 5}, {y, -5, 5}]
>
> Hope this helps. Have fun. Alexei
>
> 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?
>
> Best regards,
>
> Szymon Roziewski
>
> Alexei BOULBITCH, Dr., habil.
>
> IEE S.A.
>
> ZAE Weiergewan,
>
> 11, rue Edmond Reuter,
>
> L-5326 Contern, LUXEMBOURG
>
> Office phone :  +352-2454-2566
>
> Office fax:       +352-2454-3566
>
> mobile phone:  +49 151 52 40 66 44
>
> e-mail: alexei.boulbitch@iee.lu<mailto:alexei.boulbitch@iee.lu>
>
>
>
>
>
>

-- 
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:17 +0000

csiph-web