Credit Jonas Rauch for ideas re. symbolic differentation