Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
documentation:language_reference:functions:braket [2022/09/30 11:35] – Maurits W. Haverkort | documentation:language_reference:functions:braket [2022/09/30 18:51] (current) – Maurits W. Haverkort | ||
---|---|---|---|
Line 2: | Line 2: | ||
### | ### | ||
- | alligned paragraph text | + | // |
### | ### | ||
===== Input ===== | ===== Input ===== | ||
- | * bla : Integer | + | * psi1 or psiList1 |
- | * bla2 : Real | + | * O : 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 |
- | psi0=NewWavefunction(Nf, Nb, {{"100000",math.sqrt(1/2)}, {"000001",math.sqrt(1/2)}}) | + | NB=0 |
+ | IndexDn={0} | ||
+ | IndexUp={1} | ||
+ | |||
+ | psi0=NewWavefunction(NF,NB,{{"10",1}}) | ||
+ | psi1=NewWavefunction(NF,NB,{{"01",1}}) | ||
+ | |||
+ | OppSx = NewOperator(" | ||
+ | OppSy = NewOperator(" | ||
+ | OppSz = NewOperator(" | ||
+ | |||
+ | print(" | ||
+ | print(Braket(psi0, | ||
+ | |||
+ | print(" | ||
+ | print(Braket(psi0, | ||
+ | |||
+ | -- note that I made one list of length 3, the other of length | ||
+ | print(" | ||
+ | print(Braket({psi0, | ||
</ | </ | ||
==== 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 } } | ||
</ | </ | ||