In a machine learning course, the professor described the gradient descent method for calculating the regression line. Shortly, we're looking for the $a$ and $b$ in $y=ax+b$ which describes the line. A cost function $E$ measures the distance between the line and all the points. Thus, we have a surface $E(a,b)$, and finding the minimum of $E$ gives the best line function.
There are, however, statistical methods for calculating regression lines, for example as shown here, using the standard deviation of $X$, $Y$ and Pearson's coefficients.
Are the two methods equivalent? Do they give the same results? When should we use each?