public void reduce(){
        List<Term> result=new ArrayList<Term>();
        HashMap<Integer,Term> exponents = new HashMap<Integer,Term>();
        for(int i=0; i<polynomial.size(); i++){
            if(!exponents.containsKey(polynomial.get(i).getExponent()) && polynomial.get(i).getExponent()>=0){
                exponents.put(polynomial.get(i).getExponent(), new Term(polynomial.get(i).getCoefficient()[0],polynomial.get(i).getCoefficient()[1],polynomial.get(i).getExponent()));
            }else{
                int sum[] = fraction.sum(exponents.get(polynomial.get(i).getExponent()).getCoefficient()[0], exponents.get(polynomial.get(i).getExponent()).getCoefficient()[1], polynomial.get(i).getCoefficient()[0], polynomial.get(i).getCoefficient()[1]);
                exponents.put(polynomial.get(i).getExponent(),new Term(sum[0],sum[1],polynomial.get(i).getExponent()));
            }
        }
        for (int n : exponents.keySet()) {
            if(exponents.get(n).getCoefficient()[0]!=0){
                result.add(exponents.get(n));
            }
        }
        Collections.sort(result);
        polynomial=result;
    }