Differences
This shows you the differences between two versions of the page.
| documentation:language_reference:objects:operator:methods:chop [2016/09/25 13:59] – created Maurits W. Haverkort | documentation:language_reference:objects:operator:methods:chop [2025/11/20 04:20] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ====== 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 // | ||
| + | ### | ||
| + | |||
| + | ### | ||
| + | For an operator //O//, // | ||
| + | ### | ||
| + | |||
| + | ===== Example ===== | ||
| + | |||
| + | ### | ||
| + | We define: | ||
| + | $$O=3.4+1.2a^{\dagger}_{0}\, | ||
| + | and remove the small complex part with the command //Chop()// | ||
| + | ### | ||
| + | |||
| + | ==== Input ==== | ||
| + | <code Quanty Example.Quanty> | ||
| + | NF=3 | ||
| + | NB=0 | ||
| + | O = NewOperator(NF, | ||
| + | print(O) | ||
| + | O.Chop(0.00001) | ||
| + | print(O) | ||
| + | </ | ||
| + | |||
| + | ==== Result ==== | ||
| + | <file Quanty_Output> | ||
| + | Operator: Operator | ||
| + | QComplex | ||
| + | MaxLength | ||
| + | NFermionic modes = 3 (Number of fermionic modes (site, spin, orbital, ...) in the one particle basis) | ||
| + | NBosonic modes | ||
| + | |||
| + | Operator of Length | ||
| + | QComplex | ||
| + | N | ||
| + | | 3.400000000000000E+00 | ||
| + | |||
| + | Operator of Length | ||
| + | QComplex | ||
| + | N | ||
| + | C 0 A 0 | 1.200000000000000E+00 | ||
| + | C 1 A 2 | 2.500000000000000E+00 | ||
| + | |||
| + | |||
| + | |||
| + | Operator: Operator | ||
| + | QComplex | ||
| + | MaxLength | ||
| + | NFermionic modes = 3 (Number of fermionic modes (site, spin, orbital, ...) in the one particle basis) | ||
| + | NBosonic modes | ||
| + | |||
| + | Operator of Length | ||
| + | QComplex | ||
| + | N | ||
| + | | 3.400000000000000E+00 | ||
| + | |||
| + | Operator of Length | ||
| + | QComplex | ||
| + | N | ||
| + | C 0 A 0 | 1.200000000000000E+00 | ||
| + | C 1 A 2 | 2.500000000000000E+00 | ||
| + | </ | ||
| + | |||
| + | ===== Available methods ===== | ||
| + | {{indexmenu> | ||