class RationalFunction {

    public RationalFunction drop(final int n) {
        Polynomial cn = m_pn, cd = m_pd;

        // size of the numerator:
        int p = cd.getDegree() + 1;
        int q = p;// -1;
        if (cn.getDegree() + 1 - n > q) {
            q = cn.getDegree() + 1 - n;
        }
        if (q == 0) {
            return new RationalFunction();
        }
        double[] phi = new double[q];
        double[] ntmp = new double[q];
        for (int i = 0; i < q; ++i) {
            phi[i] = get(i + n);
        }

        ntmp[0] = phi[0] * cd.get(0);
        for (int i = 1; i < q; ++i) {
            double s = 0;
            int imax = i < q ? i : q - 1;
            for (int j = 0; j <= imax; ++j) {
                int k = i - j;
                if (k < p) {
                    s += cd.get(k) * phi[j];
                }
            }
            if (Math.abs(s) < EPSILON) {
                s = 0;
            }
            ntmp[i] = s;
        }
        // simplifiy ntmp
        int qc = q;
        while ((qc > 0) && (ntmp[qc - 1] == 0)) {
            --qc;
        }
        if (qc == 0)
            return new RationalFunction();
        if (qc != q) {
            double[] ntmp2 = new double[qc];
            for (int i = 0; i < qc; ++i) {
                ntmp2[i] = ntmp[i];
            }
            ntmp = ntmp2;
        }
        return new RationalFunction(Polynomial.of(ntmp), cd);

    }

    public  RationalFunction();
    public  RationalFunction(final Polynomial pn, final Polynomial pd);

}