add the cost function and gradient desecnt