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

◆ falling_factorial() [2/5]

template<typename T , require_arithmetic_t< T > * = nullptr>
return_type_t< T > stan::math::falling_factorial ( const T &  x,
int  n 
)
inline

Return the falling factorial function evaluated at the inputs.

Will throw for NaN x and for negative n

Template Parameters
TType of x argument.
Parameters
xArgument.
nArgument
Returns
Result of falling factorial function.
Exceptions
std::domain_errorif x is NaN
std::domain_errorif n is negative

\[ \mbox{falling\_factorial}(x, n) = \begin{cases} \textrm{error} & \mbox{if } x \leq 0\\ (x)_n & \mbox{if } x > 0 \textrm{ and } -\infty \leq n \leq \infty \\[6pt] \textrm{NaN} & \mbox{if } x = \textrm{NaN or } n = \textrm{NaN} \end{cases} \]

\[ \frac{\partial\, \mbox{falling\_factorial}(x, n)}{\partial x} = \begin{cases} \textrm{error} & \mbox{if } x \leq 0\\ \frac{\partial\, (x)_n}{\partial x} & \mbox{if } x > 0 \textrm{ and } -\infty \leq n \leq \infty \\[6pt] \textrm{NaN} & \mbox{if } x = \textrm{NaN or } n = \textrm{NaN} \end{cases} \]

\[ \frac{\partial\, \mbox{falling\_factorial}(x, n)}{\partial n} = \begin{cases} \textrm{error} & \mbox{if } x \leq 0\\ \frac{\partial\, (x)_n}{\partial n} & \mbox{if } x > 0 \textrm{ and } -\infty \leq n \leq \infty \\[6pt] \textrm{NaN} & \mbox{if } x = \textrm{NaN or } n = \textrm{NaN} \end{cases} \]

\[ (x)_n=\frac{\Gamma(x+1)}{\Gamma(x-n+1)} \]

\[ \frac{\partial \, (x)_n}{\partial x} = (x)_n\Psi(x+1) \]

\[ \frac{\partial \, (x)_n}{\partial n} = -(x)_n\Psi(n+1) \]

Definition at line 64 of file falling_factorial.hpp.