First time here? Check out the FAQ!

Ask Your Question
1

How to generate map in sage

asked 0 years ago

babyturtle gravatar image

updated 0 years ago

Max Alekseyev gravatar image

As you can see, I'm trying to repeatedly take the map x,y,z to xyx^-1, xzx^-1, (zy+1)x^-1 repeatedly. I'm getting a lot of errors though. Does anyone know how to fix my code? I think It might have something to do with the multiple variables calling the symbol 'x' but idk how else to not cause issues when I'm doing the three different parts of my map (like if I change X then the middle part has the wrong iteration of x).

That was my old question and someone gave me a response and I updated my code. I don't get why my new code doesn't work. If anyone knows how to fix it, or tell me another way to this please let me know!

A = algebras.Free(QQ, list('XYZ'), degrees=(1,1,1))
Ahat = A.completion()
A.inject_variables()

# Define elements x, y, and z
a = Ahat(X)
b = Ahat(Y)
c = Ahat(Z)

# Define the mapping function
def mymap(vx, vy, vz):
    return vx * vy * ~vx, vx * vz * ~vx, (vz * vy + 1) * ~vx

# Apply the mapping function with the generators X, Y, and Z
print(mymap(a, b, c))
Preview: (hide)

Comments

Link to previous question: https://ask.sagemath.org/question/76649

Max Alekseyev gravatar imageMax Alekseyev ( 0 years ago )

The given code breaks already at Ahat = A.completion() with the error: AttributeError: 'FreeAlgebra_generic_with_category' object has no attribute 'completion'

Max Alekseyev gravatar imageMax Alekseyev ( 0 years ago )
1

The completion method does not introduce inverses of the generators, but (I expect) only inverses of elements with nonzero constant term: elements which can be inverted using power series manipulations.

John Palmieri gravatar imageJohn Palmieri ( 0 years ago )

1 Answer

Sort by » oldest newest most voted
0

answered 0 years ago

Max Alekseyev gravatar image

updated 0 years ago

Here is a code based on my answer to your earlier question:

F.<x,y,z> = FreeGroup()
A = F.algebra(QQ)
X = A(x)
Y = A(y)
Z = A(z)

# invert given element q
def myinv(q):
    L = [(t,c) for t,c in q]
    if len(L)!=1:
        raise ValueError(f'Unable to invert {q}')
    return A(L[0][0]^(-1)) / L[0][1]

# Define the mapping function
def mymap(vx, vy, vz):
    return (vx * vy * myinv(vx), vx * vz * myinv(vx), (vz * vy + 1) * myinv(vx))

t = (X,Y,Z)
for i in range(6):
    t = mymap(*t)
    print(f'Iteration {i+1}: {t}')

It produces 3 iterations of mymap:

Iteration 1: (x*y*x^-1, x*z*x^-1, x^-1 + z*y*x^-1)
Iteration 2: (x*y*z*y^-1*x^-1, x*y*x^-1*y^-1*x^-1 + x*y*x^-1*z*x^-1, x*y^-1*x^-1 + z*y^-1*x^-1 + z*y*z*y^-1*x^-1)
Iteration 3: (x*y*z*x^-1*z^-1*y^-1*x^-1 + x*y*z*x^-1*z*y*z^-1*y^-1*x^-1, x*y*z*(y^-1*x^-1)^2 + x*y*z*y^-1*x^-1*z*x^-1 + x*y*z*y^-1*z^-1*y^-1*x^-1, z^-1*y^-1*x^-1 + x*y*z^-1*y^-1*x^-1 + z*x^-1*z^-1*y^-1*x^-1 + z*y*z^-1*y^-1*x^-1 + z*x^-1*z*y*z^-1*y^-1*x^-1 + z*y*z*x^-1*z^-1*y^-1*x^-1 + z*y*z*x^-1*z*y*z^-1*y^-1*x^-1)

Then, however, it fails with the error:

ValueError: Unable to invert x*y*z*x^-1*z^-1*y^-1*x^-1 + x*y*z*x^-1*z*y*z^-1*y^-1*x^-1

and it is what it is - I do not know how to invert x*y*z*x^-1*z^-1*y^-1*x^-1 + x*y*z*x^-1*z*y*z^-1*y^-1*x^-1.

Preview: (hide)
link

Comments

That equals x*y*z*xinv*(1 + z*y)*zinv*yinv*xinv and the inverse of 1 + z*y is 1 - z*y + (z*y)^2 - (z*y)^3 + (z*y)^4 + ...

rburing gravatar imagerburing ( 0 years ago )

I'm not sure if using power series was original intention of the OP.

Max Alekseyev gravatar imageMax Alekseyev ( 0 years ago )

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 0 years ago

Seen: 531 times

Last updated: May 01 '24