MathGroup Archive 2003

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

Search the Archive

Re: Functional differentiation on lattice

  • To: mathgroup at smc.vnet.net
  • Subject: [mg39803] Re: Functional differentiation on lattice
  • From: atelesforos at hotmail.com (Orestis Vantzos)
  • Date: Fri, 7 Mar 2003 03:41:28 -0500 (EST)
  • References: <b46uaf$92m$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

If A is a list {A[1],...,A[n]} of the values of the lattice and it is
indeed periodic so that A[1],...,A[n] gets repeated over and over,
then
-2RotateLeft[A] +4A - 2RotateRight[A] 
calculates the list dS/dA in one step and is much faster than anything
that manually iterates over the list.
By the way S[A]:=With[{dA=RotateLeft[A]-A},dA.dA]
Generally, learn to do your calculations in one sweep when possible
using functional commands (like Inner,Transpose, etc.) and don't try
to iterate over the elements using Do or any other kind of loop.
Orestis

Norbert Nemec <nobbi_at_theorie3.physik.uni-erlangen.de at NOSPAM.COM> wrote in message news:<b46uaf$92m$1 at smc.vnet.net>...
> 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


  • Prev by Date: Re: Functional differentiation on lattice
  • Next by Date: Re: Re: Is Sort stable?
  • Previous by thread: Re: Functional differentiation on lattice
  • Next by thread: Re: Functional differentiation on lattice