MathGroup Archive 2009

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

Search the Archive

Re: symbolic differentiation of a scalar field

  • To: mathgroup at smc.vnet.net
  • Subject: [mg103360] Re: symbolic differentiation of a scalar field
  • From: dh <dh at metrohm.com>
  • Date: Thu, 17 Sep 2009 06:21:00 -0400 (EDT)
  • References: <h8qc9n$cq2$1@smc.vnet.net>


Hi,

we may define a function with n variables by e.g.:

n = 3;

fun = Function[  Evaluate[Plus @@ Table[i Slot[i], {i, n}]]]

We need the "Evaluate" because "Function" has the attribute "HoldAll"

A general derivative can be written as:

Derivative[n1,n2,..][fun]

where ni indicates how  many times the function is derived with respect 

to variable i.

A function dfdk[k_] that takes k as argument and returns the first 

derivative relative to argument k:

dfdk[k_] := (Derivative @@ Table[If[i == k, 1, 0], {i, n}])[fun]

Here the "Table" is used to get all argument values.

With this we e.g. have:

dfdk[i] gives the constant function i: i&



Daniel









Llewlyn wrote:

> Greetings,

> 

> I have a function depending by n (large) number of variables, that is f

> (x1 .. xn).

> I need to do to some symbolic calculus with this function, basically

> differentiation.

> Supposing n=10 here's my solution:

> 

> f[ Array[a_, 10] ] := Sum [i*a[i], {i,10}]

> dfdk[ k_ ] := D[ f[Array[a_, 10]], a[k]]

> 

> How do you think of? And how may i do for an unknown n, set of

> variables?

> I've tried searching tutorial for standard techinque but i didn't find

> one, links are really welcome.

> 

> bests,

> 

> Ll.

> 




  • Prev by Date: Re: symbolic differentiation of a scalar field
  • Next by Date: Re: Problem with NDSolve in Mathematica V4
  • Previous by thread: Re: symbolic differentiation of a scalar field
  • Next by thread: Re: Why these spineness appeared in some certain value?