calculate divergence