! | factorial |
!! | factorial and related functions |
*** | factorial and related functions |
Subfactorial | factorial and related functions |
Bin | binomial coefficients |
Eulerian | Eulerian numbers |
LeviCivita | totally anti-symmetric Levi-Civita symbol |
Permutations | get all permutations of a list |
n! n!! a *** b Subfactorial(m) |
The "double factorial" function n!! calculates n*(n-2)*(n-4)*.... This product terminates either with 1 or with 2 depending on whether n is odd or even. If n=0 the function returns 1.
The "partial factorial" function a *** b calculates the product a*(a+1)*... which is terminated at the least integer not greater than b. The arguments a and b do not have to be integers; for integer arguments, a *** b = b! /(a-1)!. This function is sometimes a lot faster than evaluating the two factorials, especially if a and b are close together. If a>b the function returns 1.
The Subfactorial function can be interpreted as the number of permutations of m objects in which no object appears in its natural place, also called "derangements."
The factorial functions are threaded, meaning that if the argument n is a list, the function will be applied to each element of the list.
Note: For reasons of Yacas syntax, the factorial sign ! cannot precede other non-letter symbols such as + or *. Therefore, you should enter a space after ! in expressions such as x! +1.
The factorial functions terminate and print an error message if the arguments are too large (currently the limit is n<65535) because exact factorials of such large numbers are computationally expensive and most probably not useful. One can call Internal'LnGammaNum() to evaluate logarithms of such factorials to desired precision.
In> 5! Out> 120; In> 1 * 2 * 3 * 4 * 5 Out> 120; In> (1/2)! Out> Sqrt(Pi)/2; In> 7!!; Out> 105; In> 1/3 *** 10; Out> 17041024000/59049; In> Subfactorial(10) Out> 1334961; |
Bin(n, m) |
This is equal to the number of ways to choose "m" objects out of a total of "n" objects if order is not taken into account. The binomial coefficient is defined to be zero if "m" is negative or greater than "n"; Bin(0,0)=1.
In> Bin(10, 4) Out> 210; In> 10! / (4! * 6!) Out> 210; |
Eulerian(n,m) |
In> Eulerian(6,2) Out> 302; In> Eulerian(10,9) Out> 1; |
LeviCivita(list) |
In> LeviCivita({1,2,3}) Out> 1; In> LeviCivita({2,1,3}) Out> -1; In> LeviCivita({2,2,3}) Out> 0; |
Permutations(list) |
In> Permutations({a,b,c}) Out> {{a,b,c},{a,c,b},{c,a,b},{b,a,c}, {b,c,a},{c,b,a}}; |