Paragraph

So that we don’t have to guess the best values for slope and intercept, we can appeal to calculus. Indeed, to minimize this function of the two variables m and b take partial derivatives and set them equal to zero to get the critical values:
\begin{equation*} TSE_m = \sum_{k=1}^n 2(m x_k + b - y_k) \cdot x_k \end{equation*}
and
\begin{equation*} TSE_b = \sum_{k=1}^n 2(m x_k + b - y_k) \cdot 1 . \end{equation*}
Setting equal to zero and solving gives what is known as the "normal equations":
\begin{equation*} m \sum_{k=1}^n x_k^2 + b \sum_{k=1}^n x_k = \sum_{k=1}^n x_k y_k \end{equation*}
and
\begin{equation*} m \sum_{k=1}^n x_k + b \sum_{k=1}^n 1 = \sum_{k=1}^n y_k. \end{equation*}
Solving these for m and b gives the best fit line.
in-context