basic cubic formula implementation