Let $A\in \mathcal{M}_{m\times m}(\mathbb R)$ , $det(A)=1$ , $A$ is positively definite. Which matrices $P$ satisfy the equation
$$P^TAP=A$$
In fact I am interested in sequences of traces $tr P^n$ of the iterations of such solutions.

In dimension $2$ one can show that 
$$P^n=\left(
        \begin{array}{cc}
          \cos n\phi& -\beta \sin n\phi \\
         \alpha \sin n\phi  & \cos n\phi\\
             \end{array}\right)$$
for some $\phi, \alpha, \beta$ satisfying$\alpha\beta=1$
hence $tr P^n= 2\cos n\phi$.