====== Problems with creation and annihilation operators ====== ;;# asked by [[mailto:camjjr.cm@gmail.com|Carlos Alberto Martins Junior]] (2020/02/22 18:59) ;;# == == Hello, I am trying to learn how to program using Quanty, however I am having some issues to understand why my code is wrong. I tried to print the creation and annihilation operators in a d shell basis but the result is wrong. My code is NF=10 NB=0 IndexDn={0,2,4,6,8} IndexUp={1,3,5,7,9} psi0 =NewWavefunction(NF,NB,{{"0000000000",1}}) psi1 =NewWavefunction(NF,NB,{{"1000000000",1}}) psi2 =NewWavefunction(NF,NB,{{"1100000000",1}}) psi3 =NewWavefunction(NF,NB,{{"1110000000",1}}) psi4 =NewWavefunction(NF,NB,{{"1111000000",1}}) psi5 =NewWavefunction(NF,NB,{{"1111100000",1}}) psi6 =NewWavefunction(NF,NB,{{"1111110000",1}}) psi7 =NewWavefunction(NF,NB,{{"1111111000",1}}) psi8 =NewWavefunction(NF,NB,{{"1111111100",1}}) psi9 =NewWavefunction(NF,NB,{{"1111111110",1}}) psi10=NewWavefunction(NF,NB,{{"1111111111",1}}) psilist={psi0,psi1,psi2,psi3,psi4,psi5,psi6,psi7,psi8,psi9,psi10} OppN = NewOperator("Number",NF,{0,1,2,3,4,5,6,7,8,9,10},{0,1,2,3,4,5,6,7,8,9,10},{1,1,1,1,1,1,1,1,1,1,1}) OppCr = NewOperator("Cr",NF,{0,1,2,3,4,5,6,7,8,9,10},{1,1,1,1,1,1,1,1,1,1,1}) OppAn = NewOperator("An",NF,{0,1,2,3,4,5,6,7,8,9,10},{1,1,1,1,1,1,1,1,1,1,1}) print("Operator N:") for i=1,11 do for j=1,11 do io.write(string.format("%5.2f",psilist[i]*OppN*psilist[j])) end io.write("\n") end print("") print("Operator Cr:") for i=1,11 do for j=1,11 do io.write(string.format("%5.2f",psilist[i]*OppCr*psilist[j])) end io.write("\n") end print("") print("Operator An:") for i=1,11 do for j=1,11 do io.write(string.format("%5.2f",psilist[i]*OppAn*psilist[j])) end io.write("\n") end print("") And my result is Operator N: 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 1.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 2.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 3.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 4.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 5.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 6.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 7.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 8.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 9.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.0010.00 Operator Cr: 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 1.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00-1.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 1.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00-1.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 1.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00-1.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 1.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00-1.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 1.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00-1.00 0.00 Operator An: 1.00 1.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 3.61-1.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 5.00 1.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 6.08-1.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 7.00 1.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 7.81-1.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 8.54 1.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 9.22-1.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 9.85 1.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.0010.44-1.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.0011.00 I do not understand why I got this result for the creation and annihilation operators. ~~DISCUSSION|Answers~~