Implement gradient of bond term.