Compute cost for linear regression