The Drazin inverse as a gradient