# Rotate

Rotate($M$, $R$), Rotate($\psi$, $R$), Rotate($O$, $R$) or Rotate($TB$, $R$) rotates the basis of a quadratic matrix, a wave-function, an operator, or a tight-binding object (passive transformation). For a matrix it thus returns $R^\ast \cdot M \cdot R^T$, where $R^\ast$ denotes the complex conjugate and $R^T$ the transpose of the rotation matrix $R$.

$R$ needs to be a matrix of dimension $N_1\times N_2$, where $N_2$ equals the number of rows of $M$, or $N_{Fermion}+N_{Boson}$ of $\psi$, $O$ or $TB$. The rotation matrix $R$ is not required to be quadratic, it is therefore possible to use rotations to change the number of dimensions of the Hilbert-space.

$R^\ast \cdot R^T = 1$ is not checked by Quanty, to allow scaling rotations.

## Input

• $M$, $\psi$, $O$ or $TB$ : a quadratic (complex or real valued) matrix, a wave-function, an operator, or a tight-binding object.
• $R$ : a complex or real valued generalised rotation matrix.

## Output

• $M^\prime$, $\psi^\prime$, $O^\prime$ or $TB^\prime$ : the rotated quadratic matrix, wave-function, operator, or tight-binding object.

## Example

A small example:

### Input

Rotate.Quanty
dofile("../definitions.Quanty")

OpppxR = Chop(Rotate(Opppx,rotmat))
OpppyR = Chop(Rotate(Opppy,rotmat))
OpppzR = Chop(Rotate(Opppz,rotmat))

print("The matrix rotating an operator on the basis of spherical harmonics with alternating spin to a basis of kubic harmonics with alternating spin for a p orbital is:")
print(rotmat)
print("The operator adding a potential to the px orbital on a basis of spherical harmonics is: ",Opppx)
print("The operator adding a potential to the px orbital on a basis of kubic harmonics is: ",OpppxR)
print("The operator adding a potential to the py orbital on a basis of spherical harmonics is: ",Opppy)
print("The operator adding a potential to the py orbital on a basis of kubic harmonics is: ",OpppyR)
print("The operator adding a potential to the pz orbital on a basis of spherical harmonics is: ",Opppz)
print("The operator adding a potential to the pz orbital on a basis of kubic harmonics is: ",OpppzR)

psixdnR = Chop(Rotate(psixdn,rotmat))
psixupR = Chop(Rotate(psixup,rotmat))
psiydnR = Chop(Rotate(psiydn,rotmat))
psiyupR = Chop(Rotate(psiyup,rotmat))
psizdnR = Chop(Rotate(psizdn,rotmat))
psizupR = Chop(Rotate(psizup,rotmat))

print("The px orbital with spin down on a basis of spherical harmonics is: ",psixdn)
print("The px orbital with spin down on a basis of kubic harmonics is: ",psixdnR)
print("The py orbital with spin down on a basis of spherical harmonics is: ",psiydn)
print("The py orbital with spin down on a basis of kubic harmonics is: ",psiydnR)
print("The pz orbital with spin down on a basis of spherical harmonics is: ",psizdn)
print("The pz orbital with spin down on a basis of kubic harmonics is: ",psizdnR)

print("Counting the px orbital on a basis of spherical harmonics: ",psixdn *Opppx *psixdn)
print("Counting the px orbital on a basis of kubic     harmonics: ",psixdnR*OpppxR*psixdnR)
print("Counting the py orbital on a basis of spherical harmonics: ",psiydn *Opppy *psiydn)
print("Counting the py orbital on a basis of kubic     harmonics: ",psiydnR*OpppyR*psiydnR)
print("Counting the pz orbital on a basis of spherical harmonics: ",psizdn *Opppz *psizdn)
print("Counting the pz orbital on a basis of kubic     harmonics: ",psizdnR*OpppzR*psizdnR)

### Result

Rotate.out
The matrix rotating an operator on the basis of spherical harmonics with alternating spin to a basis of kubic harmonics with alternating spin for a p orbital is:
{ { 0.70710678118655 , 0 , 0 , 0 , -0.70710678118655 , 0 } ,
{ 0 , 0.70710678118655 , 0 , 0 , 0 , -0.70710678118655 } ,
{ (0 + 0.70710678118655 I) , 0 , 0 , 0 , (0 + 0.70710678118655 I) , 0 } ,
{ 0 , (0 + 0.70710678118655 I) , 0 , 0 , 0 , (0 + 0.70710678118655 I) } ,
{ 0 , 0 , 1 , 0 , 0 , 0 } ,
{ 0 , 0 , 0 , 1 , 0 , 0 } }
The operator adding a potential to the px orbital on a basis of spherical harmonics is:
Operator: Opp px
QComplex         =          0 (Real==0 or Complex==1 or Mixed==2)
MaxLength        =          2 (largest number of product of lader operators)
NFermionic modes =          6 (Number of fermionic modes (site, spin, orbital, ...) in the one particle basis)
NBosonic modes   =          0 (Number of bosonic modes (phonon modes, ...) in the one particle basis)

Operator of Length   2
QComplex      =          0 (Real==0 or Complex==1)
N             =          8 (number of operators of length   2)
C  0 A  0 |  4.999999999999999E-01
C  1 A  1 |  4.999999999999999E-01
C  4 A  4 |  4.999999999999999E-01
C  5 A  5 |  4.999999999999999E-01
C  4 A  0 | -5.000000000000000E-01
C  5 A  1 | -5.000000000000000E-01
C  0 A  4 | -5.000000000000000E-01
C  1 A  5 | -5.000000000000000E-01

The operator adding a potential to the px orbital on a basis of kubic harmonics is:
Operator: Opp px
QComplex         =          0 (Real==0 or Complex==1 or Mixed==2)
MaxLength        =          2 (largest number of product of lader operators)
NFermionic modes =          6 (Number of fermionic modes (site, spin, orbital, ...) in the one particle basis)
NBosonic modes   =          0 (Number of bosonic modes (phonon modes, ...) in the one particle basis)

Operator of Length   2
QComplex      =          0 (Real==0 or Complex==1)
N             =          2 (number of operators of length   2)
C  0 A  0 |  1.000000000000000E+00
C  1 A  1 |  1.000000000000000E+00

The operator adding a potential to the py orbital on a basis of spherical harmonics is:
Operator: Opp py
QComplex         =          0 (Real==0 or Complex==1 or Mixed==2)
MaxLength        =          2 (largest number of product of lader operators)
NFermionic modes =          6 (Number of fermionic modes (site, spin, orbital, ...) in the one particle basis)
NBosonic modes   =          0 (Number of bosonic modes (phonon modes, ...) in the one particle basis)

Operator of Length   2
QComplex      =          0 (Real==0 or Complex==1)
N             =          8 (number of operators of length   2)
C  0 A  0 |  4.999999999999999E-01
C  1 A  1 |  4.999999999999999E-01
C  4 A  4 |  4.999999999999999E-01
C  5 A  5 |  4.999999999999999E-01
C  4 A  0 |  5.000000000000000E-01
C  5 A  1 |  5.000000000000000E-01
C  0 A  4 |  5.000000000000000E-01
C  1 A  5 |  5.000000000000000E-01

The operator adding a potential to the py orbital on a basis of kubic harmonics is:
Operator: Opp py
QComplex         =          0 (Real==0 or Complex==1 or Mixed==2)
MaxLength        =          2 (largest number of product of lader operators)
NFermionic modes =          6 (Number of fermionic modes (site, spin, orbital, ...) in the one particle basis)
NBosonic modes   =          0 (Number of bosonic modes (phonon modes, ...) in the one particle basis)

Operator of Length   2
QComplex      =          0 (Real==0 or Complex==1)
N             =          2 (number of operators of length   2)
C  2 A  2 |  1.000000000000000E+00
C  3 A  3 |  1.000000000000000E+00

The operator adding a potential to the pz orbital on a basis of spherical harmonics is:
Operator: Opp pz
QComplex         =          0 (Real==0 or Complex==1 or Mixed==2)
MaxLength        =          2 (largest number of product of lader operators)
NFermionic modes =          6 (Number of fermionic modes (site, spin, orbital, ...) in the one particle basis)
NBosonic modes   =          0 (Number of bosonic modes (phonon modes, ...) in the one particle basis)

Operator of Length   2
QComplex      =          0 (Real==0 or Complex==1)
N             =          2 (number of operators of length   2)
C  2 A  2 |  9.999999999999999E-01
C  3 A  3 |  9.999999999999999E-01

The operator adding a potential to the pz orbital on a basis of kubic harmonics is:
Operator: Opp pz
QComplex         =          0 (Real==0 or Complex==1 or Mixed==2)
MaxLength        =          2 (largest number of product of lader operators)
NFermionic modes =          6 (Number of fermionic modes (site, spin, orbital, ...) in the one particle basis)
NBosonic modes   =          0 (Number of bosonic modes (phonon modes, ...) in the one particle basis)

Operator of Length   2
QComplex      =          0 (Real==0 or Complex==1)
N             =          2 (number of operators of length   2)
C  4 A  4 |  9.999999999999999E-01
C  5 A  5 |  9.999999999999999E-01

The px orbital with spin down on a basis of spherical harmonics is:
WaveFunction: Wave Function
QComplex         =          0 (Real==0 or Complex==1)
N                =          2 (Number of basis functions used to discribe psi)
NFermionic modes =          6 (Number of fermions in the one particle basis)
NBosonic modes   =          0 (Number of bosons in the one particle basis)

#      pre-factor         Determinant
1   7.071067811865E-01       100000
2  -7.071067811865E-01       000010

The px orbital with spin down on a basis of kubic harmonics is:
WaveFunction: Wave Function
QComplex         =          0 (Real==0 or Complex==1)
N                =          1 (Number of basis functions used to discribe psi)
NFermionic modes =          6 (Number of fermions in the one particle basis)
NBosonic modes   =          0 (Number of bosons in the one particle basis)

#      pre-factor         Determinant
1   1.000000000000E+00       100000

The py orbital with spin down on a basis of spherical harmonics is:
WaveFunction: Wave Function
QComplex         =          1 (Real==0 or Complex==1)
N                =          2 (Number of basis functions used to discribe psi)
NFermionic modes =          6 (Number of fermions in the one particle basis)
NBosonic modes   =          0 (Number of bosons in the one particle basis)

#      pre-factor             +I  pre-factor         Determinant
1   0.000000000000E+00         7.071067811865E-01       100000
2   0.000000000000E+00         7.071067811865E-01       000010

The py orbital with spin down on a basis of kubic harmonics is:
WaveFunction: Wave Function
QComplex         =          0 (Real==0 or Complex==1)
N                =          1 (Number of basis functions used to discribe psi)
NFermionic modes =          6 (Number of fermions in the one particle basis)
NBosonic modes   =          0 (Number of bosons in the one particle basis)

#      pre-factor         Determinant
1   1.000000000000E+00       001000

The pz orbital with spin down on a basis of spherical harmonics is:
WaveFunction: Wave Function
QComplex         =          0 (Real==0 or Complex==1)
N                =          1 (Number of basis functions used to discribe psi)
NFermionic modes =          6 (Number of fermions in the one particle basis)
NBosonic modes   =          0 (Number of bosons in the one particle basis)

#      pre-factor         Determinant
1   1.000000000000E+00       001000

The pz orbital with spin down on a basis of kubic harmonics is:
WaveFunction: Wave Function
QComplex         =          0 (Real==0 or Complex==1)
N                =          1 (Number of basis functions used to discribe psi)
NFermionic modes =          6 (Number of fermions in the one particle basis)
NBosonic modes   =          0 (Number of bosons in the one particle basis)

#      pre-factor         Determinant
1   1.000000000000E+00       000010

Counting the px orbital on a basis of spherical harmonics: 	1
Counting the px orbital on a basis of kubic     harmonics: 	1
Counting the py orbital on a basis of spherical harmonics: 	1
Counting the py orbital on a basis of kubic     harmonics: 	1
Counting the pz orbital on a basis of spherical harmonics: 	1
Counting the pz orbital on a basis of kubic     harmonics: 	1