How to solve a matrix equation of type $XAX=B$ This is the question:

Find out the matrix $X\in M_2(\mathbb R)$, so that 
  $X*A*X=B$, where $A,B \in M_2(\mathbb R)$ and $A=(a_{ij}), a_{11}=1, a_{12}=2, a_{21}=1, a_{22}=5$ and $B=(b_{ij}), b_{11}=2, b_{12}=-2, b_{21}=-2, b_{22}=2$.
  How can I solve it and what is\are the solution\s?

Consider the following two matrices
$$
\begin{array}{cc}
A:=
\left(
\begin{array}{cc}
1&2 \\
1& 5
\end{array}
\right), &
B:=
\left(
\begin{array}{cc}
2&-2 \\
-2& 2
\end{array}
\right)
\end{array}
$$
My question: How to obtain the matrix $X\in M_2(\mathbb R)$ from the next  matrix equation 
$$
X\,A\,X:=B \tag{1}
$$
My try: I assumed that $X:=\left(
\begin{array}{cc}
x_1&x_2 \\
x_3& x_4
\end{array}
\right)$ where $x_i$'s are variables, 
 but could not obtain the values of $x_i$, $1\leq i \leq 4$ from $(1)$.
Thanks for any suggestions. 

Taking the determinant of both sides of relationship $XAX=B$, we find 
$\det(X)^2 \det(A)=\det(B)=0$. As $\det(A) \neq 0$. We must have $\det(X)=0$ which is equivalent to the fact that the 2 columns of $X$ are proportional.
We can assume thus, WLOG, that $X$ can be written :
$$X=\left(
\begin{array}{rr}
a&ca \\
b&cb
\end{array}
\right)$$
Expanding the following condition:
$$
\left(
\begin{array}{rr}
a&ca \\
b&cb
\end{array}
\right)
\left(
\begin{array}{rr}
1&2 \\
1& 5
\end{array}
\right)
\left(
\begin{array}{rr}
a&ca \\
b&cb
\end{array}
\right)
=
\left(
\begin{array}{rr}
2&-2 \\
-2&2
\end{array}
\right)$$
gives rise to the following system of equations:
$$\begin{cases}ab(2 + 5c) + a^2(1 + c)=2\\
 a^2c(1 + c) + abc(2+ 5c)=-2\\
 b^2(2 + 5c) + ab(1 + c)=-2\\
 abc(1 + c) + b^2c(2 + 5c)=2\end{cases} \ \iff \ \begin{cases}a S =2 \\
 acS=-2\\
 bS=-2\\
 bcS=2\end{cases}$$
by setting 
$$\tag{1}S:=b(2 + 5c) + a^2(1 + c).$$
Out of these 4 compatible equations, taking into account the fact that $S \neq 0$, it is easy to see that necessarily $c=-1$, $b=-a$ , and thus, plugging these values in (1), we get $\frac{2}{a}=-a(2-5)$, thus 
$$a=\sqrt{\tfrac{2}{3}} \ \ \text{ or} \ \  a=-\sqrt{\tfrac{2}{3}}.$$
It suffices now to check that, with one of these values of $a$: 
$$
\left(
\begin{array}{rr}
a&-a \\
-a&a
\end{array}
\right)
\left(
\begin{array}{rr}
1&2 \\
1& 5
\end{array}
\right)
\left(
\begin{array}{rr}
a&-a \\
-a&a
\end{array}
\right)
=
\left(
\begin{array}{rr}
3a^2&-3a^2 \\
-3a^2& 3a^2
\end{array}
\right)$$
indeed coincides with matrix $B$, giving two solutions for $X$.
