Re: symbolic differentiation of a scalar field
- To: mathgroup at smc.vnet.net
- Subject: [mg103358] Re: [mg103349] symbolic differentiation of a scalar field
- From: Leonid Shifrin <lshifr at gmail.com>
- Date: Thu, 17 Sep 2009 06:20:37 -0400 (EDT)
- References: <200909160948.FAA13142@smc.vnet.net>
Hi Llewlyn, Here is one possibility (I changed your function f to make things a bit more interesting): In[1] = Clear[f]; f[var_Symbol] := Sum[i*var[i]^2, {i, 10}] In[2] = Clear[x]; f[x] Out[2] = x[1]^2+2 x[2]^2+3 x[3]^2+4 x[4]^2+5 x[5]^2+6 x[6]^2+7 x[7]^2+8 x[8]^2+9 x[9]^2+10 x[10]^2 In[3] = Clear[dfdk]; dfdk[var_Symbol][k_Integer][expr_] := D[expr, var[k]] In[4] = Table[dfdk[x][i][f[x]], {i, 1, 10}] Out[4] = {2 x[1],4 x[2],6 x[3],8 x[4],10 x[5],12 x[6],14 x[7],16 x[8],18 x[9],20 x[10]} Regards, Leonid On Wed, Sep 16, 2009 at 1:48 PM, Llewlyn <tommaso.biancalani at gmail.com>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. > >
- References:
- symbolic differentiation of a scalar field
- From: Llewlyn <tommaso.biancalani@gmail.com>
- symbolic differentiation of a scalar field