I have the following equation: $$\left(\frac{\sqrt{\sigma^2_1+\sigma_2^2}\cdot a}{\sigma_1 \cdot \sigma_2} - \frac{\mu_1\sigma^2_2 + \mu_2\sigma^2_1}{\sigma_1\sigma_2\sqrt{\sigma^2_1+\sigma^2_2}}\right)^2$$
Because it's given to me, i know that this can be rewritten to: $$\frac{(\sigma^2_1+\sigma^2_2)}{\sigma^2_1\sigma^2_2} \left(a-\frac{\mu_1\sigma^2_2+\mu_2\sigma^2_1}{\sigma^2_1+\sigma^2_2}\right)^2$$
Is there a math rule behind the concept which allows to transform the first equation into the second without solving the binominal equation first and then rearrange it?
$\frac{\sqrt{\sigma^2_1+\sigma_2^2}\cdot a}{\sigma_1 \cdot \sigma_2} - \frac{\mu_1\sigma^2_2 + \mu_2\sigma^2_1}{\sigma_1\sigma_2\sqrt{\sigma^2_1+\sigma^2_2}} = \sqrt{\frac{(\sigma^2_1+\sigma^2_2)}{\sigma^2_1\sigma^2_2}} \left(a-\frac{\mu_1\sigma^2_2+\mu_2\sigma^2_2}{\sigma^2_1+\sigma^2_2}\right)$, and square both sides.