I need to compute the derivative of a function $M=M(R,\theta)$ depending on two variables $R, \theta$ with respect to another function $H=H(R,\theta)$ of the same variables. I know the result, but I cannot retrace its computation.
Here is my functions: $$M(R,\theta)=m_0 R^{\beta} \theta$$ $$H(R,\theta)=h_0 R^{\beta \delta} h(\theta)$$ where $m_0, h_0$ are constant parameters, $h(\theta)$ is a given function of the variable $\theta$ only and the relation $\beta \delta =\beta + \gamma$ is known.
I want to compute $\frac{\partial M}{\partial H}$, so I did it this way:
$$\frac{\partial M}{\partial H}=\frac{\partial M}{\partial \theta}\frac{\partial \theta}{\partial H} + \frac{\partial M}{\partial R}\frac{\partial R}{\partial H}$$ $$\frac{\partial M}{\partial \theta}=m_0 R^{\beta}$$ $$\frac{\partial M}{\partial R}=m_0 \beta R^{\beta-1} \theta$$
$$\begin{pmatrix} \frac{\partial H}{\partial \theta} && \frac{\partial H}{\partial R} \\ \frac{\partial M}{\partial \theta} && \frac{\partial M}{\partial R} \end{pmatrix} = \begin{pmatrix} h_0 R^{\beta \delta} h'(\theta) && h_0 \beta \delta R^{\beta \delta -1} h(\theta) \\ m_0 R^{\beta} && m_0 \beta R^{\beta -1} \theta \end{pmatrix} $$ thus (by inversion of this matrix)
$$\begin{pmatrix} \frac{\partial \theta}{\partial H} && \frac{\partial \theta}{\partial M} \\ \frac{\partial R}{\partial H} && \frac{\partial R}{\partial H} \end{pmatrix} = \frac{1}{h_0 m_0 \beta R^{\beta \delta +\beta -1}(\theta h'(\theta)-\delta h(\theta))} \begin{pmatrix} m_0 \beta R^{\beta -1} \theta && -h_0 \beta \delta R^{\beta \delta -1} h(\theta) \\ -m_0 R^{\beta} && h_0 R^{\beta \delta} h'(\theta) \end{pmatrix}$$
But I end up with the result $\frac{\partial M}{\partial H}=0$, while instead I should obtain $$\frac{\partial M}{\partial H}=\frac{m_0}{h_0} R^{-\gamma} \frac{(1-\theta^2+2\beta \theta^2)}{2\beta \delta \theta h(\theta)+(1-\theta^2)h'(\theta)}$$
Where is my error?