Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
documentation:language_reference:functions:braket [2018/06/21 15:13] – created Simon Heinzedocumentation:language_reference:functions:braket [2022/09/30 18:51] (current) Maurits W. Haverkort
Line 2: Line 2:
  
 ### ###
-alligned paragraph text+//Braket(psi1, O, psi2)// calculates the expectation value or matrix element $\left\langle \psi_1 \mid O \mid \psi_2 \right\rangle$. In Quanty //Braket(psi1, O, psi2)// is the same as // psi1 * O * psi2//. The difference is that the function //Braket// can be faster. //Braket// can work on lists of functions and then returns a matrix or vector with all possible expectation values
 ### ###
  
 ===== Input ===== ===== Input =====
  
-  * bla Integer +  * psi1 or psiList1 Wavefunction or list of Wavefunctions 
-  * bla2 Real+  * Operator 
 +  * psi2 or psiList2 : Wavefunction or list of Wavefunctions
  
 ===== Output ===== ===== Output =====
  
-  * bla : real+  * real or complex number, or a list of these or a matrix of these
  
 ===== Example ===== ===== Example =====
  
 ### ###
-description text+The example calculates the expectation values of a few states
 ### ###
  
 ==== Input ==== ==== Input ====
 <code Quanty Example.Quanty> <code Quanty Example.Quanty>
--- some example code+NF=2 
 +NB=0 
 +IndexDn={0} 
 +IndexUp={1} 
 + 
 +psi0=NewWavefunction(NF,NB,{{"10",1}}) 
 +psi1=NewWavefunction(NF,NB,{{"01",1}}) 
 + 
 +OppSx   = NewOperator("Sx"   ,NF,IndexUp,IndexDn) 
 +OppSy   = NewOperator("Sy"   ,NF,IndexUp,IndexDn) 
 +OppSz   = NewOperator("Sz"   ,NF,IndexUp,IndexDn) 
 + 
 +print("The expectation value of a single state"
 +print(Braket(psi0,OppSz,psi0)) 
 + 
 +print("The expectation value of two states with a single state"
 +print(Braket(psi0,OppSx,{psi0,psi1})) 
 + 
 +-- note that I made one list of length 3, the other of length 2 so that the order is clear 
 +print("The expectation value of a three states with two other states"
 +print(Braket({psi0,psi1},OppSy,{psi0,psi1,psi1}))
 </code> </code>
  
 ==== Result ==== ==== Result ====
 <file Quanty_Output> <file Quanty_Output>
-text produced as output+The expectation value of a single state 
 +-0.5 
 +The expectation value of two states with a single state 
 +{ 0 , 0.5 } 
 +The expectation value of a three states with two other states 
 +{ { 0 , (0 + 0.5 I) , (0 + 0.5 I) } ,  
 +  { (0 - 0.5 I) , 0 , 0 } }
 </file> </file>
  
Print/export