Ask Your Question

Revision history [back]

It is simply

sage: prod(S)
6

You cannot index S because it is not ordered; you would have to convert to a list first e.g. by list(S).

The elements of S are of type Integer and so prod will use the product of integers.

When you add to S a complex number element like 1+I which is of type Expression, the Integers will be coerced to Expressions, the product will work in the way you expect and the result will be an Expression.

It is simply

sage: prod(S)
6

You cannot index S because it is not ordered; you would have to convert to a list first e.g. by s = list(S).

The elements of S are of type Integer and so prod will use the product of integers.

When you add to S a complex number element like 1+I which is of type Expression, the Integers will be coerced to Expressions, the product will work in the way you expect and the result will be an Expression.