It's better to plug the solution into the polynomial and test that it goes to 0. There are probably already helper functions to do it all. Maybe @smichr can comment.