@Test
    public void testFactorise() {
        System.out.println("testFactorise");
        Polynomial quadratic = PolynomialParser.parse("30x^5 – 166x^4 – 542x^3 + 2838x^2 + 1520x – 800");
        ConcurrentSkipListSet<Double> expResult = new ConcurrentSkipListSet<>();
        expResult.add(5.0);
        expResult.add(-4.0);
        expResult.add(-4.0/5);
        expResult.add(Rounding.roundDP(1.0/3, 3));
        ConcurrentSkipListSet<Double> result = quadratic.factorise(3);
        assertEquals(expResult, result);
        
        java.util.function.Function<Integer,Double[]> randRoots = (size) -> {
            Double[] roots = new Double[size];
            for (int i = 0; i<size; i++){
                roots[i] = Rounding.roundDP(Math.random(), 3)*10;
            }
            return roots;
        };
        java.util.function.Function<Double[], Polynomial> randPoly = (roots) -> {
            Polynomial p = new Polynomial();
            p.addTerm(0, 1);
            for (int i = 0; i<roots.length; i++){
                Polynomial factor = new Polynomial();
                factor.addTerm(1, 1);
                factor.addTerm(0, -1*roots[i]);
                p = p.multiply(factor);
            }
            return p; 
        };
        for (int i = 0; i<10; i++){
            int sigFigs = 3;
            Double[] roots = randRoots.apply(sigFigs);
            Polynomial p = randPoly.apply(roots);
            Double[] expected = Rounding.roundDP(roots, sigFigs);
            ConcurrentSkipListSet<Double> actual = p.factorise(sigFigs);
            ConcurrentSkipListSet<Double> list = new ConcurrentSkipListSet<>();
            for (Double expected1 : expected) {
                list.add(expected1);
            }
            assertEquals(list,actual);
        }
        
    }