kredel / java-algebra-system

Java Algebra System (JAS) Project
GNU General Public License v2.0
44 stars 9 forks source link

Normalize polynomial results from approximantOfPade? #29

Open axkr opened 2 years ago

axkr commented 2 years ago

Can the result poylnomials be "normalized" from the approximantOfPade(), so that the coefficient for x^0 is 0 or 1.

  public void testQuotientPade001() {
    GenPolynomialRing<BigRational> pr = fac.polyRing();
    GenPolynomial<BigRational> numerator = pr.parse("x^3 + 72 x^2 + 600 x + 720 ");
    GenPolynomial<BigRational> denominator = pr.parse("12 x^2 + 240 x + 720");
    QuotientRing<BigRational> qr = new QuotientRing<BigRational>(pr);

    Quotient<BigRational> p = new Quotient<BigRational>(qr, numerator, denominator);

    QuotientTaylorFunction<BigRational> tf = new QuotientTaylorFunction<BigRational>(p);

    Quotient<BigRational> approximantOfPade =
        PolyUfdUtil.<BigRational>approximantOfPade(fac, tf, BigRational.ZERO, 3, 1);
    System.out.println(approximantOfPade.toString());
    System.out.println("num: " + approximantOfPade.num.toString());
    System.out.println("den: " + approximantOfPade.den.toString());
  }

gives

{ ( -1/192 ) x^3 + 3/16 x^2 + 23/8 x + 15/4  | x + 15/4  }
num: ( -1/192 ) x^3 + 3/16 x^2 + 23/8 x + 15/4 
den: x + 15/4 
kredel commented 2 years ago

The normalization of the quotient as normalization of the denominator leading coefficient to one is hard coded in the constructor. Maybe it would need an enumeration of possible normalizations defined in its ring.

kredel commented 2 years ago

The next JAS version will contain code to select between different quotient normalizations.

/** Quotient polynomial normalization, simplification. */
public static enum QuoNorm {
    normNumLead,  // normalize ldcf(numerator) == 1
    normNumTrail, // normalize trcf(numerator) == 1
    normDenLead,  // normalize ldcf(denominator) == 1
    normDenTrail  // normalize trcf(denominator) == 1
};
/** Default quotient polynomial normalization, simplification.*/
public final static QuoNorm quoNorm = QuoNorm.normDenLead; // must be the default

But using other normalizations than QuoNorm.normDenLead will crash code in various places. Could you please help in spotting all those places and give hints on what would be a desirable solution?