class SumatraMath {

	public static List<Double> quadraticFunctionRoots(final double a, final double b, final double c)
	{
		List<Double> roots = new ArrayList<>();
		
		if (isEqual(a, 0.0))
		{
			if (isEqual(b, 0.0))
			{
				// the function is of constant form 'c = 0' => no roots
				return roots;
			}
			
			double x1 = -c / b;
			roots.add(x1);
			return roots;
		}
		
		// normalize coefficients
		double p = b / a;
		double q = c / a;
		
		// calculate discriminant
		double d = (p * p) - (4.0 * q);
		
		if (d < 0.0)
		{
			// no real solution
		} else if (d > 0.0)
		{
			double pHalf = p * 0.5;
			double x1 = -pHalf + SumatraMath.sqrt((pHalf * pHalf) - q);
			double x2 = -pHalf - SumatraMath.sqrt((pHalf * pHalf) - q);
			roots.add(x1);
			roots.add(x2);
		} else
		{
			double x1 = -p * 0.5;
			roots.add(x1);
		}
		
		return roots;
	}

	private  SumatraMath();

}