Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

We have that a density matrix can be written in a basis of spherical tensors:

$\rho =\sum _{K=0}^S\sum_{q=-K}^K \rho _{\text{Kq}}^{(S)} T_{\text{Kq}}^{(S)}$

for example for a 3x3 matrix, $S=1$, dimension of the matrix is $2S+1$, I will drop superscript (S) for simplicity

$\rho =\rho_{00}T_{00}+\rho_{1-1}T_{1-1}+\rho_{10}T_{10}+\rho_{11}T_{11}+\rho_{2-2}T_{2-2}+\rho_{2-1}T_{2-1}+\rho_{20}T_{20}+\rho_{21}T_{21}+\rho_{21}T_{21}$

Now, I have a command that gives me the matrix representation of $T_{Kq}^{(S)}$

I want to know now how to make a program so that if you give as an imput the parameter S, they write you the resultant matrix dependent of the coefficients $\rho_{Kq}$. Also as $\rho_{Kq}=(-1)^q\rho_{Kq}^*$, this should also be implemented so that the final matrix depends on fewer parameters.

Edit: Answering to Hector below. I have not programmed the command which gives $T_{Kq}^{(S)}$, to say the truth I have not made code in Mathematica never, and hardly ever elsewhere. Well command is sphtens[K,q,S]

I've been thinking about the algorithm to get the desired result. To me the step are the following:

  • Input the value of S
  • Create a square matrix of zeros of dimension 2S+1.

Call it $\rho$ for example.

  • Create two loops one for the K and another one for the q

for $K=0$ till $2S$

for $q=-K$ till $K$

if $q\geq 0$

$\rho=\rho + \rho_{Kq}$ \times sphtens[K,q,S]

if not $\rho=\rho + (-1)^q\rho_{Kq}^* \times$ sphtens[K,q,S]

end for

end for

Basically what I don't know is to write this in Wolfram language

share|improve this question
3  
After "I have a command that gives me the matrix representation of …" is a good place to put the code you have been playing with. –  Hector Nov 21 '13 at 16:44
    
I edited to give an answer to your suggerence, I guess someone that has some level of programmimg with mathematica can built the program/function with some ease from my algorithm. –  user10712 Nov 21 '13 at 18:40
    
don't know is to write this in mathematica language, excuse me but it is the Wolfram Language or WL for short. Please see wolfram.com/wolfram-language that is the official name of the language from now on. –  Nasser Nov 21 '13 at 18:46
1  
Edited, Wolfram name everything after his own name, a bit weird. –  user10712 Nov 22 '13 at 14:34

1 Answer 1

To transform back from spherical tensors to Cartesian tensors, the unitary transform is

$$\mathbf{U}_l = \frac{1}{\sqrt{2}}\left\{ \begin{align} Y^{-m}_l + (-1)^m Y^m_l &,\ m >0\\ \sqrt{2} Y^0_l &,\ m=0\\ i(Y^{-m}_l - (-1)^m Y^m_l) &,\ m<0 \end{align}\right.$$

where $m$ runs from $-l$ to $l$. This can be built in many ways, usually involving Table, but here is an implementation I used.

Clear[ExchangeMatrix, AntiDiagonalMatrix, RealHarmonics];
ExchangeMatrix[a_Integer?Positive]:= Permutations[ConstantArray[0, a-1]~Join~{1}]
AntiDiagonalMatrix[vec_?VectorQ, k_Integer:0]:= 
   DiagonalMatrix[vec,k].ExchangeMatrix[Length@vec+Abs[k]]

RealHarmonics[l_Integer?NonNegative]:=
Block[{harmmat,ord},
 harmmat =(DiagonalMatrix[
    Table[(-1)^m Which[m<0,-I, m==0, 1/Sqrt[2],m>0, 1], {m, l,-l,-1}]]+
  + AntiDiagonalMatrix[
      Table[Which[m<0,I, m==0, 1/Sqrt[2],m>0, 1], {m, l,-l,-1}]
  ])/Sqrt[2];

 (* This moves the z^n terms to the end, thus maintaining x, y, z order *)
 harmmat[[Drop[Range[1,2l+1], {l+1}]~Append~(l+1)]]
]

Note, ExchangeMatrix and AntiDiagonalMatrix are part of a larger package of matrix utilities I have put together.

To use RealHarmonics, just enter the angular quantum number, e.g.

RealHarmonics[1]
(* {{-(1/Sqrt[2]), 0, 1/Sqrt[2]}, {I/Sqrt[2], 0, I/Sqrt[2]}, {0, 1, 0}} *)

Then, to transform to spherical tensors, you take the conjugate transpose,

ConjugateTranspose@RealHarmonics[1]
(*{{-(1/Sqrt[2]), -(I/Sqrt[2]), 0}, {0, 0, 1}, {1/Sqrt[2], -(I/Sqrt[2]), 0}}*)
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.