improved general implementation of evaluation and differentation of product of variables