Re: Functional differentiation on lattice
- To: mathgroup at smc.vnet.net
- Subject: [mg39777] Re: Functional differentiation on lattice
- From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
- Date: Fri, 7 Mar 2003 03:30:53 -0500 (EST)
- Organization: Universitaet Leipzig
- References: <b46uaf$92m$1@smc.vnet.net>
- Reply-to: kuska at informatik.uni-leipzig.de
- Sender: owner-wri-mathgroup at wolfram.com
Hi,
S[A_] := Sum[(A[x + 1] - A[x])^2, {x, -Infinity, Infinity}]
Unprotect[D];
D[Sum[b_, {x_, -Infinity, Infinity}], a[q_]] /; ! FreeQ[b, a] :=
Module[{forms},
forms = Cases[b, a[_], Infinity] /. a[r_] :> r;
forms = Solve[q == #, x][[1]] & /@ forms;
Plus @@ (D[#, a[q]] & /@ (b /. forms))
]
Protect[D];
and
D[S[a], a[y]] // Simplify
gives
-2 (a[-1 + y] - 2 a[y] + a[1 + y])
Regards
Jens
Norbert Nemec wrote:
>
> Hi there,
>
> I've just recently decided that the maths I have to do at the moment really
> demand the use of a CAS. I'm absolutely new to Mathematica, but the problem
> I have is probably a bit hard to get moving on. Perhaps someone can give me
> a simple solution to start out on?
>
> What I need to do could probably be called a "Functional differentiation on
> a lattice". To give one very simply example:
>
> I have the functional
>
> S[A] := sum_x (A(x+1)-A(x))^2
>
> (where x is integer - in my case there are periodic boundaries, but that
> does not matter at that point)
>
> now I want to calculate
>
> dS/dA(y)
>
> which should result in
>
> - 2(A(y+1)-A(y)) + 2(A(y)-A(y-1))
>
> or simplified
>
> -2A(y+1) + 4A(y) - 2A(y-1)
>
> Lateron, the whole thing will get 4-dimensional and A will get indices that
> will be summed over as well.
>
> Is there a simple way to do that in Mathematica? I would really appreciate a
> piece of code to get me started on.
>
> Thanks,
> Nobbi