Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| documentation:language_reference:functions:braket [2018/06/21 15:13] – created Simon Heinze | documentation:language_reference:functions:braket [2025/11/20 03:29] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| 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 |
| + | NB=0 | ||
| + | IndexDn={0} | ||
| + | IndexUp={1} | ||
| + | |||
| + | psi0=NewWavefunction(NF, | ||
| + | psi1=NewWavefunction(NF, | ||
| + | |||
| + | 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 2 so that the order is clear | ||
| + | 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 } } | ||
| </ | </ | ||