       Re: Differentiation w.r.t. elements of lists

• To: mathgroup at smc.vnet.net
• Subject: [mg79736] Re: [mg79642] Differentiation w.r.t. elements of lists
• From: Carl Woll <carlw at wolfram.com>
• Date: Fri, 3 Aug 2007 06:24:32 -0400 (EDT)
• References: <200708010854.EAA01528@smc.vnet.net>

```Daniel Hornung wrote:

>Hello,
>I don't know if what I want to do is impossible to do neatly (probably not)
>or whether I simply chose the wrong way (maybe).
>
>Basically I want to do componentwise differentiation.  Here's a short test
>case:
>----
>In := h[x_]:=Sum[x[[j]]^2,{j,1,Length[x]}]
>
>In := dh[x_,i_]=D[h[x],x[[i]]]
>>From In:=
>Part::pspec: Part specification i is neither an integer nor a list of
>integers. Mehr...
>Out= 0
>
>In:= Assuming[i\[Element]Integers&&i>0&&i<=n,dh[x_,i_]=D[h[x],x[[i]]]]
>>From In:=
>Part::pspec: Part specification i is neither an integer nor a list of
>integers. Mehr...
>Out= 0
>----
>
>What I would want is a result like dh[x_,i_]=2x[[i]], of course.
>
>Another, even shorter test case would be
>
>D[x[[i]], x[[j]]]
>
>which "should", IMHO, return KroneckerDelta[i,j].
>
>Any ideas or hints how to solve these problems in a nice way?
>
>Daniel Hornung
>
>
I don't think you will get very far working with x as a list. Perhaps
the following idea may help:

w /: D[w[i_], w[j_], NonConstants -> {w}] :=  DiscreteDelta[i - j]

In:= D[Sum[w[i]^2, {i, n}], w, NonConstants -> {w}]
Out= 2 UnitStep[n - 1] w

Carl Woll
Wolfram Research

```

• Prev by Date: Re: Paul Abbott Chebyshev Article
• Next by Date: Re: Plot a number line
• Previous by thread: Differentiation w.r.t. elements of lists
• Next by thread: Multi-variable Integration