## Documentation Center |

Multisets

This functionality does not run in MATLAB.

Dom::Multiset(<s1, s2, …>)

`Dom::Multiset` is the domain of multisets,
i.e., sets with possibly multiple identical elements.

A multiset is represented by a set of lists of the form [*s*, *m*],
where *s* is
an element of the multiset and *m* its
multiplicity.

Multisets can be returned by the system solver `solve`. For example,
the input `solve(x^3 - 4*x^2 + 5*x - 2, x, Multiple)` gives
all roots of the polynomial *x*^{3} -
4 *x*^{2} + 5 *x* -
2 in form of the multiset `{[1, 2], [2,
1]}`.

The standard set operations such as union, intersection and subtraction of sets have been extended to deal with multisets.

These operations can handle different types of sets, such as
sets of type `DOM_SET` and
multisets. One may, for example, compute the union of the multiset `{[a,
2], [b, 1]}` and the set `{c}`, which results
in the multiset `{[a, 2], [b, 1], [c, 1]}`.

The elements of the multiset are sorted at the time where the
multiset is created. The system function `sort` is used in order to guarantee that
exactly one representation exists for a multiset, independent of the
sequence in which the arguments appear.

`Dom::Multiset(s1, s2, ...)` creates the multiset
consisting of the elements `s1, s2, ...`

Multiple identical elements in `s1, s2`, ...
are collected. For example, the call `Dom::Multiset(a, b,
a, c)` creates a multiset with the elements `a, b,
c`. The element `a` has multiplicity two,
the other two elements `b` and `c` both
have multiplicity one.

The multiset {*a*, *a*, *b*} consists
of the two different elements *a* and *b*,
where *a* has
multiplicity two and *b* has
multiplicity one:

delete a, b, c: set1 := Dom::Multiset(a, a, b)

We create another multiset:

set2 := Dom::Multiset(a, c, c)

Standard set operations such as disjoint union, intersection
or subtraction are implemented for multisets and can be performed
using the standard set operators of MuPAD^{®}:

set1 union set2

set1 intersect set2

contains(set1, a), contains(set1, d)

Some system functions were overloaded for multisets, such as `expand`, `normal` or `split`.

If we apply `expand` to a multiset, for example,
we get an expression sequence of all elements of the multiset (appearing
in correspondence to their multiplicity):

delete a, b, c, d, e: set := Dom::Multiset(a, b, c, a, c, d, c, e, c)

expand(set)

If you want to convert a multiset into an ordinary set of the
domain type `DOM_SET`,
use `coerce`:

coerce(set, DOM_SET)

Note: The system function `coerce` uses the
methods `"convert"` and `"convert_to"` of
the domain `Dom::Multiset`.

Compare the last result with the return value of the function `expr`, when it is applied
for multisets:

expr(set)

The result is a set of the domain type `DOM_SET`,
consisting of lists of the domain type `DOM_LIST` with two entries,
an element of the multiset and the corresponding multiplicity of that
element.

"isFinite" | is |

"inhomog_intersect" | a table of the form |

"inhomog_union" | a table of the form |

Was this topic helpful?