The Group of symmetries of the square (D4) has an order of 8. There are 2 classes in the group (correct me if Im wrong). These classes are: One class made of rotations in the plane of the square, of $0$ (identity), $\pi/2$, $\pi$ and $3 \pi /2$. Also 4 rotations with axis inside the plane: two across the diagonals of the square and two perpendicular to the sides by the middle.
Using the "dimensionality theorem", which says that the order is equal to the sum of the square of the dimensionalities of the possible representations, I get $2^2+2^2=8$, meaning that there are 2 representations of order 2.
One of this representations has the first class represented with these matrices:
$\begin{bmatrix} 1 & 0 \\0 & 1 \end{bmatrix}$, $\begin{bmatrix} 0 & -1 \\1 & 0 \end{bmatrix}$, $\begin{bmatrix} -1 & 0 \\0 & -1 \end{bmatrix}$, $\begin{bmatrix} 0 & -1 \\1 & 0 \end{bmatrix}$
And the second class represented as:
$\begin{bmatrix} -1 & 0 \\0 & 1 \end{bmatrix}$, $\begin{bmatrix} 1 & 0 \\0 & -1 \end{bmatrix}$, $\begin{bmatrix} 0 & 1 \\1 & 0 \end{bmatrix}$, $\begin{bmatrix} 0 & -1 \\-1 & 0 \end{bmatrix}$
But my problem is that the traces of a same class should be the same (correct me again if im wrong), and the first class has 1 matrix of $Tr=2$, 1 of $Tr=-2$ and two of $Tr=0$. The second class has every matrix with $Tr=0$.
I immediately thought that the classes I choose were wrong, and that I have 3 classes. But it doesn't have sense for me because, if I have 3 classes I cant fulfill the dimensionality theorem, as there isn't any sum of square integers which is equal to 8.
What I am missing? There are 2 or 3 classes? Im choosing wrong the members of the classes?
You've got the conjugacy classes wrong. There are actually $5$.
Namely $\{e\}, \{(13)(24)\} ,\{14)(23),(12)(34)\},\{(13),(24)\}$and $\{(1234),(4321)\}$. These are, identity, $180^0$ rotation, edge reflections, vertex reflections and $90^0$ rotations, respectively...
I leave it to you to find the matrices. The traces within the classes are indeed the same.