Solve quadratic equations using a numerical stable method