Update function to compute E. The test script now computes E as well.