I have a question regarding cost function and Ordinary Least Square (OLS) in univariate linear regression.
From my understanding, in linear regression, OLS is used to find the the slope and y-intercept that minimises the sum of squared differences between the dependent and independent variables.
While for cost function, my understanding is that it is also somewhat used to find a line of best fit, by measuring the relationship performance between the dependent and independent variables.
Then if that's the case, do we still need to use cost function when we are already using OLS to plot our line? Thank you.