I think I missed something in this mechanics problem.
We're given a polish and homogeneous hemicircle which has mass $M$ and a particle of mass $m$ laying on the top of it.
There is also no friction between the hemicircle and the ground. Find the equation for the angle $\theta$ in which the particle abandons the hemicircle surface.
I can't find my mistake.
As we have no external horizontal forces acting on the system particle + hemicircle we must have conservation of the horizontal position of the center of mass.
I made this horrible drawing to try to understand the movement:
we would have $x = \frac{mR \sin(\theta)}{M+m}$, making $M = k \cdot m \iff k = \frac M m$, we would have:
$$x = \frac{R \sin(\theta)}{1+k} \implies \dot x = \frac{R \dot \theta \cos(\theta)}{1+k}$$
from this, I found that the velocity of the particle with respect to the ground was:
$$R \dot \theta (\cos (\theta)(\frac k{k+1})u_x - \sin (\theta) u_y) = \vec v_P $$
And conservation of energy
$$mgR = mgR\cos(\theta) + \frac{mv_P^2+ M \dot x^2}2$$
gave me:
$$2\frac gR(1-\cos(\theta))(1+k) = \dot \theta^2 [\sin^2(\theta) +k]$$
Finally, I used the abandonment equation: $\frac gR \cos(\theta) = \dot \theta^2$
Which led me to:
$$3 \cos(\theta) - \frac{\cos^3(\theta)}{1+k} = 2$$
but I feel something is wrong because $k=0$ should give me $\cos(\theta) = \frac23$ any insights on my mistakes?
EDIT: I think on the line of the energy conservation the term $\sin^2(\theta)$ is the one causing trouble. I'm very confident about the expression for the velocity of the particle.

Hint.
Assuming that the movement occurs into a maximum declivity plane, and calling $A$ the semi-sphere center and $B$ the $m$ mass position, we have
$$ B = A + R(\sin\theta,\cos\theta) $$
then $\dot B = \dot A + R(\cos\theta,-\sin\theta)\dot\theta$ so the lagrangian can be established as
$$ L = \frac 12 m \|\dot B\|^2+\frac 12 M\|\dot A\|^2-m g R\cos\theta $$
with $A = (a,0)$ and the movement equations (while in contact) are
$$ \left\{ \begin{array}{rcl} \ddot a& =& \frac{m \sin (\theta) \left(R \dot\theta^2-g \cos (\theta)\right)}{M+m-m \cos ^2(\theta)} \\ \ddot\theta&=&\frac{\sin (\theta) \left(m R \dot\theta^2 \cos (\theta )-g (m+M)\right)}{m R \cos ^2(\theta)-R (m+M)} \\ \end{array} \right. $$