From f35bac8212c5b491b6c252050eaf7a0f94f9d9e6 Mon Sep 17 00:00:00 2001 From: TimWeaving Date: Tue, 28 Nov 2023 11:35:42 +0000 Subject: [PATCH] Expectation value is a real quantity --- symmer/operators/base.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/symmer/operators/base.py b/symmer/operators/base.py index 39ea7780..80c0c54f 100644 --- a/symmer/operators/base.py +++ b/symmer/operators/base.py @@ -830,7 +830,7 @@ def expval(self, psi: "QuantumState") -> complex: complex: The expectation value. """ if self.n_terms > psi.n_terms: - return psi.dagger * self * psi + return (psi.dagger * self * psi).real else: if self.n_terms > 1: @process.parallelize @@ -841,7 +841,7 @@ def f(P, psi): else: expvals = np.array(single_term_expval(self, psi)) - return np.sum(expvals * self.coeff_vec) + return np.sum(expvals * self.coeff_vec).real def __mul__(self, mul_obj: Union["PauliwordOp", "QuantumState", complex],