Function to compute the cost for multiple regression