You want to write the derivative as - x.d_ / expm1(-x.val_);  

It's a sign change and a division instead of a multiplication and a division.  

And try not to over-parenthesize.  It's harder to read if you know the rules of the language, because you only expect to see parens where they're needed to disambiguate.