Add numerical differentiation and fix up matrix formatting.