[GiNaC-list] question about quantum operator algebra

Chris.Dams at mi.infn.it Chris.Dams at mi.infn.it
Sat May 5 11:13:49 CEST 2007


Hi!

> hi, I am searching for a software or library that can handle operator
> algebra in quantum mechanics. For example, I would like to caculate
> the commutator [a,H], where the Hamiltonian "H"=\epsilon a^{\dag}a,
> and "a" is annihilation operator for, say, an osilator. I tried
> GiNaC, and read much documentation, and get little
> clue. I wonder if there is a direct implementation of these kind of
> operator algebra in GiNaC.

You can declare those operators as noncommutative symbols. I assume that
you are using version 1.3.x. Then it goes as e.g.,

   const unsigned my_tinfo = 2;
   symbol a("a", return_types::noncommutative, my_tinfo);
   symbol adag("adag", return_types::noncommutative, my_tinfo);
   H = epsilon*adag*a;
   ex commu = a*H - H*a
   commu = rewrite_operators(commu);

The global constant my_tinfo is arbitrary, but for safety it should not be
one that is already in use (see
http://www.ginac.de/viewcvs/GiNaC/ginac/tinfos.h?hideattic=0&rev=1.27.2.3&view=markup).
You would have to define the function rewrite_operators yourself. It could
be something like

ex rewrite_operators(const ex &x)
{  if (is_a<ncmul>(x))
   {  ... constructing the result of rewriting is done here ...
      return result;
   }
   else
      return x.map(rewrite_operators);
}

Good luck!
Chris



More information about the GiNaC-list mailing list