File: test_combinatorics.mac

package info (click to toggle)
maxima 5.27.0-3
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 120,648 kB
  • sloc: lisp: 322,503; fortran: 14,666; perl: 14,343; tcl: 11,031; sh: 4,146; makefile: 2,047; ansic: 471; awk: 24; sed: 10
file content (42 lines) | stat: -rw-r--r-- 1,615 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/* Original version of this file copyright 1999 by Michael Wester,
 * and retrieved from http://www.math.unm.edu/~wester/demos/Combinatorics/problems.macsyma
 * circa 2006-10-23.
 *
 * Released under the terms of the GNU General Public License, version 2,
 * per message dated 2007-06-03 from Michael Wester to Robert Dodier
 * (contained in the file wester-gpl-permission-message.txt).
 *
 * See: "A Critique of the Mathematical Abilities of CA Systems"
 * by Michael Wester, pp 25--60 in
 * "Computer Algebra Systems: A Practical Guide", edited by Michael J. Wester
 * and published by John Wiley and Sons, Chichester, United Kingdom, 1999.
 */
/* ----------[ M a c s y m a ]---------- */
/* ---------- Initialization ---------- */
showtime: all$
prederror: false$
/* ---------- Combinatorial Theory ---------- */
/* Pochhammer symbol (a)_n = a (a + 1) ... (a + n - 1) => a (a + 1) (a + 2) */
pochhammer(a, 3);
/* Binomial coefficient => n (n - 1) (n - 2)/6 */
binomial(n, 3);
/* 2^n n! (2 n - 1)!! => (2 n)! */
declare(n, integer)$
2^n * n! * (2*n - 1)!!;
makefact(%);
ratsimp(subst(ceiling((2*n - 1)/2) = n, %));
remove(n, integer)$
/* 2^n n! product(2 k - 1, k = 1..n) => (2 n)! */
2^n * n! * product(2*k - 1, k, 1, n);
closedform(%);
/* => (2 n)!/[2^(2 n) (n!)^2]   or   (2 n - 1)!!/[2^n n!] */
gamma(n + 1/2)/(sqrt(%pi) * n!);
makegamma(%);
/* Partitions of an integer => {1+1+1+1, 1+1+2, 1+3, 2+2, 4} (5 in all) */
numpartitions(4);
/* Stirling numbers of the first kind: S_1(5, 2) => -50 */
/*stirling1(5, 2);*/
/* Euler's totient function => 576 */
totient(1776);
/* ---------- Quit ---------- */
quit();