# Preparing a maximally entangled state among four qubits

I am trying to create the following states in Qiskit, but having trouble with the nested loops. Can someone help me create it?

$$\left|\psi_o\right\rangle=\frac{1}{\sqrt{8}}\left(\sum_i \hat{\sigma}_{x, i}+\sum_{i, j, k} \hat{\sigma}_{x, i} \hat{\sigma}_{x, j} \hat{\sigma}_{x, k}\right)|0,0,0,0\rangle$$, and

$$\left|\psi_e\right\rangle=\frac{1}{\sqrt{8}}\left(\sum_{i, j} \hat{\sigma}_{x, i} \hat{\sigma}_{x, j}+\hat{I}+\hat{\sigma}_{x, 1} \hat{\sigma}_{x, 2} \hat{\sigma}_{x, 3} \hat{\sigma}_{x, 4}\right)|0,0,0,0\rangle$$

• So, just to be clear, you want to make two states, which are the uniform superposition over all basis states, just with even/odd numbers of 1s in them? Mar 9, 2023 at 15:23

Here's a trick: if I apply Hadamard to all 4 qubits initially in the $$|0\rangle$$ state, I prepare a uniform superposition over all basis states. If I apply Hadamard to all 4 qubits initially in the $$|1\rangle$$ state, I prepare a superposition over all basis states, but those with an odd number of 1s have a -1 phase.
Hence, to produce the even weighted superposition, it is enough to produce $$\frac{1}{\sqrt{2}}(|0000\rangle+|1111\rangle)$$ and apply Hadamard to all 4 qubits. I'm hoping you know how to prepare that 4 qubit state.