compute cost for linear regression