Changed the sign of the cost function to give cleaner code.

We need the opposite sign to *minimize* the cost, but we can add that in later.