Introduction to Statistical Learning Eq. 4.32 Can someone please explain how the third line becomes the fourth line?


Another way would be adding some terms to make the first multiplicands the same, and group (subtract the added terms outside of the parantheses as well):
$$\begin{align}A&=-\frac{1}{2}(x-\mu_k-\overbrace{\mu_K}^{new})^T\Sigma^{-1}(x-\mu_k)+\frac{1}{2}(x-\mu_K-\overbrace{\mu_k}^{new})^T\Sigma^{-1}(x-\mu_K)\\&- \frac{1}{2}\mu_K^T\Sigma^{-1}(x-\mu_k)+\frac{1}{2}\mu_k^T\Sigma^{-1}(x-\mu_K)\rightarrow \text{subtract newly added terms}\\&=\frac{1}{2}(x-\mu_k-\mu_K)^T\Sigma^{-1}(\mu_k-\mu_K)+\frac{1}{2}x^T\Sigma^{-1}(\mu_k-\mu_K)\\&=x^T\Sigma^{-1}(\mu_k-\mu_K)-\frac{1}{2}(\mu_k+\mu_K)^T\Sigma^{-1}(\mu_k-\mu_K)\end{align}$$
Note that $x^T\Sigma^{-1}\mu=\mu^T\Sigma^{-1}x$ since inverse of cov. matrix is symmetric.
