The function simplify(x) for operator expressions uses something like undo_average( simplify( average(x) ) ), to use the simplification rules for "normal" numbers of SymbolicUtils. This causes problems if x already includes averages like x = a*average(a), which leads to the wrong result a*average(a) -> a*a. Such terms appear if one deals with measurement backaction. To circumvent this problem, one can simply create the average of the expression as soon as possible. I mention this here since I made this mistake multiple times.
@david-pl Do you think there would be a problem to average terms, in general, as soon as possible after the operator algebra is applied? The only "major" change I see is that we would not have the operator_equations. But I think we only use the operator_equations for the correlation function, so maybe we can just create them there with undo_average()?
The function
simplify(x)for operator expressions uses something likeundo_average( simplify( average(x) ) ), to use the simplification rules for "normal" numbers of SymbolicUtils. This causes problems ifxalready includes averages likex = a*average(a), which leads to the wrong resulta*average(a) -> a*a. Such terms appear if one deals with measurement backaction. To circumvent this problem, one can simply create the average of the expression as soon as possible. I mention this here since I made this mistake multiple times.@david-pl Do you think there would be a problem to average terms, in general, as soon as possible after the operator algebra is applied? The only "major" change I see is that we would not have the
operator_equations. But I think we only use theoperator_equationsfor the correlation function, so maybe we can just create them there withundo_average()?