compute_gradient tested, gives satisfactory results (?)