Ask Your Question
1

How to generate map in sage

asked 2024-04-30 00:58:00 +0200

babyturtle gravatar image

updated 2024-04-30 03:13:04 +0200

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))
edit retag flag offensive close merge delete

Comments

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

Max Alekseyev gravatar imageMax Alekseyev ( 2024-04-30 05:19:59 +0200 )edit

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 ( 2024-04-30 18:06:36 +0200 )edit
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 ( 2024-04-30 20:56:20 +0200 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2024-05-01 02:51:56 +0200

Max Alekseyev gravatar image

updated 2024-05-01 04:42:42 +0200

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.

edit flag offensive delete link more

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 ( 2024-05-01 09:24:51 +0200 )edit

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

Max Alekseyev gravatar imageMax Alekseyev ( 2024-05-01 13:08:10 +0200 )edit

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: 2024-04-30 00:58:00 +0200

Seen: 222 times

Last updated: May 01