Implement polynomial solver.
Add diag function.