Maxima – 198 – Insiemi – 7

top1

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

setify (a)
Constructs a set from the elements of the list a. Duplicate elements of the list a are deleted and the elements are sorted according to the predicate orderlessp.

setify complains if a is not a literal list.

(%i1) setify ([1, 2, 3, a, b, c]);
(%o1)                         {1, 2, 3, a, b, c}
(%i2) setify ([a, b, c, a, b, c]);
(%o2)                              {a, b, c}
(%i3) setify ([7, 13, 11, 1, 3, 9, 5]);
(%o3)                       {1, 3, 5, 7, 9, 11, 13}

setp (a)
Returns true if and only if a is a Maxima set.

setp returns true for unsimplified sets (that is, sets with redundant members) as well as simplified sets.

setp is equivalent to the Maxima function setp(a) := not atom(a) and op(a) = 'set.

(%i4) simp : false;
(%o4)                                false
(%i5) {a, a, a};
(%o5)                              {a, a, a}
(%i6) setp (%);
(%o6)                                true

set_partitions (a)
set_partitions (a, n)
Returns the set of all partitions of a, or a subset of that set.

set_partitions(a, n) returns a set of all decompositions of a into n nonempty disjoint subsets.

set_partitions(a) returns the set of all partitions.

stirling2 returns the cardinality of the set of partitions of a set.

A set of sets P is a partition of a set S when

  1. each member of P is a nonempty set,
  2. distinct members of P are disjoint,
  3. the union of the members of P equals S.

The empty set is a partition of itself, the conditions 1 and 2 being vacuously true.

(%i8) set_partitions ({});
(%o8)                                {{}}

The cardinality of the set of partitions of a set can be found using stirling2.

(%i9) s: {0, 1, 2, 3, 4, 5}$

(%i10) p: set_partitions (s, 3)$

(%i11) cardinality(p) = stirling2 (6, 3);
(%o11)                              90 = 90

Each member of p should have n = 3 members; let’s check.

(%i12) s: {0, 1, 2, 3, 4, 5}$

(%i13) p: set_partitions (s, 3)$

(%i14) map (lambda ([x], apply (union, listify (x))), p);
(%o14)                       {{0, 1, 2, 3, 4, 5}}

ahemmm 😐

some (f, a)
some (f, L_1, ..., L_n)
Returns true if the predicate f is true for one or more given arguments.

Given one set as the second argument, some(f, s) returns true if is(f(a_i)) returns true for one or more a_i in s. some may or may not evaluate f for all a_i in s. Since sets are unordered, some may evaluate f(a_i) in any order.

Given one or more lists as arguments, some(f, L_1, ..., L_n) returns true if is(f(x_1, ..., x_n)) returns true for one or more x_1, ..., x_n in L_1, ..., L_n, respectively. some may or may not evaluate f for some combinations x_1, ..., x n. some evaluates lists in the order of increasing index.

Given an empty set {} or empty lists [] as arguments, some returns false.

When the global flag maperror is true, all lists L_1, ..., L_n must have equal lengths. When maperror is false, list arguments are effectively truncated to the length of the shortest list.

Return values of the predicate f which evaluate (via is) to something other than true or false are governed by the global flag prederror. When prederror is true, such values are treated as false. When prederror is false, such values are treated as unknown.

some applied to a single set. The predicate is a function of one argument.

(%i15) some (integerp, {1, 2, 3, 4, 5, 6});
(%o15)                               true
(%i16) some (atom, {1, 2, sin(3), 4, 5 + y, 6});
(%o16)                               true

some applied to two lists. The predicate is a function of two arguments.

(%i17) some ("=", [a, b, c], [a, b, c]);
(%o17)                               true
(%i18) some ("#", [a, b, c], [a, b, c]);
(%o18)                               false

Return values of the predicate f which evaluate to something other than true or false are governed by the global flag prederror.

(%i19) prederror : false;
(%o19)                               false
(%i20) map (lambda ([a, b], is (a < b)), [x, y, z], [x^2, y^2, z^2]);
(%o20)                    [unknown, unknown, unknown]
(%i21) some ("<", [x, y, z], [x^2, y^2, z^2]);
(%o21)                              unknown
(%i22) some ("<", [x, y, z], [x^2, y^2, z + 1]);
(%o22)                               true
(%i23) prederror : true;
(%o23)                               true
(%i24) some ("<", [x, y, z], [x^2, y^2, z^2]);
(%o24)                               false
(%i25) some ("<", [x, y, z], [x^2, y^2, z + 1]);
(%o25)                               true

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: