# [GiNaC-list] same expression prints in differs orders

Alexei Sheplyakov alexei.sheplyakov at gmail.com
Tue Sep 21 12:34:19 CEST 2010

```Hi again,

> The code try to find the integral of a function. The code include all basic
> integration rules, for the function log(x)^2*x^(-1) apply these rule.

> ex f = pow(log(x),2)/x;
> // case a: f = x^(-1)*log(x)^2, case b: log(x)^2*x^(-1)
> ex w0, w1, w2;
> exmap m;
>
> if( f.match(pow(wild(0),wild(1))*wild(2), m)) {

[skipped the rest of the code]

This .match is certainly ambigous, and term ordering has very little
to do with the ambiguity. The thing is that possible to match
the expression (at least) in two ways: one with \$2 == x^(-1) and
another with \$2 == log(x)^2. Both are perfectly valid, no matter
what internal representation is. I guess the solution is to

1. match against \$0^\$1 * \$2^\$3 and check
a. if \$2^\$3 is derivative of \$0^\$1
b. if \$0^\$1 is the derivative of \$2^\$3
2. if there's no match, or neither a or b holds,
match against \$0^\$1 * \$2

Hope this helps,
Alexei
```