no way to compare when less than two revisions
Differences
This shows you the differences between two versions of the page.
Previous revisionNext revision | |||
— | documentation:language_reference:functions:braket [2022/09/30 17:50] – Maurits W. Haverkort | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Braket ====== | ||
+ | |||
+ | ### | ||
+ | // | ||
+ | ### | ||
+ | |||
+ | ===== Input ===== | ||
+ | |||
+ | * psi1 or psiList1 : Wavefunction or list of Wavefunctions | ||
+ | * O : Operator | ||
+ | * psi2 or psiList2 : Wavefunction or list of Wavefunctions | ||
+ | |||
+ | ===== Output ===== | ||
+ | |||
+ | * real or complex number, or a list of these or a matrix of these | ||
+ | |||
+ | ===== Example ===== | ||
+ | |||
+ | ### | ||
+ | The example calculates the expectation values of a few states | ||
+ | ### | ||
+ | |||
+ | ==== Input ==== | ||
+ | <code Quanty Example.Quanty> | ||
+ | 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 ==== | ||
+ | <file Quanty_Output> | ||
+ | The expectation value of a single state | ||
+ | -0.5 | ||
+ | The expectation value of a single state with two other states | ||
+ | { 0 , 0.5 } | ||
+ | The expectation value of a two states with two other states | ||
+ | { { 0 , (0 + 0.5 I) , (0 + 0.5 I) } , | ||
+ | { (0 - 0.5 I) , 0 , 0 } } | ||
+ | </ | ||
+ | |||
+ | ===== Table of contents ===== | ||
+ | {{indexmenu> | ||