Re: symbolic differentiation of a scalar field
- To: mathgroup at smc.vnet.net
- Subject: [mg103351] Re: [mg103349] symbolic differentiation of a scalar field
- From: Bob Hanlon <hanlonr at cox.net>
- Date: Thu, 17 Sep 2009 06:19:06 -0400 (EDT)
- Reply-to: hanlonr at cox.net
f[n_Integer] := Array[a, n].Range[n] dfdk[func_, k_Integer] := D[func, a[k]] dfdk[f[7], 4] 4 g = f[5] a(1)+2 a(2)+3 a(3)+4 a(4)+5 a(5) dfdk[g, #] & /@ Range[Length[Variables[g]]] {1,2,3,4,5} SetAttributes[dfdk, Listable] dfdk[g, Range[Length[Variables[g]]]] {1,2,3,4,5} However, you can just use D[g, #] & /@ Variables[g] {1,2,3,4,5} Bob Hanlon ---- 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.