works for quadratic (3var)