crsa ml hw 3: vectorized logistic cost & gradient functions