# Number of solutions within an interval

What I'm trying to calculate is the following $$\int_0^{2\pi}dz_1\sum_{j\text{ s.t. } z_2^{(j)}=\arccos(\lambda-\cos(z1))\text{ or }\\\text{ written another way}\\0\leq\arccos(\lambda-\cos(z1))\leq\frac{2\pi}{B}}\frac{1}{\sqrt{1-\left(\lambda-\cos(z_1)\right)^2}}.$$

I want to find $$z_2^{(j)}$$ such that $$F(z_2^{(j)})=0,$$ where there are $$j$$ roots to this equation. I want to find $$j$$ such that $$z_2^{(j)}\in[0,\frac{2\pi}{B}]$$ ($$B$$ is a constant) and $$F(z_2)=\cos(z_2)-(\lambda-\cos(z_1))$$ and where $$\lambda$$ is a parameter ($$\lambda\in(-2,2)$$) which I want to plot over later, but for now I want to leave it as a constant

MY ANSWER: In my example I set $$B=2$$, but it would be nice to have it for a general $$B$$. I think $$j=1$$ since re-arranging we have $$\cos(z_2)=\lambda-\cos(z_1)$$ and since $$\cos(z_2)$$ in bijective in this interval there is only one solution. But this doesn't restrict $$\cos(z_2)$$ since my $$\lambda\in(-2,2)$$, this will cause the sqrt to be complex which by $$\cos(z_2)=\lambda-\cos(z_1)$$ cannot happen since $$|\cos(z_2)|\leq1$$.

How would one go about solving such a problem analytically? If not can someone possibly point me in the direction of some python document where a similar problem is tackled? I have tried to implement it in python using an if statement, but since I want to integrate it with respect to the argument that is being restricted it's quite difficult... Any help would be greatly appreciated!