## Maxima – 199 – Insiemi – 8

Continuo da qui, copio dal Reference Manual, PDF scaricabile da qui, sono a p.601.

`stirling1 (n, m)`
Represents the Stirling number of the first kind.

When `n` and `m` are nonnegative integers, the magnitude of `stirling1 (n, m)` is the number of permutations of a set with `n` members that have `m` cycles.

`stirling1` is a simplifying function. Maxima knows the following identities:

• `stirling1(1, k) = kron_delta(1, k), k >= 0`,(see here)
• `stirling1(n, n) = 1, n >= 0` (see here)
• `stirling1(n, n − 1) = −binomial(n, 2), n >= 1`, (see here)
• `stirling1(n, 0) = kron d elta(n, 0), n >= 0` (see here and here)
• `stirling1(n, 1) = (−1) ( n − 1)(n − 1)!, n >= 1` (see here)
• `stirling1(n, k) = 0, n >= 0` and `k > n`.

These identities are applied when the arguments are literal integers or symbols declared as integers, and the first argument is nonnegative. `stirling1` does not simplify for non-integer arguments.

``````(%i1) declare (n, integer)\$

(%i2) assume (n >= 0)\$

(%i3) stirling1 (n, n);
(%o3)                                  1``````

`stirling2 (n, m)`
Represents the Stirling number of the second kind.

When `n` and `m` are nonnegative integers, `stirling2 (n, m)` is the number of ways a set with cardinality `n` can be partitioned into `m` disjoint subsets.

• `stirling2` is a simplifying function. Maxima knows the following identities:
• `stirling2(n, 0) = 1, n >= 1` (see here) and `stirling2(0,0) = 1)`
• `stirling2(n, n) = 1, n >= 0`, (see here)
• `stirling2(n, 1) = 1, n >= 1`, (see here) and `stirling2(0,1) = 0)`
• `stirling2(n, 2) = 2 ( n − 1) − 1, n >= 1`, (see here)
• `stirling2(n, n − 1) = binomial(n, 2), n >= 1` (see here)
• `stirling2(n, k) = 0, n >= 0` and `k > n`.

These identities are applied when the arguments are literal integers or symbols declared as integers, and the first argument is nonnegative. `stirling2` does not simplify for non-integer arguments.

``````(%i1) declare (n, integer)\$

(%i2) assume (n >= 0)\$

(%i3) stirling2 (n, n);
(%o3)                                  1``````

`stirling2` does not simplify for non-integer arguments.

``````(%i4) stirling2 (%pi, %pi);
(%o4)                         stirling2(%pi, %pi)``````

`subset (a, f)`
Returns the subset of the set `a` that satisfies the predicate `f`.

`subset` returns a set which comprises the elements of `a` for which `f` returns anything other than `false`. `subset` does not apply is to the return value of `f`.

`subset` complains if `a` is not a literal set.

See also `partition_set`.

``````(%i5) subset ({1, 2, x, x + y, z, x + y + z}, atom);
(%o5)                            {1, 2, x, z}
(%i6) subset ({1, 2, 7, 8, 9, 14}, evenp);
(%o6)                             {2, 8, 14}``````

`subsetp (a, b)`
Returns `true` if and only if the set `a` is a subset of `b`.

`subsetp` complains if either `a` or `b` is not a literal set.

``````(%i7) subsetp ({1, 2, 3}, {a, 1, b, 2, c, 3});
(%o7)                                true
(%i8) subsetp ({a, 1, b, 2, c, 3}, {1, 2, 3});
(%o8)                                false``````

`symmdifference (a_1, ..., a_n)`
Returns the symmetric difference of sets `a_1, ..., a_n`.

Given two arguments, `symmdifference (a, b)` is the same as `union (setdifference (a, b), setdifference (b, a))`.

`symmdifference` complains if any argument is not a literal set.

``````(%i9) S_1 : {a, b, c};
(%o9)                              {a, b, c}
(%i10) S_2 : {1, b, c};
(%o10)                             {1, b, c}
(%i11) S_3 : {a, b, z};
(%o11)                             {a, b, z}
(%i12) symmdifference ();
(%o12)                                {}
(%i13) symmdifference (S_1);
(%o13)                             {a, b, c}
(%i14) symmdifference (S_1, S_2);
(%o14)                              {1, a}
(%i15) symmdifference (S_1, S_2, S_3);
(%o15)                             {1, b, z}
(%i16) symmdifference ({}, S_1, S_2, S_3);
(%o16)                             {1, b, z}``````

`union (a_1, ..., a_n)`
Returns the union of the sets `a_1` through `a_n`.

`union()` (with no arguments) returns the empty set.

`union` complains if any argument is not a literal set.

``````(%i17) S_1 : {a, b, c + d, %e};
(%o17)                         {%e, a, b, d + c}
(%i18) S_2 : {%pi, %i, %e, c + d};
(%o18)                       {%e, %i, %pi, d + c}
(%i19) S_3 : {17, 29, 1729, %pi, %i};
(%o19)                      {17, 29, 1729, %i, %pi}
(%i20) union ();
(%o20)                                {}
(%i21) union (S_1);
(%o21)                         {%e, a, b, d + c}
(%i22) union (S_1, S_2);
(%o22)                    {%e, %i, %pi, a, b, d + c}
(%i23) union (S_1, S_2, S_3);
(%o23)             {17, 29, 1729, %e, %i, %pi, a, b, d + c}
(%i24) union ({}, S_1, S_2, S_3);
(%o24)             {17, 29, 1729, %e, %i, %pi, a, b, d + c}``````

Posta un commento o usa questo indirizzo per il trackback.