[GiNaC-list] Expanding Polynomials

Vladimir V. Kisil kisilv at maths.leeds.ac.uk
Fri Sep 7 14:35:56 CEST 2018


>>>>> On Thu, 6 Sep 2018 08:59:13 +0200, Patrick Schulz <pschulz at posteo.de> said:

    PS> And sorry for messing up the subject!  On 06.09.2018 08:47,
    PS> Patrick Schulz wrote:
    >> Hi all!
    >> I'm working with polynomials in one variable, where i want to
    >> compare coefficients and remove some (simplification). For this,
    >> i need to iterate over the individual coefficients, but in order
    >> to compare them, i need them to be in a standard form. Since only
    >> terms with products and sums are involved, i expand the
    >> expressions to remove any nested expressions, e.g. R1 * (C1 + C2)
    >> -> R1 * C1 + R1 * C2.  This works well, but sometime terms of nth
    >> power also exist, which are not expanded:
    >> GiNaC::symbol R1("R1"); GiNaC::symbol R2("R2"); GiNaC::symbol
    >> C1("C1"); GiNaC::symbol C2("C2"); GiNaC::ex e = (R1 + R2) * (C1 +
    >> C2 * (R1 * C1)); std::cout << e << '\n' << e.expand() << '\n';
    >> Here we get a term R1^2 * C1 * C2, which does not comply with my
    >> "standard form".

    I am afraid the substitution R1*R1 -> R1^2 is the substitution which
  GiNaC  is doing for symbols automatically. So you either need to write
  your own class which will not have this feature or find an algorithm
  to deal with power.

  Best wishes,
Vladimir V. Kisil                 http://www.maths.leeds.ac.uk/~kisilv/
  Book:     Geometry of Mobius Transformations     http://goo.gl/EaG2Vu
  Software: Geometry of cycles          http://moebinv.sourceforge.net/

More information about the GiNaC-list mailing list