Expander Functions for Generating Full Gradient and Hessian from