Find equation for mass in gravity A satellite is moving in circular motion round a planet.
From the physics we know that
$$\Sigma F_r = ma_r = \frac{GMm}{r^2}$$
So I wanted to find the equation for $M$ knowing also that 
$$v = \omega r = \frac{2\pi r}{T}$$
and
$$a_r = \frac{v^2}{r}$$
Thus,
$$ma_r = \frac{GMm}{r^2}$$
$$a_r = \frac{GM}{r^2}$$
$$\frac{v^2}{r} = \frac{GM}{r^2}$$
$$\frac{\left(\frac{2\pi r}{T}\right)^2}{r} = \frac{GM}{r^2}$$
$$\frac{\frac{4\pi^2r^2}{T^2}}{r} = \frac{GM}{r^2}$$
$$\frac{4\pi^2r^3}{T^2} = \frac{GM}{r^2}$$
$$\frac{4\pi^2r^5}{T^2} = GM$$
$$\frac{4\pi^2r^5G}{T^2} = M$$
However, this is wrong! It should be:
$$M = \frac{4\pi^2r^3}{GT^2}$$
What was my mistake in Mathematics? Please don't migrate it to physics because my misunderstanding is on math.
Note: I would be very happy if you show my mistake, instead of showing me another way to get to the equation.
 A: $\frac{4\pi^2r^2}{T^2}/r=\frac{4\pi r}{T^2}$ and G should go down not up in numerator.
A: The mistake lies in these steps:

$$\frac{\frac{4\pi^2r^2}{T^2}}{r} = \frac{GM}{r^2}$$
  $$\frac{4\pi^2r^3}{T^2} = \frac{GM}{r^2}$$
  $$\frac{4\pi^2r^5}{T^2} = GM$$
  $$\frac{4\pi^2r^5G}{T^2} = M$$

Actually, it should have been:
$$\frac{\frac{4\pi^2r^2}{T^2}}{r} = \frac{GM}{r^2}$$
$$\frac{4\pi^2r}{T^2} = \frac{GM}{r^2}$$
$$\frac{4\pi^2r^3}{T^2} = GM$$
$$\frac{4\pi^2r^3}{GT^2} = M$$


*

*In the second step, the numerator will have $r$ and not $r^3$.

*In the last step, $G$ will be in the denominator.

A: When going from $\frac{4\pi^2r^2/T^2}{r}$ to $\frac{4\pi^2r^3}{T^2}$ you added an extra factor of $r^2$; you should have canceled out an $r$ from the numerator and denominator, giving you $\frac{4\pi^2r}{T^2}$. Then when going from $\frac{4\pi^2r^5}{T^2} = GM$ to $\frac{4\pi^2r^5G}{T^2} = M$, you needed to divide each side by $G$; $G$ should be in the denominator on the left-hand side, not the numerator.,
