public Double[][] sum(Double[][] a, Double[][] b) {
        Double[][] ans = new Double[2][a[0].length+b[0].length];
        boolean flag = false;
        for(int i=0; i<a[0].length; i++){
            ans[0][i] = a[0][i];
            ans[1][i] = a[1][i];
        }
        if(a[0].length < b[0].length){
            Double[][] t = a;
            a = b;
            b = t;
        }
        for(int i=0;i<b[0].length; i++){
            for(int j=0;j < a[0].length; j++){
                if(a[1][j].doubleValue() == b[1][i].doubleValue()){
                    ans[0][j] += b[0][i];
                    flag = true;
                }                
            }
            if(!flag){
                ans[0][a[0].length+i] = b[0][i];
                ans[1][a[1].length+i] = b[1][i];
            }
            flag = false;
        }
        return ArrayVerifier.removeZeroCoefs(ans);
    }