Automatic Differentiation
 
Loading...
Searching...
No Matches

◆ grad_pFq()

template<bool calc_a = true, bool calc_b = true, bool calc_z = true, typename TpFq , typename Ta , typename Tb , typename Tz , typename T_Rtn = return_type_t<Ta, Tb, Tz>, typename Ta_Rtn = promote_scalar_t<T_Rtn, plain_type_t<Ta>>, typename Tb_Rtn = promote_scalar_t<T_Rtn, plain_type_t<Tb>>>
std::tuple< Ta_Rtn, Tb_Rtn, T_Rtn > stan::math::grad_pFq ( const TpFq &  pfq_val,
const Ta &  a,
const Tb &  b,
const Tz &  z,
double  precision = 1e-14,
int  max_steps = 1e6 
)

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}} \)

Template Parameters
calc_aBoolean for whether to calculate derivatives wrt to 'a'
calc_bBoolean for whether to calculate derivatives wrt to 'b'
calc_zBoolean for whether to calculate derivatives wrt to 'z'
TpFqScalar type of hypergeometric_pFq return value
TaEigen type with either one row or column at compile time
TbEigen type with either one row or column at compile time
TzScalar type
Parameters
[in]pfq_valReturn value from the hypergeometric_pFq function
[in]aVector of 'a' arguments to function
[in]bVector of 'b' arguments to function
[in]zScalar z argument
[in]precisionConvergence criteria for infinite sum
[in]max_stepsMaximum number of iterations
Returns
Tuple of gradients

Definition at line 92 of file grad_pFq.hpp.