Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| documentation:language_reference:functions:chop [2016/10/09 21:27] – created Maurits W. Haverkort | documentation:language_reference:functions:chop [2025/11/20 03:29] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ====== Chop ====== | ||
| + | ### | ||
| + | Chop(//a//) replaces approximate real numbers in //a// that are close to zero by the exact integer 0. Chop(//a//, $\epsilon$) replaces numbers smaller in absolute magnitude than $\epsilon$ by 0. Chop uses a default tolerance of $\epsilon=2.3\cdot10^{-15}$ (or 10 times the double machine precision DBL_EPSILON if defined). Chop works on Real and Complex numbers as well as on operators, wavefunctions, | ||
| + | ### | ||
| + | |||
| + | ===== Input ===== | ||
| + | |||
| + | * //a// : object that will be chopped, all types allowed | ||
| + | * $\epsilon$ : real number setting the boundary between zero and finite | ||
| + | |||
| + | ===== Output ===== | ||
| + | |||
| + | * //a'// : object of same type as //a// | ||
| + | |||
| + | ===== Example ===== | ||
| + | |||
| + | ### | ||
| + | A small test script of chop is: | ||
| + | ### | ||
| + | |||
| + | ==== Input ==== | ||
| + | <code Quanty Chop.Quanty> | ||
| + | dofile(" | ||
| + | |||
| + | Opp = Opp1 + 0.000001*Opp2 | ||
| + | print(Opp) | ||
| + | Opp3 = Chop(Opp, | ||
| + | print(Opp3) | ||
| + | |||
| + | psi = psi1 + 0.00001 * psi2 | ||
| + | print(psi) | ||
| + | psi3 = Chop(psi, | ||
| + | print(psi3) | ||
| + | |||
| + | a = 0.000001 + 0.3 * I | ||
| + | b = Chop(a, | ||
| + | print(" | ||
| + | </ | ||
| + | |||
| + | ==== Result ==== | ||
| + | <file Quanty_Output Chop.out> | ||
| + | |||
| + | Operator: Lx | ||
| + | QComplex | ||
| + | MaxLength | ||
| + | NFermionic modes = 6 (Number of fermionic modes (site, spin, orbital, ...) in the one particle basis) | ||
| + | NBosonic modes | ||
| + | |||
| + | Operator of Length | ||
| + | QComplex | ||
| + | N | ||
| + | C 3 A 1 | 7.071067811865476E-01 -7.071067811865476E-07 | ||
| + | C 1 A 3 | 7.071067811865476E-01 | ||
| + | C 2 A 0 | 7.071067811865476E-01 -7.071067811865476E-07 | ||
| + | C 0 A 2 | 7.071067811865476E-01 | ||
| + | C 5 A 3 | 7.071067811865476E-01 -7.071067811865476E-07 | ||
| + | C 3 A 5 | 7.071067811865476E-01 | ||
| + | C 4 A 2 | 7.071067811865476E-01 -7.071067811865476E-07 | ||
| + | C 2 A 4 | 7.071067811865476E-01 | ||
| + | |||
| + | |||
| + | |||
| + | Operator: Lx | ||
| + | QComplex | ||
| + | MaxLength | ||
| + | NFermionic modes = 6 (Number of fermionic modes (site, spin, orbital, ...) in the one particle basis) | ||
| + | NBosonic modes | ||
| + | |||
| + | Operator of Length | ||
| + | QComplex | ||
| + | N | ||
| + | C 3 A 1 | 7.071067811865476E-01 | ||
| + | C 1 A 3 | 7.071067811865476E-01 | ||
| + | C 2 A 0 | 7.071067811865476E-01 | ||
| + | C 0 A 2 | 7.071067811865476E-01 | ||
| + | C 5 A 3 | 7.071067811865476E-01 | ||
| + | C 3 A 5 | 7.071067811865476E-01 | ||
| + | C 4 A 2 | 7.071067811865476E-01 | ||
| + | C 2 A 4 | 7.071067811865476E-01 | ||
| + | |||
| + | |||
| + | |||
| + | WaveFunction: | ||
| + | QComplex | ||
| + | N = 3 (Number of basis functions used to discribe psi) | ||
| + | NFermionic modes = 6 (Number of fermions in the one particle basis) | ||
| + | NBosonic modes | ||
| + | |||
| + | # pre-factor | ||
| + | | ||
| + | | ||
| + | | ||
| + | |||
| + | |||
| + | |||
| + | WaveFunction: | ||
| + | QComplex | ||
| + | N = 2 (Number of basis functions used to discribe psi) | ||
| + | NFermionic modes = 6 (Number of fermions in the one particle basis) | ||
| + | NBosonic modes | ||
| + | |||
| + | # pre-factor | ||
| + | | ||
| + | | ||
| + | |||
| + | |||
| + | a = (1e-06 + 0.3 I) | ||
| + | Chop(a) = (0 + 0.3 I) | ||
| + | |||
| + | </ | ||
| + | |||
| + | ==== Options ==== | ||
| + | |||
| + | The last element of Chop can be a table of options. Possible options are: | ||
| + | * " | ||
| + | |||
| + | ===== Table of contents ===== | ||
| + | {{indexmenu> | ||