Exercise 2: Logistic regression cost function