Find matrix $P$ such that $P^{-1}AP=B$ 
Given $$A = \begin{bmatrix}
1 & 0 & 0 \\
0 & 2 & -3 \\
1 & 3 & 2 \end{bmatrix}$$ $$B= \begin{bmatrix}
1 & 0 & 0 \\
0 & 2 & -3 \\
0 & 3 & 2 \end{bmatrix}$$ find $P$ such that $P^{-1} A P = B$.

Firstly I said that $AP=PB$
Solved the 9 equations in 9 unknowns. and got that:
$$P= \left( \begin{array}{ccc}
-10x & 0 & 0 \\
3x & y & z \\
x & -z & y \end{array} \right)$$
Then I used computer to find $P^{-1}$ in terms of those unknowns and plugged it back in to 
$P^{-1}AP=B$
Compared the coefficients and i end up with 
$B= \left( \begin{array}{ccc}
1 & 0 & 0 \\
-z/10x & 2 & -3 \\
1-y/10x & 3 & 2 \end{array} \right) $
Set $x=1$, $y=10$, $z=0$ and indeed $P^{-1}AP=B$ 
The doubts I am having is the fact that P is not unique. I could set x,y,z to different numbers. 
Can anyone explain this? Thank you.
 A: The computation is correct, and we cannot expect that $P$ is unique in general. A somewhat extreme case is $A=B=0$, where any invertible $P$ will do.
A: Using SymPy:
>>> from sympy import *
>>> X = MatrixSymbol('X',3,3)
>>> A = Matrix([[ 1, 0, 0],
                [ 0, 2,-3],
                [ 1, 3, 2]])
>>> B = Matrix([[ 1, 0, 0],
                [ 0, 2,-3],
                [ 0, 3, 2]])
>>> simplify(Matrix(A*X - X*B))
Matrix([
[                            0,            -X[0, 1] - 3*X[0, 2],             3*X[0, 1] - X[0, 2]],
[          X[1, 0] - 3*X[2, 0],          -3*(X[1, 2] + X[2, 1]),           3*(X[1, 1] - X[2, 2])],
[X[0, 0] + 3*X[1, 0] + X[2, 0], X[0, 1] + 3*X[1, 1] - 3*X[2, 2], X[0, 2] + 3*X[1, 2] + 3*X[2, 1]]])

If $\rm A X - X B = O_3$, we have an underdetermined homogeneous system of $3^2 - 1$ linear equations in $3^2$ unknowns. Thus, we have at least $1$ degree of freedom. We vectorize the matrix equation
$$\left( \mathrm I_3 \otimes \mathrm A - \mathrm B^{\top} \otimes \mathrm I_3 \right) \mbox{vec} (\mathrm X) = 0_9$$
and let $\mathrm M := \mathrm I_3 \otimes \mathrm A - \mathrm B^{\top} \otimes \mathrm I_3$. Using SymPy:
>>> I3 = Identity(3)
>>> O3 = ZeroMatrix(3,3)
>>> M = BlockMatrix([[A - I3,       O3,       O3],
                     [    O3, A - 2*I3,    -3*I3], 
                     [    O3,     3*I3, A - 2*I3]])
>>> Matrix(M)
Matrix([
[0, 0,  0,  0, 0,  0,  0,  0,  0],
[0, 1, -3,  0, 0,  0,  0,  0,  0],
[1, 3,  1,  0, 0,  0,  0,  0,  0],
[0, 0,  0, -1, 0,  0, -3,  0,  0],
[0, 0,  0,  0, 0, -3,  0, -3,  0],
[0, 0,  0,  1, 3,  0,  0,  0, -3],
[0, 0,  0,  3, 0,  0, -1,  0,  0],
[0, 0,  0,  0, 3,  0,  0,  0, -3],
[0, 0,  0,  0, 0,  3,  1,  3,  0]])
>>> Matrix(M).rank()
6

Hence, we have $3^2 - 6 = 3$ degrees of freedom.
