MathGroup Archive 2011

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

Search the Archive

Re: Function of N variable

  • To: mathgroup at
  • Subject: [mg121101] Re: Function of N variable
  • From: Sam Takoy <sam.takoy at>
  • Date: Sun, 28 Aug 2011 04:05:18 -0400 (EDT)
  • Delivered-to:
  • References: <> <>
  • Reply-to: Sam Takoy <sam.takoy at>

E.G, the following?

Grad[f_][x__] := Switch[Length[{x}],
 1, {Derivative[1][f][x]},
 2, {Derivative[1, 0][f][x], Derivative[0, 1][f][x]},
 3, {Derivative[1, 0, 0][f][x], Derivative[0, 1, 0][f][x], 
 Derivative[0, 0, 1][f][x]},
 4, {Derivative[1, 0, 0, 0][f][x], Derivative[0, 1, 0, 0][f][x], 
 Derivative[0, 0, 1, 0][f][x], Derivative[0, 0, 0, 1][f][x]}]

f[x_, y_] = x^2 + y^2;
Grad[f][x, y]


From: Ethan Dyer <ethansdyer at>
To: Sam Takoy <sam.takoy at>
Cc: "mathgroup at" <mathgroup at>
Sent: Saturday, August 27, 2011 9:24 AM
Subject: [mg121101] Re: Function of N variable


  Mathematica allows one to define functions that take an arbitrary number of arguments using double underscore (BlankSequence) or triple underscore (BlankNullSequence)

For instance F[args__]:={args} takes in any number of arguments except zero.

A function defined with three underscores can take any number including zero.


On Aug 27, 2011, at 8:17 AM, Sam Takoy <sam.takoy at> wrote:

> Hi,
> I have put together a few function for differential geometry in 3D.
> All my functions were of the kind F(z1_, z2_, z3_). Now I want to
> generalize to 4D, then 5D, etc. Is there a good way to represent a
> function of N variables? For example, I want to be able to say grad[F]
> [???] to obtain a list of N function (partial derivatives) of N
> variables. I understand these are vague questions, but I am only
> looking for some keywords.
> Many thanks in advance,
> Sam

  • Prev by Date: Re: Replace
  • Next by Date: Re: Incompletely simplified Square root.
  • Previous by thread: Re: Function of N variable
  • Next by thread: Mathematica Script mode