Double factorial function
MuPAD® notebooks are not recommended. Use MATLAB® live scripts instead.
MATLAB live scripts support most MuPAD functionality, though there are some differences. For more information, see Convert MuPAD Notebooks to MATLAB Live Scripts.
n !! fact2(
fact2(n) represents the double factorial
of an integer. The double factorial is defined as for
even positive integers and for
odd positive integers.
The short hand call
n!! is equivalent to
(-1)!! both return
n is an integer greater or equal to
smaller than the value given by
then an integer is returned. If
n is an integer
-1 or a non-integer numerical value
then an error occurs. If
n is a symbolic expression,
then a symbolic call of
fact2 is returned.
expand(n!!) to compute an explicit result
for large integers
n equal to or larger than
Note that the double factorial
n!! does not equal
the iterated factorial
Integer numbers are produced if the argument is an integer greater than or equal to - 1:
fact2(-1), fact2(0), fact2(5), fact2(16)
A symbolic call is returned if the argument is a symbolic expression:
5!! = fact2(5), fact2(n^2 + 3)
rewrite(fact2(2*n)/fact2(2*n - 1), gamma)
assume(n, Type::Integer): Simplify(%2)
For efficiency, the double factorial should be rewritten in
a floating-point evaluation for large arguments is desired. The following
call produces a huge exact integer that is finally converted to a
The following call is much faster because no exact intermediate result is computed:
float(subs(rewrite(fact2(n), gamma), n = 2^17))
An arithmetical expression representing an integer greater than or equal to - 1.