union - Maple Programming Help

union

set union operator

intersect

set intersection operator

minus

set difference operator

subset

subset operator

Calling Sequence

 s1 union s2 $\mathrm{s1}\cup \mathrm{s2}$ s1 intersect s2 $\mathrm{s1}\cap \mathrm{s2}$ s1 minus s2 $\mathrm{s1}\setminus \mathrm{s2}$ s1 subset s2 $\mathrm{s1}\subseteq \mathrm{s2}$ union(s1, s2, s3,...) intersect(s1, s2, s3, ...) minus(s1,s2) subset(s1,s2)

Parameters

 s1, s2, s3, ... - sets or expressions

Description

 • The union, intersect, minus, and subset routines are used for the set union, intersection, difference, and subset operations.  The union and intersect routines are infix, associative, commutative, n-ary operators. The minus and subset routines are binary infix operators.
 For information on the order of precedence of these operators, see operator precedence.
 • If an argument is an expression, it must be possible for that object to evaluate to a set.  If any argument cannot be assigned a set, an error is returned.  For example, the union of $\left\{1,2,3\right\}$ and $4$ returns an error, while the union of $\left\{1,2,3\right\}$ and S returns unevaluated.
 • You can enter these commands using either the 1-D or 2-D calling sequences.  For example, {a,b} union {b,c} is equivalent to $\left\{a,b\right\}\cup \left\{b,c\right\}$.
 • When using the union(s1,s2) calling sequence in 1-D Math notation, you must enclose union in backquotes since it is a keyword: union(s1,s2). In 2-D Math notation, backquotes are not necessary.
 Note: The set operations are based on address tests.  If two set elements appear to be the same but have different addresses, the test fails.  This is illustrated by the final example.

 • The set operators are thread safe as of Maple 15.

Examples

 > $\left\{a,b\right\}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathbf{union}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\left\{b,c\right\}$
 $\left\{{a}{,}{b}{,}{c}\right\}$ (1)
 > $\left\{a,b\right\}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathbf{intersect}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\left\{b,c\right\}$
 $\left\{{b}\right\}$ (2)
 > $\left\{a,b\right\}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathbf{minus}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\left\{b,c\right\}$
 $\left\{{a}\right\}$ (3)
 > $a\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathbf{union}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}b\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathbf{union}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}a$
 ${a}{\cup }{b}$ (4)
 > $\left\{3,4\right\}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathbf{union}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}a\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathbf{union}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\left\{3,7\right\}$
 ${a}{\cup }\left\{{3}{,}{4}{,}{7}\right\}$ (5)
 > $\left\{3,4\right\}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathbf{union}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}a\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathbf{union}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\left\{3,7\right\}$
 ${a}{\cup }\left\{{3}{,}{4}{,}{7}\right\}$ (6)
 > $a\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathbf{intersect}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}b\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathbf{intersect}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}a$
 ${a}{\cap }{b}$ (7)
 > $\left\{3,4\right\}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathbf{intersect}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}a\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathbf{intersect}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\left\{3,7\right\}$
 ${a}{\cap }\left\{{3}\right\}$ (8)
 > $\mathrm{intersect}\left(\left\{3,4\right\},a,\left\{3,7\right\}\right)$
 ${a}{\cap }\left\{{3}\right\}$ (9)

minus and subset are binary operators.

 > $a\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathbf{minus}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}b\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathbf{minus}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}a$
 ${a}{\setminus }{b}{\setminus }{a}$ (10)
 > $\left\{a\right\}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathbf{minus}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\left\{b\right\}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathbf{minus}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\left\{a\right\}$
 ${\varnothing }$ (11)
 > $\left\{3,4\right\}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathbf{minus}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\left\{3,7\right\}$
 $\left\{{4}\right\}$ (12)
 > $\left\{a,b\right\}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathbf{subset}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\left\{a,b,c,d\right\}$
 ${\mathrm{true}}$ (13)
 > $\left\{a,b\right\}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathbf{subset}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\left\{a,c,d,e\right\}$
 ${\mathrm{false}}$ (14)
 > $a\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathbf{subset}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}b\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathbf{union}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}c$
 ${a}{\subseteq }{b}{\cup }{c}$ (15)

The order of precedence for set operators is: intersect, union and minus, then subset.

 > $\left\{1,2\right\}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathbf{subset}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\left\{1,3,7\right\}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathbf{union}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\left\{2,4\right\}$
 ${\mathrm{true}}$ (16)
 > $\left\{1,2\right\}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathbf{union}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\left\{1,2,3\right\}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathbf{intersect}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\left\{3,4,5\right\}$
 $\left\{{1}{,}{2}{,}{3}\right\}$ (17)
 > $\left(\left\{1,2\right\}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathbf{union}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\left\{1,2,3\right\}\right)\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathbf{intersect}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\left\{3,4,5\right\}$
 $\left\{{3}\right\}$ (18)

The set operations are based on address test. If two set elements appear to be the same but have different addresses, the test fails.

 > $A≔\left\{e↦\mathrm{type}\left(e,'\mathrm{integer}'\right)\right\}:$$B≔\left\{e↦\mathrm{type}\left(e,'\mathrm{integer}'\right)\right\}:$
 > $A\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathbf{subset}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}B$
 ${\mathrm{false}}$ (19)
 > $A\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathbf{intersect}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}B$
 ${\varnothing }$ (20)