solving quadratic graphs and maximum and minimum