computed cost for log regression and grad desc