I'm trying to use a Matérn 5/2 kernel for GP regression, so my kernel function is $ K(x,x')\triangleq\theta_0(1+\sqrt{5r(x,x')}+5/3r)\exp(-\sqrt{5r}), $ where $r(x,x')\triangleq\sum_{d=1}^D (x_d-x'_d)^2/\theta_d^2$
I want to optimize the marginal likelihood--the gradient of which involves calculating $\frac{\partial K}{\partial\theta_i}.$ The problem, though is for $x=x'$, i.e., the diagonal entries of $K$, $r(\cdot)=0$, making $\frac{\partial K}{\partial\theta_i}$ undefined at the diagonal, as $\sqrt{(\cdot)}$ doesn't have a defined derivative at 0.
This seems like a very obvious problem, but google hasn't revealed anything, so maybe I'm missing something.