# time evolution of Hamiltonian and observables

I am given the following Hamiltonian on 4 qubits.

$$H = - J_x (X_0 X_1 + X_2 X_3) - J_z (Z_0 Z_2 + Z_1 Z_3) - h\sum_{j=0}^3 X_j + Z_j$$

I have already implemented the time evolution of this Hamiltonian. Now I wish to use this to calculate $$\langle W\rangle$$, where $$W$$ is a matrix that commutes with $$X_0X_1, X_2X_3, Z_0Z_2,$$ and $$Z_1Z_3$$. I have chosen $$W = X_0 X_1 X_2 X_3$$. Now I should start with an eigenstate of $$W$$; in my case, I've taken $$\vert ++++ \rangle$$. Now I should calculate $$\langle W \rangle$$ in dependence of $$0 < t \leq 2\pi$$. But I don't really understand how to do that (maybe just apply the time evolution on the eigenstate, but what am I looking for as a result?). I don't even understand what the use of this is.

You want to calculate the expectation value of $$W = X_0 X_1 X_2 X_3$$ with respect to a state $$\vert\psi(t)\rangle$$ that you have time evolved according to $$H$$. You say you already know how to do this step, so I will assume you have the time evolved state $$\vert \psi(t)\rangle = e^{-i H t}\vert\psi_0\rangle$$ prepared on a quantum register.

## Calculating $$\langle W\rangle$$

To calculate $$\langle W\rangle$$, we measure $$W$$ in the $$X$$ basis for all the qubits. To do this, we perform a Hadamard on all the qubits, then measure all the qubits in the $$0,1$$ basis. The result is a bitstring $$b_3 b_2 b_1 b_0$$, where $$b_j$$ is the result (0 or 1) on the $$j$$th qubit. Add all the bitstrings together, and record whether the result is even or odd.

Repeat this many times (perform time evolution, Hadamards, measure) and you will get estimates of the probabilities $$p_{\mathrm{even}}$$ and $$p_{\mathrm{odd}}$$ that the results add up to an even or odd bitstring. It turns out that your expectation value is given by

$$\langle W\rangle = p_{\mathrm{even}} - p_\mathrm{odd}.$$

## What is the use of this in general?

Generally speaking, computing expectation values is extremely useful. For example, they can be used to determine the average energy of a physical system, or to compute the cost function of an optimization problem. Remember that in order to learn something useful from a quantum system, we need to do some sort of measurement. Think of expectation values as a piece of information gathered from repeated measurements.

• Thank you @Jacob for your Answer. Could I use this approach with $P_{even}$ and $P_{odd}$ for any $W$ with any Hamiltonian or is this "special" for this case? Commented Nov 12, 2023 at 9:52
• @Ruebli. For the most part, my answer is specific to your problem. If $W$ is any $n$ qubit pauli, you can compute $\langle W\rangle$ by first diagonalizing it, then doing the even-odd calculation. In your case, the Hadamards diagonalize $W$. See ryanlarose.com/uploads/1/1/5/8/115879647/quic04s02s.pdf for details. It's useful to think of time evolution by $H$ and expectation value calculations as separated procedures. The role of $H$ in this context is just to prepare the state you're interested in. Commented Nov 13, 2023 at 15:22