init ex3
finished cost fucntion and grad