Ask Your Question

Revision history [back]

Looking at the source code, the problem seems to be that the subs method requires to be able to count the number of generators of the parent of poly (i.e. Symmetric Functions over Rational Field in the elementary basis), which is infinite.

Since this parent does not provide any ngens method (that is supposed to count the number of generators), the subs method just returns poly unmodified.

So, you have to write your own. I am not completely sure, but i can suggest the following approach: you can have a look at the map_item method of poly. Since you basically want to replace e[1,1] by e[0] (=1), you can do:

sage: def substitution(item, coeff):
....:    if item == Partition([1, 1]):
....:        return (Partition([0]), coeff)
....:    else:
....:        return (item, coeff)

sage: poly.map_item(substitution)
e[] - 2*e[2]

Looking at the source code, the problem seems to be that the subs method requires to be able to count the number of generators of the parent of poly (i.e. Symmetric Functions over Rational Field in the elementary basis), which is infinite.

Since this parent does not provide any ngens method (that is supposed to count the number of generators), the subs method just returns poly unmodified.

So, you have to write your own. I am not completely sure, but i can suggest the following approach: you can have a look at the map_item method of poly. Since you basically want to replace e[1,1] e[1,1] by e[0] e[0] (=1), you can do:

sage: def substitution(item, coeff):
....:    if item == Partition([1, 1]):
....:        return (Partition([0]), coeff)
....:    else:
....:        return (item, coeff)

sage: poly.map_item(substitution)
e[] - 2*e[2]