Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2003
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2003

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Problems evaluating Grad

  • To: mathgroup at smc.vnet.net
  • Subject: [mg39410] Re: [mg39372] Problems evaluating Grad
  • From: Murray Eisenberg <murraye at attbi.com>
  • Date: Fri, 14 Feb 2003 03:20:45 -0500 (EST)
  • Organization: Mathematics & Statistics, Univ. of Mass./Amherst
  • References: <200302130952.EAA20607@smc.vnet.net>
  • Reply-to: murray at math.umass.edu
  • Sender: owner-wri-mathgroup at wolfram.com

There are two different problems with your attempt.

First, Grad from the Calculus`VectorAnalysis` package wants the function 
to have 3 variables, not 2.  Here's one way to do this (with a slightly 
more interesting f):

   f[x_, y_] := x^2 + Sin[y]
   Drop[Grad[f[x, y], Cartesian[x, y, z]], -1]
{2 x,Cos[y]}

Second, if you use arguments "a" and "b" directly in the Grad 
expression, instead of the {x,y,x} coordinates, you now have a constant 
function, so that you correctly obtain:

   Drop[Grad[f[a, b], Cartesian[x, y, z]], -1]
{0, 0}

You can get the answer you presumably want, namely {2a, Cos[b]}, in 
either of two ways -- either respecifying the coordinate system or else 
using a ReplaceAll ( /. ):

   Drop[Grad[f[a, b], Cartesian[a, b, z]], -1]
{2 a, Cos[b]}

   Drop[Grad[f[x, y], Cartesian[x, y, z]], -1] /. {x -> a, y -> b}
{2 a, Cos[b]}


Konrad Den Ende wrote:
> I'd like to detrmine Grad to a function so i go:
> <<Calculus`VectorAnalysis`
> f[x_,y_]:=x+y
> 
> Grad[f[a,b]]
> 
> I get no errors, but the answer is simply the same thing
> that i asked, as if no computation was done. What do i
> do wrong?
> 
> Also - when i evaluated the examples in Help i got the same
> behavior. The answer that already is there gets exchanged
> to something else upon my evaluation. Namely, the question
> itself. What is that?!
> 
> --
> 
> Vänligen
> Konrad
> ---------------------------------------------------
> phone #1:  (+46/0) 708 - 70 73 92
> phone #2: (+46/0) 704 - 79 96 95
> url: http://konrads.webbsida.com
> e-mail: chamsterkonrad at bigfoot.com
> -----------------------------------
> 
> Sleep - thing used by ineffective people
>             as a substitute for coffee
> 
> Ambition - a poor excuse for not having
>                  enough sence to be lazy
> ---------------------------------------------------
> 
> 
> 
> 
> 
> 
> 
> 

-- 
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
Amherst, MA 01375



  • Prev by Date: Re: Problems evaluating Grad
  • Next by Date: Re: Detecting unsuccessful computations
  • Previous by thread: Re: Problems evaluating Grad
  • Next by thread: Re: Problems evaluating Grad