# How to integrate a function with the Haar measure over multiple qubits

I am starting with a product state over multiple qubits. That looks like the expression below. $$|\psi\rangle = \left(\cos\left(\frac{\theta_1}{2}\right)|0\rangle+e^{i\phi_1}\sin\left(\frac{\theta_1}{2}\right)|1\rangle \right)\otimes\left(\cos\left(\frac{\theta_2}{2}\right)|0\rangle+e^{i\phi_2}\sin\left(\frac{\theta_2}{2}\right) |1\rangle\right)\,.$$

After doing some calculations, I obtain a function of $$\theta$$ and $$\phi$$. e.g.

$$f(\theta_1,\theta_2,\phi_1,\phi_2)=\cos ^2\left(\frac{\text{\theta_1}}{2}\right) \cos ^2\left(\frac{\text{\theta_2}}{2}\right)\,.$$ (This specific example doesn't contain $$\phi_1$$ or $$\phi_2$$. But, they are present in general.) I am not sure, how can I integrate $$f(\theta_1,\theta_2,\phi_1,\phi_2)$$ over Haar random states. I know for single qubit, we can integrate with a measure $$\sin(\theta) \,\mathrm{d}\theta$$ with $$\theta \in [0,\pi]$$. My doubt is what should be the way for multiple qubits. Any help is much appreciated. Feel free to ask for any clarification. Thank you in advance.

• A Haar-random quantum state on $2$ qubits is parametrized by $3$ amplitudes and $3$ relative phases. Since you only have $2$ of each, does that mean that you want to integrate over tensor products of Haar-random states independently? Commented Oct 25, 2023 at 13:54
• BTW your formula for $\psi$ is missing some basis vectors. Just as a remark: It seems that the function you want to integrate is a polynomial in the state. In this case, there are more elegant ways to integrate which do not involve an explicit parametrization. This is also the way to go in a general $n$-qubit setting. Commented Oct 25, 2023 at 14:07