<s>[INST] Help with algebra, rearrange equations I have:

$$
r=\frac{1-x^2-y^2}{(1-x)^2+y^2} \tag 1
$$
  And want to write $(1)$ as:
  $$
\Big (x-\frac{r}{1+r}\Big )^2+y^2=\Big (\frac{1}{1+r}\Big )^2 \tag 2
$$

First method, starting from $(1)$:
$$
r=\frac{1-x^2-y^2}{x^2-2x+1+y^2}\iff
$$
$$
r(x^2-2x+1+y^2)=1-x^2-y^2 \iff
$$
$$
rx^2-r2x+r+ry^2=1-x^2-y^2 \iff
$$
$$
rx^2+x^2-r2x+r+ry^2+y^2=1 \iff
$$
$$
x^2(r+1)-r2x+r+y^2(r+1)=1 \iff
$$
$$
x^2-x\frac{2r}{r+1}+\frac{r}{r+1}+y^2=\frac{1}{r+1} \tag 3
$$
Completing the square of $x^2-x\frac{2r}{r+1}$:
$$
x^2-x\frac{2r}{r+1}+\Big (\frac{r}{1+r} \Big )^2-\Big (\frac{r}{1+r} \Big )^2=\Big (x-\frac{r}{1+r}\Big )^2-\Big (\frac{r}{1+r} \Big )^2
$$
Inserting in $(3)$ gives:
$$
\Big (x-\frac{r}{1+r}\Big )^2-\Big (\frac{r}{1+r} \Big )^2+\frac{r}{r+1}+y^2=\frac{1}{r+1} \tag 4
$$
I'm stuck here, what is next?
Second method, starting from $(2)$:
$$
\Big (x-\frac{r}{1+r}\Big )^2+y^2=\Big (\frac{1}{1+r}\Big )^2 \iff
$$
$$
\Big (\frac{x(r+1)-r}{1+r}\Big )^2+y^2=\Big (\frac{1}{1+r}\Big )^2 \iff
$$
$$
(x(r+1)-r)^2+y^2(1+r)^2=1 \tag 5
$$
Expand $(x(r+1)-r)^2$: 
$$
(x(r+1)-r)^2=x^2(1+r)^2-x2r(1+r)+r^2 
$$ 
Inserting in $(5)$ gives:
$$
x^2(1+r)^2-x2r(1+r)+r^2+y^2(1+r)^2=1 \iff
$$
$$
x^2(1+2r+r^2)-2rx-2xr^2+r^2+y^2(1+2r+r^2)=1\iff
$$
$$
x^2+2rx^2+r^2x^2-2rx-2xr^2+r^2+y^2+2ry^2+r^2y^2=1\iff
$$
Collect $r^2$ and $r$:
$$
r^2(x^2-2x+1+y^2)+r(2x^2-2x+2y^2) = 1-x^2-y^2 \iff
$$
$$
r^2((x-1)^2+y^2)+r(2x(x-1)+2y^2) = 1-x^2-y^2 \tag 6
$$
I'm stuck here, I don't know how to go from $(6)$ to $(1)$. 
 [/INST] Don't forget to get a common denominator first, before you add or subtract fractions.
Starting from (4)
$$
\begin{align}
\Big(x-\frac{r}{1+r}\Big)^2-\Big(\frac{r}{1+r} \Big)^2+\frac{r}{r+1}+y^2&=\frac{1}{r+1}\tag 4\\
\Big(x-\frac{r}{1+r}\Big)^2+y^2&=\frac{1}{r+1} +\Big(\frac{r}{1+r} \Big)^2- \frac{r}{r+1}\\
&=\frac{r+1}{(r+1)^2} +\frac{r^2}{(r+1)^2}- \frac{r(r+1)}{(r+1)^2}\\
&=\frac{r+1+r^2-r^2-r}{(1+r)^2}\\
&=\frac{1}{(1+r)^2} = \Big(\frac{1}{r+1}\Big)^2\\
\end{align}
$$
</s>