# Revision history [back]

Jere is a way to get kernel of the corresponding linear system:

D = A.T*X - X.T*A
M = Matrix(ZZ,0,len(X.list()))
for d in D.list():
if d:
M = M.insert_row(0,[ZZ(d.coefficient(x)) for x in X.list()])
print( M.right_kernel().basis() )


Jere Here is a way to get kernel of the corresponding linear system:

D = A.T*X - X.T*A
M = Matrix(ZZ,0,len(X.list()))
for d in D.list():
if d:
M = M.insert_row(0,[ZZ(d.coefficient(x)) for x in X.list()])
print( M.right_kernel().basis() )


Here is a way to get kernel of the corresponding linear system:

D = A.T*X - X.T*A
M = Matrix(ZZ,0,len(X.list()))
Matrix([[ZZ(d.coefficient(x)) for x in X.list()] for d in D.list():
if d:
M = M.insert_row(0,[ZZ(d.coefficient(x)) for x in X.list()])
D.list()])
print( M.right_kernel().basis() )


Here is a way to get kernel of the corresponding linear system:

D = A.T*X - X.T*A
M = Matrix([[ZZ(d.coefficient(x)) for x in X.list()] for d in D.list()])
print( M.right_kernel().basis() )


ADDED. If in addition one also wants $AX^T-XA^T = 0$, then

D1 = A.T*X - X.T*A
D2 = A*X.T - X*A.T
M = Matrix([[ZZ(d.coefficient(x)) for x in X.list()] for d in D1.list()+D2.list()])
print( M.right_kernel().basis() )


Here is a way to get a basis of the kernel of the corresponding linear system:

D = A.T*X - X.T*A
M = Matrix([[ZZ(d.coefficient(x)) for x in X.list()] for d in D.list()])
print( M.right_kernel().basis() )


ADDED. If in addition one also wants $AX^T-XA^T = 0$, then

D1 = A.T*X - X.T*A
D2 = A*X.T - X*A.T
M = Matrix([[ZZ(d.coefficient(x)) for x in X.list()] for d in D1.list()+D2.list()])
print( M.right_kernel().basis() )


Here is a way to how we get a the basis of the kernel of the corresponding linear system:

D solutions to ${ A^TX = A.T*X - X.T*A M = Matrix([[ZZ(d.coefficient(x)) for x in X.list()] for d in D.list()]) print( M.right_kernel().basis() )  ADDED. If in addition one also wants$AX^T-XA^T = 0$, thenX^TA, AX^T=XA^T }$:

D1 = A.T*X - X.T*A
D2 = A*X.T - X*A.T
M V = Matrix([[ZZ(d.coefficient(x)) [x for x in X.list()] X.list() if x]   # variables
M = Matrix([[d.coefficient(x) for x in V] for d in D1.list()+D2.list()])
print( M.right_kernel().basis() B = [X.subs(zip(V,b)) for b in M.right_kernel().basis()]
assert all( A.T*x == x.T*A and A*x.T == x*A.T for x in B )
print(B)


Here is how we get the basis of the solutions to ${$\{ A^TX = X^TA, AX^T=XA^T }$:\}$:

D1 = A.T*X - X.T*A
D2 = A*X.T - X*A.T
V = [x for x in X.list() if x]   # variables
M = Matrix([[d.coefficient(x) for x in V] for d in D1.list()+D2.list()])
B = [X.subs(zip(V,b)) for b in M.right_kernel().basis()]
assert all( A.T*x == x.T*A and A*x.T == x*A.T for x in B )
print(B)