bundles / scipy 1.17.1 / scipy / special / _basic / factorial2
function
scipy.special._basic:factorial2
source: /scipy/special/_basic.py :2996
Signature
def factorial2 ( n , exact = False , extend = zero ) Summary
Double factorial.
Extended Summary
This is the factorial with every second value skipped. E.g., 7!! = 7 * 5 * 3 * 1. It can be approximated numerically as
n!! = 2 ** (n / 2) * gamma(n / 2 + 1) * sqrt(2 / pi) n odd = 2 ** (n / 2) * gamma(n / 2 + 1) n even = 2 ** (n / 2) * (n / 2)! n even
The formula for odd n is the basis for the complex extension.
Parameters
n: int or float or complex (or array_like thereof)Input values for
n!!. Non-integer values requireextend='complex'. By default, the return value forn < 0is 0.exact: bool, optionalIf
exactis set to True, calculate the answer exactly using integer arithmetic, otherwise use above approximation (faster, but yields floats instead of integers). Default is False.extend: string, optionalOne of
'zero'or'complex'; this determines how valuesn<0are handled - by default they are 0, but it is possible to opt into the complex extension of the double factorial. This also enables passing complex values ton.
Returns
nf: int or float or complex or ndarrayDouble factorial of
n, as integer, float or complex (depending onexactandextend). Array inputs are returned as arrays.
Examples
from scipy.special import factorial2 factorial2(7, exact=False) factorial2(7, exact=True)✓
Aliases
-
scipy.special.factorial2