kahan sum everything for added numerical accuracy; fixed tensor contraction for G matrix; fixed sign bug in double factorial