Split function and gradient calculation
grad_share.RdCalculate function and gradient together but access separately. Reduces computation since they share data in calculation. Doesn't have to be function and gradient, can be any two values calculated together but accessed separately. Useful in optimization when function evaluation is expensive since the chain rule means many parts of function and gradient are the same.