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

asked 2025-01-07 19:21:30 +0200

levav gravatar image

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.

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by Max Alekseyev
close date 2025-01-17 17:04:09.493117

Comments

1

in the completion, maybe you first need to extract the homogeneous component using f[d]

FrédéricC gravatar imageFrédéricC ( 2025-01-07 19:32:43 +0200 )edit

That works like a charm! Thank you.

levav gravatar imagelevav ( 2025-01-07 19:46:06 +0200 )edit