qiskit.quantum_info.SparsePauliOp.chop¶
- SparsePauliOp.chop(tol=1e-14)[source]¶
Set real and imaginary parts of the coefficients to 0 if
< tol
in magnitude.For example, the operator representing
1+1e-17j X + 1e-17 Y
with a tolerance larger than1e-17
will be reduced to1 X
whereasSparsePauliOp.simplify()
would return1+1e-17j X
.If a both the real and imaginary part of a coefficient is 0 after chopping, the corresponding Pauli is removed from the operator.
- Parameters
tol (float) – The absolute tolerance to check whether a real or imaginary part should be set to 0.
- Returns
This operator with chopped coefficients.
- Return type