# $n$-th derivative of Matern function

$$C_{\nu }(d)$$ is the Matérn covariance function and has this definition: $${\displaystyle C_{\nu }(d)=\sigma ^{2}{\frac {2^{1-\nu }}{\Gamma (\nu )}}{\Bigg (}{\sqrt {2\nu }}{\frac {d}{\rho }}{\Bigg )}^{\nu }K_{\nu }{\Bigg (}{\sqrt {2\nu }}{\frac {d}{\rho }}{\Bigg )},}$$ where Γ is the gamma function, $$K_{\nu }$$ is the modified Bessel function of the second kind, and ρ and ν are positive parameters of the covariance.

I would like to calculate the $$n$$th derivative

Using the definition I found that:

$$\frac{d}{dx}C_{\nu}\left(x\right)=v\left(\frac{1}{x}C_\nu\left(x\right)-\frac{x}{2\rho^{2}\left(\nu-1\right)}C_{\nu-1}\left(\sqrt{\frac{\nu}{\nu-1}}x\right)-\frac{1}{x}C_{\nu+1}\left(\sqrt{\frac{\nu}{\nu+1}}x\right)\right)$$

knowing this, is it possible to directly calculate the nth derivative?

• Try applying the Leibnitz rule $(fg)^{(n)}=\sum_{k=0}^n \binom{n}{k} f^{(k)}g^{(n-k)}$. Jan 28 at 0:06

$$\frac{\partial ^n\left((A x)^v K_v(A x)\right)}{\partial x^n}=\\-2^{-1+n-v} A^v \pi x^{-n+v} (A x)^v \csc (\pi v) \Gamma \left(\frac{1}{2}+v\right) \, _1\tilde{F}_2\left(\frac{1}{2}+v;\frac{1}{2}-\frac{n}{2}+v,1-\frac{n}{2}+v;\frac{A^2 x^2}{4}\right)+2^{-1+n+v} A^v \pi ^{3/2} x^{-n+v} (A x)^{-v} \csc (\pi v) \, _2\tilde{F}_3\left(1,\frac{1}{2};1-v,\frac{1}{2}-\frac{n}{2},1-\frac{n}{2};\frac{A^2 x^2}{4}\right)$$

where: $$A=\frac{\sqrt{2 v}}{\rho }$$ , $$\, _2\tilde{F}_3\left(1,\frac{1}{2};1-v,\frac{1}{2}-\frac{n}{2},1-\frac{n}{2};\frac{A^2 x^2}{4}\right)$$ and $$\, _1\tilde{F}_2\left(v+\frac{1}{2};-\frac{n}{2}+v+\frac{1}{2},-\frac{n}{2}+v+1;\frac{A^2 x^2}{4}\right)$$ is the regularized generalized hypergeometric function.

Mathematica code:

-2^(-1 + n - v) A^v \[Pi] x^(-n + v) (A x)^ v Csc[\[Pi] v] Gamma[ 1/2 + v] HypergeometricPFQRegularized[{1/2 + v}, {1/2 - n/2 + v, 1 - n/2 + v}, (A^2 x^2)/4] + 2^(-1 + n + v) A^v \[Pi]^(3/2) x^(-n + v) (A x)^-v Csc[\[Pi] v] HypergeometricPFQRegularized[{1, 1/ 2}, {1 - v, 1/2 - n/2, 1 - n/2}, (A^2 x^2)/4]

Using Mellin Transform and Inverse of Mellin:

$$\frac{\partial ^n\left((A x)^v K_v(a A x)\right)}{\partial x^n}=\\\mathcal{M}_s^{-1}\left[\frac{\partial ^n\mathcal{M}_a\left[(A x)^v K_v(a A x)\right](s)}{\partial x^n}\right](1)=\\\mathcal{M}_s^{-1}\left[\frac{\partial ^n}{\partial x^n}\left(2^{-2+s} (A x)^{-s+v} \Gamma \left(\frac{s}{2}-\frac{v}{2}\right) \Gamma \left(\frac{s}{2}+\frac{v}{2}\right)\right)\right](1)=\\\mathcal{M}_s^{-1}\left[\frac{2^{-2+s} A^n (A x)^{-n-s+v} \Gamma \left(\frac{s}{2}-\frac{v}{2}\right) \Gamma \left(\frac{s}{2}+\frac{v}{2}\right) \Gamma (1-s+v)}{\Gamma (1-n-s+v)}\right](1)=-2^{-1+n-v} A^v \pi x^{-n+v} (A x)^v \csc (\pi v) \Gamma \left(\frac{1}{2}+v\right) \, _1\tilde{F}_2\left(\frac{1}{2}+v;\frac{1}{2}-\frac{n}{2}+v,1-\frac{n}{2}+v;\frac{A^2 x^2}{4}\right)+2^{-1+n+v} A^v \pi ^{3/2} x^{-n+v} (A x)^{-v} \csc (\pi v) \, _2\tilde{F}_3\left(1,\frac{1}{2};1-v,\frac{1}{2}-\frac{n}{2},1-\frac{n}{2};\frac{A^2 x^2}{4}\right)$$

Update 30.01.2024

With more compact solution can be expressed by FoxH function:

Mathematica code:

1/4 A^v x^(-n + v)FoxH[{{{-v, 1}}, {{1 - n + v, -1}}}, {{{v/2, 1/2}, {-v/2, 1/2}}, {}}, (A x)/2]

or: