The union of M and N has ground set equal to the union of those of M and N, and independent sets given by pairwise unions of independent sets of M and N.



When the ground sets of M and N are disjoint, this is the direct sum of M and N. Beware of order when using == though:





Matroid union is an important operation in combinatorial optimization, and via duality, is related to the problem of matroid intersection.
With the operation of union, one can work with transversal matroids and gammoids. A matroid is transversal iff it is a union of rank 1 matroids; strict gammoids are precisely the duals of transversal matroids, and gammoids are restrictions of strict gammoids. In general the problem of determining if a given matroid is a gammoid is difficult.
A union of two uniform matroids is again uniform, but a union of two graphic matroids need not be binary:






One potential caveat: the ground set of M must not have repeated elements. If this is not the case, the user MUST rename elements of M so that they become distinct. Of course, this needs to be done for both M and N, and one should also keep track of which elements of M and N are meant to be the same after the renaming (otherwise the entire point of taking unions, as opposed to direct sums, is lost).
In the example below, M contains the vector {1,1} twice. Macaulay2 has no way of distinguishing the repeated vectors, so the second occurrence of {1,1} is relabelled to the symbol d (of course, if the symbol d also happened to be an element of N, then a different label would have to be chosen).










