Following up on #2736, we need to document the function.
Note that I left the old partially implemented version of divergence matrix as a commented out block here as it could be a useful starting point. We should delete that as part of closing this issue.
Maybe be worth doing #2780 first.