working cost and gradient