Chop

Numerics inside a computer is not exact. Quanty represents numbers by doubles, which can store numbers with about 16 digits accuracy. The fact that you only have 16 digits can lead to number-loss and situations where numbers that should be zero are close to zero but not exactly zero. An example in base 10: If you represent $1/3$ by $0.3333333333333333$ then $1-3\times0.3333333333333333 = 0.00000000000000001$. In Quanty you can remove these small numbers with the command Chop().

For a wavefunction psi, psi.Chop() or psi.Chop($\epsilon$) Removes determinants with small prefactors (smaller than $\epsilon$) from the wavefunction. The standard value (when the argument is omitted) for $\epsilon = 2.2 \times 10^{−15}$. psi.Chop() returns nil and changes the value of psi.

Example

We can define the following function: $$ |\psi\rangle = \left(\frac{1}{\sqrt{4}} a^{\dagger}_0 a^{\dagger}_1 + \frac{1}{\sqrt{4}} a^{\dagger}_0 a^{\dagger}_2 + (1+0.0000001*I)\frac{1}{\sqrt{4}} a^{\dagger}_1 a^{\dagger}_2 \right)|0\rangle, $$ and remove the small complex part with the command Chop()

Input

Example.Quanty
NF=3
NB=0
psi = NewWavefunction(NF, NB, {{"110",sqrt(1/4)},{"101",sqrt(1/4)},{"011",(1+0.0000001*I)*sqrt(1/4)}})
print(psi)
psi.Chop(0.00001)
print(psi)

Result

WaveFunction: Wave Function
QComplex         =          1 (Real==0 or Complex==1)
N                =          3 (Number of basis functions used to discribe psi)
NFermionic modes =          3 (Number of fermions in the one particle basis)
NBosonic modes   =          0 (Number of bosons in the one particle basis)
 
#      pre-factor             +I  pre-factor         Determinant
   1   5.000000000000E-01         0.000000000000E+00       110
   2   5.000000000000E-01         0.000000000000E+00       101
   3   5.000000000000E-01         5.000000000000E-08       011
 
 
 
WaveFunction: Wave Function
QComplex         =          0 (Real==0 or Complex==1)
N                =          3 (Number of basis functions used to discribe psi)
NFermionic modes =          3 (Number of fermions in the one particle basis)
NBosonic modes   =          0 (Number of bosons in the one particle basis)
 
#      pre-factor         Determinant
   1   5.000000000000E-01       110
   2   5.000000000000E-01       101
   3   5.000000000000E-01       011

Available methods

Print/export