Stan Math Library
5.0.0
Automatic Differentiation
|
|
inline |
Returns the gradient of generalized hypergeometric function wrt to the input arguments: \( _pF_q(a_1,...,a_p;b_1,...,b_q;z) \).
Where: \( \frac{\partial }{\partial a_1} = \sum_{k=0}^{\infty}{ \frac {\psi\left(k+a_1\right)\left(\prod_{j=1}^p\left(a_j\right)_k\right)z^k} {k!\prod_{j=1}^q\left(b_j\right)_k}} - \psi\left(a_1\right){}_pF_q(a_1,...,a_p;b_1,...,b_q;z) \) \( \frac{\partial }{\partial b_1} = \psi\left(b_1\right){}_pF_q(a_1,...,a_p;b_1,...,b_q;z) - \sum_{k=0}^{\infty}{ \frac {\psi\left(k+b_1\right)\left(\prod_{j=1}^p\left(a_j\right)_k\right)z^k} {k!\prod_{j=1}^q\left(b_j\right)_k}} \)
\( \frac{\partial }{\partial z} = \frac{\prod_{j=1}^{p}(a_j)}{\prod_{j=1}^{q} (b_j)}\ {}_pF_q(a_1+1,...,a_p+1;b_1+1,...,b_q+1;z) \)
Noting the the recurrence relation for the digamma function: \( \psi(x + 1) = \psi(x) + \frac{1}{x} \), the gradients for the function with respect to a and b then simplify to: \( \frac{\partial }{\partial a_1} = \sum_{k=1}^{\infty}{ \frac {\left(1 + \sum_{m=0}^{k-1}\frac{1}{m+a_1}\right) * \left(\prod_{j=1}^p\left(a_j\right)_k\right)z^k} {k!\prod_{j=1}^q\left(b_j\right)_k}} - {}_pF_q(a_1,...,a_p;b_1,...,b_q;z) \) \( \frac{\partial }{\partial b_1} = {}_pF_q(a_1,...,a_p;b_1,...,b_q;z) - \sum_{k=1}^{\infty}{ \frac {\left(1 + \sum_{m=0}^{k-1}\frac{1}{m+b_1}\right) * \left(\prod_{j=1}^p\left(a_j\right)_k\right)z^k} {k!\prod_{j=1}^q\left(b_j\right)_k}} \)
calc_a | Boolean for whether to calculate derivatives wrt to 'a' |
calc_b | Boolean for whether to calculate derivatives wrt to 'b' |
calc_z | Boolean for whether to calculate derivatives wrt to 'z' |
TpFq | Scalar type of hypergeometric_pFq return value |
Ta | Eigen type with either one row or column at compile time |
Tb | Eigen type with either one row or column at compile time |
Tz | Scalar type |
[in] | pfq_val | Return value from the hypergeometric_pFq function |
[in] | a | Vector of 'a' arguments to function |
[in] | b | Vector of 'b' arguments to function |
[in] | z | Scalar z argument |
[in] | precision | Convergence criteria for infinite sum |
[in] | max_steps | Maximum number of iterations |
Definition at line 92 of file grad_pFq.hpp.