I am reading cirq guide about Simulation and there is an example in "Expectation values" paragraph that I don't understand.
Everything boils down to the following snippet:
import cirq q0 = cirq.GridQubit(0, 0) q1 = cirq.GridQubit(1, 0) def basic_circuit(): sqrt_x = cirq.X**0.5 yield sqrt_x(q0), sqrt_x(q1) yield cirq.CZ(q0, q1) yield sqrt_x(q0), sqrt_x(q1) circuit = cirq.Circuit(basic_circuit()) XX_obs = cirq.X(q0) * cirq.X(q1) ZZ_obs = cirq.Z(q0) * cirq.Z(q1) ev_list = cirq.Simulator().simulate_expectation_values(circuit, observables=[XX_obs]) print(ev_list) # Output: [(1+0j)]
First, I don't understand what
ZZ_obs do. What does it mean to multiply two circuits by
* operator. Is it the tensor product of the operations or something else?
Second, is simulating observable
XX_obs the same as adding
XX_obs at the end of circuit? If so, how to read the following printed output:
circuit.append(XX_obs) print(circuit) # Output: (0, 0): ───X^0.5───@───X^0.5───PauliString(+X)─── │ │ (1, 0): ───X^0.5───@───X^0.5───X─────────────────
Third, if I simulate the above circuit without measurement I get the following output which does not resemble
[(1+0j)] obtained previously:
result = cirq.Simulator().simulate(circuit) print(result) # output: measurements: (no measurements) output vector: 0.5|00⟩ + 0.5j|01⟩ + 0.5j|10⟩ + 0.5|11⟩
Why is it so?
PS. It is my very first question on this site so be forgiving about tags I used or about some conventions that you use and I don't know.