Normal order should reduce, not the other way around
See original GitHub issueEnvironment
- Qiskit Nature version: 98de3b06fbc8b03e4079fbf7e256169f0196facc
- Python version: N/A
- Operating system: N/A
What is happening?
Normal ordering should put an operator into a canonical form. This means that two equivalent operators should have the same normal order. So FermionicOp.to_normal_order
should “reduce” the operator by merging terms with the same label. It currently does not do this.
Reducing an operator should refer to merging terms with the same label. This is a useful operation in itself. It should not perform normal ordering, which takes exponential time in general. Reducing should be efficient. Currently, reducing a FermionicOp normal orders it, which is incorrect behavior.
How can we reproduce the issue?
import random
from qiskit_nature.operators.second_quantization import FermionicOp
random.seed(123)
k = 50
n = 100
op = sum(
(FermionicOp(''.join(random.choices('+-ENI', k=k)), display_format="dense") * random.random())
for _ in range(n))
op.reduce()
What should happen?
This operation should complete in at most a few seconds, probably under one second. Instead, it takes a very long time (I have not witnessed it complete, so I don’t know how long).
Any suggestions?
FermionicOp.to_normal_order
should normal order and reduce, and FermionicOp.reduce
should only reduce (not normal order).
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (7 by maintainers)
Top GitHub Comments
Actually,
simplified
is a better name because the method returns a copy rather than modifying the operator in place. But we’d need to usesimplify
to be consistent withSparsePauliOp
. But then the tense would be inconsistent withnormal_ordered
. Unfortunate…Ok I’ll go ahead then. Just to be clear, the agreed changes are:
simplify
and deprecatereduce
.normal_ordered
and deprecateto_normal_order
.