Solves quadratic functions with the PQ rule