Maxima – 197 – Insiemi – 6

wzrQ

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

num_distinct_partitions (n, list)
num_distinct_partitions (n)
Returns the number of distinct integer partitions of n when n is a nonnegative integer.

Otherwise, num_distinct_partitions returns a noun expression.

num_distinct_partitions(n, list) returns a list of the number of distinct partitions of 1, 2, 3, ..., n.

A distinct partition of n is a list of distinct positive integers k_1 , ..., k_m such that n = k_1 + ... + k_m.

(%i1) num_distinct_partitions (12);
(%o1)                                 15
(%i2) num_distinct_partitions (12, list);
(%o2)               [1, 1, 2, 2, 3, 4, 5, 6, 8, 10, 12, 15]
(%i3) num_distinct_partitions (n);
(%o3)                     num_distinct_partitions(n)

num_partitions (n)
num_partitions (n, list)
Returns the number of integer partitions of n when n is a nonnegative integer. Otherwise, num_partitions returns a noun expression.

num_partitions(n, list) returns a list of the number of integer partitions of 1, 2, 3, ..., n.

For a nonnegative integer n, num_partitions(n) is equal to cardinality(integer_partitions(n)); however, num_partitions does not actually construct the set of partitions, so it is much faster.

(%i4) num_partitions (5) = cardinality (integer_partitions (5));
(%o4)                                7 = 7
(%i5) num_partitions (8, list);
(%o5)                     [1, 2, 3, 5, 7, 11, 15, 22]
(%i6) num_partitions (n);
(%o6)                          num_partitions(n)

partition_set (a, f)
Partitions the set a according to the predicate f.

partition_set returns a list of two sets. The first set comprises the elements of a for which f evaluates to false, and the second comprises any other elements of a.

partition_set does not apply is to the return value of f.

partition_set complains if a is not a literal set.

See also subset.

(%i7) partition_set ({2, 7, 1, 8, 2, 8}, evenp);
(%o7)                          [{1, 7}, {2, 8}]
(%i8) partition_set ({x, rat(y), rat(y) + z, 1}, lambda ([x], ratp(x)));
(%o8)/R/                     [{1, x}, {y, y + z}]

permutations (a)
Returns a set of all distinct permutations of the members of the list or set a. Each permutation is a list, not a set.

When a is a list, duplicate members of a are included in the permutations.

permutations complains if a is not a literal list or set.

See also random_permutation.

(%i9) permutations ([a, a]);
(%o9)                              {[a, a]}
(%i10) permutations ([a, a, b]);
(%o10)                 {[a, a, b], [a, b, a], [b, a, a]}

powerset (a)
powerset (a, n)
Returns the set of all subsets of a, or a subset of that set.

powerset(a) returns the set of all subsets of the set a. powerset(a) has 2^cardinality(a) members.

powerset(a, n) returns the set of all subsets of a that have cardinality n.

powerset complains if a is not a literal set, or if n is not a nonnegative integer.

(%i11) powerset ({a, b, c});
(%o11)      {{}, {a}, {a, b}, {a, b, c}, {a, c}, {b}, {b, c}, {c}}
(%i12) powerset ({w, x, y, z}, 4);
(%o12)                          {{w, x, y, z}}
(%i13) powerset ({w, x, y, z}, 3);
(%o13)           {{w, x, y}, {w, x, z}, {w, y, z}, {x, y, z}}
(%i14) powerset ({w, x, y, z}, 2);
(%o14)         {{w, x}, {w, y}, {w, z}, {x, y}, {x, z}, {y, z}}
(%i15) powerset ({w, x, y, z}, 1);
(%o15)                       {{w}, {x}, {y}, {z}}
(%i16) powerset ({w, x, y, z}, 0);
(%o16)                               {{}}

random_permutation (a)
Returns a random permutation of the set or list a, as constructed by the Knuth shuffle algorithm.

The return value is a new list, which is distinct from the argument even if all elements happen to be the same. However, the elements of the argument are not copied.

(%i17) random_permutation ([a, b, c, 1, 2, 3]);
(%o17)                        [c, 1, 2, 3, a, b]
(%i18) random_permutation ([a, b, c, 1, 2, 3]);
(%o18)                        [b, 3, 1, c, a, 2]
(%i19) random_permutation ({x + 1, y + 2, z + 3});
(%o19)                       [y + 2, z + 3, x + 1]
(%i20) random_permutation ({x + 1, y + 2, z + 3});
(%o20)                       [x + 1, y + 2, z + 3]

setdifference (a, b)
Returns a set containing the elements in the set a that are not in the set b.

setdifference complains if either a or b is not a literal set.

(%i21) S_1 : {a, b, c, x, y, z};
(%o21)                        {a, b, c, x, y, z}
(%i22) S_2 : {aa, bb, c, x, y, zz};
(%o22)                       {aa, bb, c, x, y, zz}
(%i23) setdifference (S_1, S_2);
(%o23)                             {a, b, z}
(%i24) setdifference (S_2, S_1);
(%o24)                           {aa, bb, zz}
(%i25) setdifference (S_1, S_1);
(%o25)                                {}
(%i26) setdifference (S_1, {});
(%o26)                        {a, b, c, x, y, z}
(%i27) setdifference ({}, S_1);
(%o27)                                {}

setequalp (a, b)
Returns true if sets a and b have the same number of elements and is(x = y) is true for x in the elements of a and y in the elements of b, considered in the order determined by listify. Otherwise, setequalp returns false.

(%i28) setequalp ({1, 2, 3}, {1, 2, 3});
(%o28)                               true
(%i29) setequalp ({a, b, c}, {1, 2, 3});
(%o29)                               false
(%i30) setequalp ({x^2 - y^2}, {(x + y) * (x - y)});
(%o30)                               false

Posta un commento o usa questo indirizzo per il trackback.

Trackback

Rispondi

Inserisci i tuoi dati qui sotto o clicca su un'icona per effettuare l'accesso:

Logo WordPress.com

Stai commentando usando il tuo account WordPress.com. Chiudi sessione /  Modifica )

Google+ photo

Stai commentando usando il tuo account Google+. Chiudi sessione /  Modifica )

Foto Twitter

Stai commentando usando il tuo account Twitter. Chiudi sessione /  Modifica )

Foto di Facebook

Stai commentando usando il tuo account Facebook. Chiudi sessione /  Modifica )

Connessione a %s...

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d blogger hanno fatto clic su Mi Piace per questo: