A basic maths question, but the same type of formula is appearing everywhere in my text and i am unable to join the dots. Could some please show me how to obtain the second line from the first?
Kind regards
$$L = \prod_{i=1}^n f(y_i) = \frac1{\left(\sqrt{2\pi\sigma^2}\right)^n}\prod_{i=1}^n \exp\left[-\frac1{2\sigma^2}\varepsilon_i^2\right]$$
$$\log L = -\frac n2 \log(2\pi\sigma^2) - \frac1{2\sigma^2}\sum_{i=1}^n\varepsilon_i^2$$
It comes from directly taking the logarithm of both sides and simplifying using rules of logs. Note that this is the natural logarithm with base $e$ that we're taking. It's typically denoted $\ln$ in calculus and before, but beyond calculus people usually just use $\log$ to denote natural log.
\begin{align*} L &= \frac1{\left(\sqrt{2\pi\sigma^2}\right)^n}\prod_{i=1}^n \exp\left[-\frac1{2\sigma^2}\varepsilon_i^2\right]\\[0.3cm] \log L &= \log \left(\frac1{\left(\sqrt{2\pi\sigma^2}\right)^n}\prod_{i=1}^n \exp\left[-\frac1{2\sigma^2}\varepsilon_i^2\right]\right)\\[0.3cm] &= \log \left(\frac1{\left(\sqrt{2\pi\sigma^2}\right)^n}\right)+\log\left(\prod_{i=1}^n \exp\left[-\frac1{2\sigma^2}\varepsilon_i^2\right]\right)\tag{1}\\[0.3cm] &= \log \left(\left(2\pi\sigma^2\right)^{-n/2}\right)+\log\left(e^{-\varepsilon_1^2/(2\sigma^2)} \cdot e^{-\varepsilon_2^2/(2\sigma^2)} \cdots e^{-\varepsilon_n^2/(2\sigma^2)}\right)\\[0.3cm] &= -\frac n2\log \left(2\pi\sigma^2\right)+\log\left(e^{-\varepsilon_1^2/(2\sigma^2)}\right) + \log\left(e^{-\varepsilon_2^2/(2\sigma^2)}\right) + \cdots + \log\left(e^{-\varepsilon_n^2/(2\sigma^2)}\right)\tag{2}\\[0.3cm] &= -\frac n2\log \left(2\pi\sigma^2\right) + \frac{-\varepsilon_1^2}{2\sigma^2} + \frac{-\varepsilon_2^2}{2\sigma^2} + \cdots + \frac{-\varepsilon_n^2}{2\sigma^2}\tag{3}\\[0.3cm] &= -\frac n2\log \left(2\pi\sigma^2\right) + \left(-\frac1{2\sigma^2}\right) \left(\varepsilon_1^2 + \varepsilon_2^2 + \cdots + \varepsilon_n^2\right)\\[0.3cm] &= -\frac n2\log \left(2\pi\sigma^2\right) - \frac1{2\sigma^2} \sum_{i=1}^n\varepsilon_i^2\\[0.3cm] \end{align*}
The equality in the line labeled $(1)$, i.e., when going to $(1)$ from the line above $(1)$, comes from the product rule for logs: $\log(AB) = \log A + \log B$
The equality in the line labeled $(2)$ uses that property again and it uses the power rule for logs: $\log(A^r) = r \log A$
The equality in the line labeled $(3)$ uses the "inverse" property of exponentials and logs: $\log(e^A) = A$
All other manipulations are routine arithmetic operations.