In [44]:
%run sympowers.py
This provides macros for symmetric tensor powers.

SymPower(A,N): a matrix A and degree N
SymmTraces(A,n): matrix A and order of the series
PowerTraces(A,n): matrix A and order of the series
GAM(A,N): Lie map for matrix A in degree N
In [45]:
A=Matrix(2,2,[1,2,x,y])
A
Out[45]:
$$\left[\begin{matrix}1 & 2\\x & y\end{matrix}\right]$$
In [46]:
for n in range(1,6):
    B=SymPower(A,n)
    display(B,trace(B),expand(trace(A**n)))
    
    
$$\left[\begin{matrix}1 & 2\\x & y\end{matrix}\right]$$
$$y + 1$$
$$y + 1$$
$$\left[\begin{matrix}1 & 4 & 4\\x & 2 x + y & 2 y\\x^{2} & 2 x y & y^{2}\end{matrix}\right]$$
$$2 x + y^{2} + y + 1$$
$$4 x + y^{2} + 1$$
$$\left[\begin{matrix}1 & 6 & 12 & 8\\x & 4 x + y & 4 x + 4 y & 4 y\\x^{2} & 2 x^{2} + 2 x y & 4 x y + y^{2} & 2 y^{2}\\x^{3} & 3 x^{2} y & 3 x y^{2} & y^{3}\end{matrix}\right]$$
$$4 x y + 4 x + y^{3} + y^{2} + y + 1$$
$$6 x y + 6 x + y^{3} + 1$$
$$\left[\begin{matrix}1 & 8 & 24 & 32 & 16\\x & 6 x + y & 12 x + 6 y & 8 x + 12 y & 8 y\\x^{2} & 4 x^{2} + 2 x y & 4 x^{2} + 8 x y + y^{2} & 8 x y + 4 y^{2} & 4 y^{2}\\x^{3} & 2 x^{3} + 3 x^{2} y & 6 x^{2} y + 3 x y^{2} & 6 x y^{2} + y^{3} & 2 y^{3}\\x^{4} & 4 x^{3} y & 6 x^{2} y^{2} & 4 x y^{3} & y^{4}\end{matrix}\right]$$
$$4 x^{2} + 6 x y^{2} + 8 x y + 6 x + y^{4} + y^{3} + y^{2} + y + 1$$
$$8 x^{2} + 8 x y^{2} + 8 x y + 8 x + y^{4} + 1$$
$$\left[\begin{matrix}1 & 10 & 40 & 80 & 80 & 32\\x & 8 x + y & 24 x + 8 y & 32 x + 24 y & 16 x + 32 y & 16 y\\x^{2} & 6 x^{2} + 2 x y & 12 x^{2} + 12 x y + y^{2} & 8 x^{2} + 24 x y + 6 y^{2} & 16 x y + 12 y^{2} & 8 y^{2}\\x^{3} & 4 x^{3} + 3 x^{2} y & 4 x^{3} + 12 x^{2} y + 3 x y^{2} & 12 x^{2} y + 12 x y^{2} + y^{3} & 12 x y^{2} + 4 y^{3} & 4 y^{3}\\x^{4} & 2 x^{4} + 4 x^{3} y & 8 x^{3} y + 6 x^{2} y^{2} & 12 x^{2} y^{2} + 4 x y^{3} & 8 x y^{3} + y^{4} & 2 y^{4}\\x^{5} & 5 x^{4} y & 10 x^{3} y^{2} & 10 x^{2} y^{3} & 5 x y^{4} & y^{5}\end{matrix}\right]$$
$$12 x^{2} y + 12 x^{2} + 8 x y^{3} + 12 x y^{2} + 12 x y + 8 x + y^{5} + y^{4} + y^{3} + y^{2} + y + 1$$
$$20 x^{2} y + 20 x^{2} + 10 x y^{3} + 10 x y^{2} + 10 x y + 10 x + y^{5} + 1$$
In [47]:
st=SymmTraces(A,6);pt=PowerTraces(A,6)

for i in range(6):
    display([st[i],pt[i]])
    
$$\left [ 1, \quad 2\right ]$$
$$\left [ y + 1, \quad y + 1\right ]$$
$$\left [ 2 x + y^{2} + y + 1, \quad 4 x + y^{2} + 1\right ]$$
$$\left [ 4 x y + 4 x + y^{3} + y^{2} + y + 1, \quad 6 x y + 6 x + y^{3} + 1\right ]$$
$$\left [ 4 x^{2} + 6 x y^{2} + 8 x y + 6 x + y^{4} + y^{3} + y^{2} + y + 1, \quad 8 x^{2} + 8 x y^{2} + 8 x y + 8 x + y^{4} + 1\right ]$$
$$\left [ 12 x^{2} y + 12 x^{2} + 8 x y^{3} + 12 x y^{2} + 12 x y + 8 x + y^{5} + y^{4} + y^{3} + y^{2} + y + 1, \quad 20 x^{2} y + 20 x^{2} + 10 x y^{3} + 10 x y^{2} + 10 x y + 10 x + y^{5} + 1\right ]$$
In [49]:
B=Matrix(2,2,[y,x,2,1])
C=A*B-B*A
A,B,C
Out[49]:
$$\left ( \left[\begin{matrix}1 & 2\\x & y\end{matrix}\right], \quad \left[\begin{matrix}y & x\\2 & 1\end{matrix}\right], \quad \left[\begin{matrix}- x^{2} + 4 & - x y + x - 2 y + 2\\x y - x + 2 y - 2 & x^{2} - 4\end{matrix}\right]\right )$$
In [53]:
GAM(A,4),GAM(B,4),GAM(C,4),simplify(GAM(A,4)*GAM(B,4)-GAM(B,4)*GAM(A,4)-GAM(C,4))
Out[53]:
$$\left ( \left[\begin{matrix}4 & 8 & 0 & 0 & 0\\x & y + 3 & 6 & 0 & 0\\0 & 2 x & 2 y + 2 & 4 & 0\\0 & 0 & 3 x & 3 y + 1 & 2\\0 & 0 & 0 & 4 x & 4 y\end{matrix}\right], \quad \left[\begin{matrix}4 y & 4 x & 0 & 0 & 0\\2 & 3 y + 1 & 3 x & 0 & 0\\0 & 4 & 2 y + 2 & 2 x & 0\\0 & 0 & 6 & y + 3 & x\\0 & 0 & 0 & 8 & 4\end{matrix}\right], \quad \left[\begin{matrix}- 4 x^{2} + 16 & - 4 x y + 4 x - 8 y + 8 & 0 & 0 & 0\\x y - x + 2 y - 2 & - 2 x^{2} + 8 & - 3 x y + 3 x - 6 y + 6 & 0 & 0\\0 & 2 x y - 2 x + 4 y - 4 & 0 & - 2 x y + 2 x - 4 y + 4 & 0\\0 & 0 & 3 x y - 3 x + 6 y - 6 & 2 x^{2} - 8 & - x y + x - 2 y + 2\\0 & 0 & 0 & 4 x y - 4 x + 8 y - 8 & 4 x^{2} - 16\end{matrix}\right], \quad \left[\begin{matrix}0 & 0 & 0 & 0 & 0\\0 & 0 & 0 & 0 & 0\\0 & 0 & 0 & 0 & 0\\0 & 0 & 0 & 0 & 0\\0 & 0 & 0 & 0 & 0\end{matrix}\right]\right )$$
In [ ]: