gradient computation have been implemented