Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Getting a specific Coefficient of a non-commuting formal power series in multiple variables

This is a continuation of question1 and question2, though reading them is not needed to understand this one.

Here is the code in which I tried doing what was specified in the question:

n = 2
R = FreeAlgebra(ZZ, 'X', n, degrees = [1]*n)
RR = R.completion()
RM = R.monoid()

R_gens = R.gens()
RR_gens = tuple(RR(x) for x in R.gens())
RM_gens = RM.gens()

print(f"{R_gens=}")
print(f"{RR_gens=}")
print(f"{RM_gens=}")

r = R_gens[0]
print(f"{r=}")
print(f"{r.coefficient(RM_gens[0])=}")
print(f"{r.coefficient(RM_gens[1])=}")

rr = RR_gens[0]
print(f"{rr=}")
# print(f"{rr.coefficient(RM_gens[0])}")
# print(f"{rr.coefficient(RR_gens[0])}")
print(f"{rr.coefficient(R_gens[0])}")

The last 3 prints are different methods in which I try doing this. The first Throws:

TypeError: unsupported operand parent(s) for >=: 'Free monoid on 2 generators (X0, X1)' and 'Integer Ring'

The second Throws:

TypeError: tuple indices must be integers or slices, not LazyCompletionGradedAlgebra_with_category.element_class

The third doesn't throw an error, but returns the integer 0.

I've tried varying the formal power series in many ways, and the monomial for which I request the coefficient without success, the results are the same for the above 3 methods.

FrédéricC, thank you for all the help so far, and do let me know if there are things I can/should do to improve future questions and/or give back to the community.