[GiNaC-devel] Substitution of wildcards

Vladimir V. Kisil kisilv at maths.leeds.ac.uk
Fri Jun 9 17:58:37 CEST 2017


>>>>> On Wed, 7 Jun 2017 18:26:47 +0200, Jan Rheinländer <jrheinlaender at gmx.de> said:

    JR> Hi, I'm wondering what is going on here (ginsh output):

    >> subs($1 * x + 1/2 * x^2 * $2, match(a * x + b, $1 + x * $2));
    JR> b*a+1/2*a^3

    JR> What happened to "x" ? The match by itself correctly finds

    >> match(a * x + b, $1 + x * $2);
    JR> {$2==a,$1==b}

    JR> but the substitution result is weird.

    According to the GiNaC tutorial:

    "* A single wildcard matches any expression. "

    Thus, the wildcard $2 matches to x, then the expression

    $1 * $2 + 1/2 * $2^2 * $2

    is substituted using  {$2==a,$1==b}.

-- 
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-devel mailing list