Macaulay2 » Documentation
Packages » NumericalSemigroups :: sums
next | previous | forward | backward | up | index | toc

sums -- sum of two sequences

Synopsis

Description

sums(L1,L2) returns a sorted list of the unique sums of nonzero elements of L1 with L2; sums(n, L1) returns the sorted list of unique sums of n nonzero elements of L1.

i1 : L1 = {2,3}

o1 = {2, 3}

o1 : List
i2 : L2 = {4,5}

o2 = {4, 5}

o2 : List
i3 : sums(L1, L2)

o3 = {6, 7, 8}

o3 : List
i4 : sums(1, L1) == L1

o4 = true
i5 : sums(L1, L1)

o5 = {4, 5, 6}

o5 : List
i6 : sums(2,L1)

o6 = {4, 5, 6}

o6 : List

Of course the sequence of arbitrary sums of elements including 0 is essentially semigroup L. To get just the sums of n elements, one could write:

i7 : n = 3

o7 = 3
i8 : {0}|sort unique flatten (for i from 1 to n list sums(i,L1))

o8 = {0, 2, 3, 4, 5, 6, 7, 8, 9}

o8 : List

Ways to use sums:

For the programmer

The object sums is a method function.