# How to write a matrix in a different basis by using Mathematica

I have these two 4x4 matrix

Subscript[S, 1] = KroneckerProduct[PauliMatrix[1], IdentityMatrix[2]]
Subscript[S, 2] = KroneckerProduct[IdentityMatrix[2], PauliMatrix[2]]


Which are written in the Canonical basis ({{{1}, {0}, {0}, {0}};{{{0}, {1}, {0}, {0}}; {{{0}, {0}, {1}, {0}}; {{{0}, {0}, {0}, {1}})

I would like to write down these two matrices in the following basis:

G := {{0}, {0}, {0}, {1}}

S := (1/Sqrt[2]) {{0}, {1}, {1}, {0}}

A := (1/Sqrt[2]) {{0}, {1}, {-1}, {0}}

EE := {{1}, {0}, {0}, {0}}


Is there any way to do it in Mathematica?

Thanks in advance

• Crossposted here. Commented Jul 22, 2021 at 14:18

## 1 Answer

Should be

Subscript[S, 1] = KroneckerProduct[PauliMatrix[1], IdentityMatrix[2]]
Subscript[S, 2] = KroneckerProduct[IdentityMatrix[2], PauliMatrix[2]]
basis = {{0, 0, 0, 1}, (1/Sqrt[2]) {0, 1, 1, 0}, (1/Sqrt[2]) {0, 1, -1, 0}, {1, 0, 0, 0}};
Inverse[basis].Subscript[S, 1].Transpose[basis]
Inverse[basis].Subscript[S, 2].Transpose[basis]


{{0, 1/Sqrt[2], 1/Sqrt[2], 0}, {1/Sqrt[2], 0, 0, 1/Sqrt[2]}, {1/Sqrt[ 2], 0, 0, -(1/Sqrt[2])}, {0, 1/Sqrt[2], -(1/Sqrt[2]), 0}}

{{0, I/Sqrt[2], -(I/Sqrt[2]), 0}, {-(I/Sqrt[2]), 0, 0, I/Sqrt[2]}, {I/ Sqrt[2], 0, 0, I/Sqrt[2]}, {0, -(I/Sqrt[2]), -(I/Sqrt[2]), 0}}

• I understood what you have done but when I reply it I do not get a matrix as the result. Instead, I get only the full expression of the products. Commented Jul 21, 2021 at 23:31
• Of course, you have to define Subscript[S, 1]  and Subscript[S, 2], first. Commented Jul 22, 2021 at 12:29