I'm not the most mathematically minded, but I'm doing my best to learn MLEs. We were provided the following original likelihood function of a Normal Distribution and I am having trouble understanding how part of these workings were simplified. It's holding me back from understanding the rest of the concept.
Likelihood Function of a Normal Distribution provided:
$$ p(y\mid\theta) = \left(\frac{1}{2\pi\sigma}\right)^{n/2}\exp \left(-\frac{1}{2\sigma^2} \sum_{i=1}^n (\mu-y_i) \right) $$
The teacher then went on to explain that for easy differentiation, we rewrite this as a negative log function (which I understand).
$$ \mathcal{L}(y\mid\theta:\mu,\sigma) = -\log p(y\mid\theta:\mu,\sigma)\\ = -\log\left(\left( \frac{1}{2\pi\sigma^2}\right)^{n/2} \exp \left( -\frac{1}{2\sigma^2} \sum_{i=1}^{n}(\mu-y_i)^2\right)\right) $$
This next part is where I got confused. The teacher then simplifies this to:
$$ =\frac{n}{2}\log(2\pi\sigma^2) + \frac{1}{2\sigma^2}\sum_{i=1}^n (y_i-\mu)^2 $$
My questions are:
How did we get from $\biggl( \frac{1}{2\pi\sigma^2}\biggr)^{\frac{n}{2}} $ to $\frac{n}{2}\log(2\pi\sigma^2)$? What rule/s were used?
The same for the right hand side: How did we get from $\exp \biggl( -\frac{1}{2\sigma^2} \sum_{i=1}^{n}(\mu-y_i)^2 \biggr)$ to: $ -\frac{1}{2\sigma^2}\sum_{i=1}^n (y_i-\mu)^2$?
Would appreciate someone showing me the step by step or pointing me towards the rules required to complete the simplification!
We have
\begin{align*} & -\log \left( \left(\frac{1}{2\pi\sigma^2}\right)^{n/2} \exp \left( -\frac{1}{2\sigma^2} \sum_{i=1}^n(\mu - y_i)^2 \right) \right) \\ = & \: -\log \left( \left(\frac{1}{2\pi\sigma^2}\right)^{n/2}\right) - \log \left(\exp \left( -\frac{1}{2\sigma^2} \sum_{i=1}^n(\mu - y_i)^2 \right) \right) \\ = & \: -\log \left( (2\pi\sigma^2)^{-n/2}\right) - \left(-\frac{1}{2\sigma^2} \sum_{i=1}^n(\mu - y_i)^2\right) \\ = & \: -\left(-\frac{n}{2}\right)\log (2\pi\sigma^2) + \frac{1}{2\sigma^2} \sum_{i=1}^n(\mu - y_i)^2 \\ = & \: \frac{n}{2} \log (2\pi\sigma^2) + \frac{1}{2\sigma^2} \sum_{i=1}^n(y_i - \mu)^2 \end{align*} as desired. This uses only basic algebraic manipulations, including some logarithm properties such as $\log(ab) = \log(a) + \log(b)$ and $\log(a^b) = b \log a$.