Matching Metrics of Gravitational Collapse in Weinberg's Gravitation and Cosmology In chapter 11, section 9 of Weinberg's Gravitation and Cosmology, the metric of a collapsing pressureless star of uniform density $\rho(t)$ is derived. In comoving coordinates, it essentially looks like an FLRW metric with positive spatial curvature:
$$
ds^2 =  -dt^2 + a^2(t)\left(\frac{dr^2}{1-kr^2} + r^2\, d\Omega^2\right),
$$
where $k = \frac{8\pi G}{3}\rho(0)$. The scale factor $a(t)$ obeys the differential equation
$$
\dot{a}(t) = -\sqrt{k\left(\frac{1-a}{a}\right)},
$$
and we choose the initial conditions $a(0)= 1$ and $\dot{a}(0) = 0$. (I've changed Weinberg's notation to a more normal one.) We also have the usual $\rho(t) = \rho(0) a(t)^{-3}$. The solution to this differential equation is a cycloid, which has no closed form solution, but a parametric solution is
$$
t = \frac{\psi + \sin\psi}{2\sqrt{k}}, \quad
a = \frac{1}{2}\left(1+\cos\psi\right),
$$
where $\psi$ runs from 0 to $\pi$.
Outside the star, of course, the metric is the Schwarzschild metric, which in Schwarzschild coordinates $(T,R)$ is
$$
ds^2 = -\left(1-\frac{r_S}{R}\right) \, dT^2 
+ \left(1-\frac{r_S}{R}\right)^{-1} \, dR^2
+ R^2 d\Omega^2,
$$
with $r_S = 2GM$. In order to complete the solution, the interior metric must be converted into coordinates that match the exterior coordinates at the boundary of the star. Matching the angular pieces of the metrics quickly yields
$$
R(r,t) = r a(t).
$$
Weinberg then says ``In order to define a standard time coordinate such that $ds^2$ does not contain a cross-term $dT \, dR$, we employ the `integrating factor' technique described in Section 11.7, which gives''
$$
T(r,t) = \sqrt{\frac{1-kr_0^2}{k}}
\int_{S(r,t)}^1 \frac{dx}{1-kr_0^2/x} \sqrt{\frac{x}{1-x}},
$$
where
$$
S(r,t) = 1 - \sqrt{\frac{1-kr^2}{1-kr_0^2}}
\left(1-a(t)\right).
$$
$r_0$ is an arbitrary constant, but we choose it to the be radius of the star in comoving coordinates. I don't understand how this expression for $T(t,r)$ was derived. Section 11.7 is not particularly helpful, since as far as I can tell, it only shows how to take a generic metric with a $dt \, dr$ term and remove this cross term by completing the square.
Weinberg then claims that the interior metric in these coordinates is
$$
ds^2 = -B(R,T) \, dT^2 + A(R,T) dR^2 
+ R^2 \, d\Omega^2,
$$
with
$$
B = \frac{a(t)}{S(r,t)}
\sqrt{\frac{1-kr^2}{1-kr_0^2}} 
\frac{\left(1-kr_0^2/S(r,t)\right)^2}{1-kr^2/a(t)},
\quad
A = \left(1-\frac{kr^2}{a(t)}\right)^{-1},
$$
with it being understood that $S$ is a function of $T$ defined by the previous equation, and that $r$ and $a(t)$ are functions of $R$ and $S$, or $R$ and $T$, defined by solving the above equations.
Again, it is unclear to me how this was derived. I can successfully check that this metric transforms back into the original FLRW form when the transformation from $T$ and $R$ to $t $ and $r$ above is applied, but without the reverse transformation I seem to be unable to derive this form of the metric myself.
Any help is appreciated.
 A: We have $R(r,t)=a(t)r$, $\therefore$ $\mathrm{d}s^2$ in outer region becomes $$-\bigg(1-\frac{2GM}{ar}\bigg)\mathrm{d}T^2+\bigg(1-\frac{2GM}{ar}\bigg)^{-1}(\dot{a}r\hspace{2pt}\mathrm{d}t+a\mathrm{d}r)^2$$
where dot over a means differentiating with respect to $t$. Now substituting T as a function of $(t,r)$ substituting it in above equation collecting the like terms together we'll get something like $$(...)\hspace{2pt}\mathrm{d}t^2+(...)\hspace{2pt}\mathrm{d}r^2+(...)\hspace{2pt}\mathrm{d}t\hspace{1pt}\mathrm{d}r$$
Now you can go ahead and use the integrating factor technique but algebra will be messy since you have to figure out two functions $T(t,r)$ and $\eta(t,r)$ and all are related by PDE.
There is a reason why we were easily able to deduce the relation $R=a(t)r$ by comparing last term of the line elements? It's because when we do the above calculation in thin shell formalism the condition $[h_{ab}]=0$ doesn't affect/change the $d\Omega^2$ term.
If you're confused by what I just said I'm simply referring you to another way to do the above problem which is called thin shell formalism. You can find this method here. This one needs only half a page calculation.
There is another way to doing the problem which is how Oppenheimer found the solution.
