In the context of the likelihood ratio test, I was told to use the following formula (1):
$$ \sum^n_{i=1}(X_i-\mu_0)^2=\sum^n_{i=1}(X_i-\bar{X})^2 + n(\bar{X}-{\mu}_0)^2 \qquad(1) $$
in order to derive the formula (2) as follows:
$$ \begin{aligned} \log\Lambda & = -\frac{1}{2{\sigma}^2}\left(\sum^n_{i=1}(X_i-\mu_0)^2 - \sum^n_{i=1}(X_i-\bar{X})^2\right) & \quad &\\ & = -\frac{1}{2{\sigma}^2}n(\bar{X}-{\mu}_0)^2 & & (2) \end{aligned} $$
where $X_i = \{X_1, \cdots , X_n\}$ is independent and identically distributed and normally distributed with mean $\mu$ and standard deviation $\sigma$, $\mu_0$ is a certain number such that $H_0: \mu = \mu_0$, and $\bar{X}$ is the maximal likelihood estimate of $\mu$.
I understood how to apply (1) to (2). However, I'm not sure why the left side of (1) can be transformed as its right side. Then, how should I derive the formula (1)?