Closed Roger-luo closed 2 years ago
From slack
bug report found by @Stefano Barison while working with Yao: If you measure an operator on a state, and the operator has two blocks that cancel out each-other, you get wrong result that does not match what expect would tell you
using Yao, Statistics circ_wfn = zero_state(2) |> put(2, 1=>H) sp = put(2, 1=>(X + 1im*Y)/2) X_diff = sp + sp' X_bare = put(2, 1=>X) # check they are identical Matrix(X_bare) == Matrix(X_diff). # True expect(X_diff, circ_wfn) # 0.9999999999999998 + 0.0im expect(X_bare, circ_wfn) # 0.9999999999999998 + 0.0im measure(X_diff, circ_wfn, nshots=100) |> mean # 0.0 + 0.0im measure(X_bare, circ_wfn, nshots=100) |> mean # 1.0 + 0.0im
From slack
bug report found by @Stefano Barison while working with Yao: If you measure an operator on a state, and the operator has two blocks that cancel out each-other, you get wrong result that does not match what expect would tell you