Fraction-manipulation between a Gamma and Student-t I'm working on a course problem,

Suppose that $\textbf{x}=\{x_1,\dots,x_n\}$ and $\textbf{y}=\{y_1\dots,y_m\}$ are independent random samples from $\text{N}(x|\mu_x,1/\lambda)$ and $\text{N}(y|\mu_y,1/\lambda)$, respectively. Using the (improper) prior $$\pi(\mu_x,\mu_y,\lambda)=\lambda^{-1},$$ prove that $\mu_x$ and $\mu_y$ are not independent a posteriori and find $\text{Cov}[\mu_x,\mu_y|\textbf{x},\textbf{y}]$.

The given solution begins,

The likelihood can be written as $$\text{L}(\mu_x,\mu_y,\lambda|\textbf{x},\textbf{y})\propto\lambda^{\frac{n+m}{2}}\exp\left(-\lambda\left(\frac{n}{2}(s_x^2+(\bar{x}-\mu_x)^2)+\frac{m}{2}(s_y^2+(\bar{y}-\mu_y)^2)\right)\right)$$ thus the joint posterior is $$\pi(\mu_x,\mu_y,\lambda|\textbf{x},\textbf{y})\propto\lambda^{\frac{n+m}{2}-1}\exp\left(-\lambda\left(\frac{n}{2}(s_x^2+(\bar{x}-\mu_x)^2)+\frac{m}{2}(s_y^2+(\bar{y}-\mu_y)^2)\right)\right)$$ and the marginal for the means is $$\pi(\mu_x,\mu_y|\textbf{x},\textbf{y})\propto\left(1+\frac{1}{ns_x^2+ms_y^2}(n(\bar{x}-\mu_x)^2+m(\bar{y}-\mu_y)^2)\right)^{-\frac{n+m}{2}}.$$

I see we have \begin{align}\pi(\mu_x,\mu_y,\lambda|\textbf{x},\textbf{y})=\frac{\Gamma(a)}{b^a}\text{Ga}(\lambda|a,b),\text{ with } & a = \frac{n+m}{2}, \\ & b = \frac{n}{2}(s_x^2+(\bar{x}-\mu_x)^2)+\frac{m}{2}(s_y^2+(\bar{y}-\mu_y)^2),\end{align} but I can't follow the manipulation of fractions in \begin{align}b&=\frac{n}{2}(s_x^2+(\bar{x}-\mu_x)^2)+\frac{m}{2}(s_y^2+(\bar{y}-\mu_y)^2) \\ &=1+\frac{1}{ns_x^2+ms_y^2}(n(\bar{x}-\mu_x)^2)+(m(\bar{y}-\mu_y)^2)\end{align} between the last two steps. Would someone mind clarifying?

To find the marginal, you need to integrate out the $\lambda$ term in
$$\lambda^{\frac{n+m}{2}-1}\exp\left(-\lambda\left(\frac{n}{2}(s_x^2+(\bar{x}-\mu_x)^2)+\frac{m}{2}(s_y^2+(\bar{y}-\mu_y)^2)\right)\right).$$
To do this, let's simplify it by replacing that constant positive multiple of $\lambda$ by a single name, such as $z,$ and compute (since evidently $\lambda\gt 0$)

$$\int_0^\infty \lambda^{\frac{n+m}{2}-1}\exp\left(-\lambda z\right)\,\mathrm dz = z^{-\frac{n+m}{2}}\int_0^\infty (\lambda z)^{\frac{n+m}{2}}\exp\left(-\lambda z\right)\frac{\mathrm d(\lambda z)}{\lambda z} = \frac{z^{-\frac{n+m}{2}}}{\Gamma\left(\frac{n+m}{2}\right)}.$$

(This calculation shows up so often in statistics and mathematics that it's worth remembering.)
We need to identify the portion of this result that depends on $(\mu_x,\mu_y),$ but any multiplicative factors not involving these variables can be ignored.
Begin by ignoring the $1/\Gamma((n+m)/2)$ factor and focus on $z$ itself before raising it to the $-(n+m)/2$ power:
$$\begin{aligned}
z &= \frac{n}{2}(s_x^2+(\bar{x}-\mu_x)^2)+\frac{m}{2}(s_y^2+(\bar{y}-\mu_y)^2) \\
&= \frac{n}{2}s_x^2 + \frac{m}{n}s_y^2 + \frac{n}{2}(\bar{x}-\mu_x)^2 + \frac{m}{2}(\bar{y}-\mu_y)^2 \\
&= \left(\frac{n}{2}s_x^2 + \frac{m}{n}s_y^2\right)\left(1+\frac{1}{ns_x^2+ms_y^2}(n(\bar{x}-\mu_x)^2+m(\bar{y}-\mu_y)^2)\right).
\end{aligned}$$
This expresses $z$ in the form $z = (C)\,(f(\mu_x,\mu_y)).$ Its $-(n+m)/2$ power therefore has a constant factor of $C^{-(m+n)/2},$ which can be ignored.  Thus
$$z^{-\frac{n+m}{2}}\ \propto\ f(\mu_x,\mu_y)^{-(n+m)/2} = \left(1+\frac{1}{ns_x^2+ms_y^2}(n(\bar{x}-\mu_x)^2+m(\bar{y}-\mu_y)^2)\right)^{-(n+m)/2},$$
QED.
The motivation for this last move is, of course, to steer the expression towards something that looks like a Student-t density.
