Dirk Laurie on Thu, 9 Oct 2003 09:50:56 +0200 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: Oddities modulo multivariate polynomials |
Jeroen Demeyer skryf: > ? Y /* Make sure Y is defined first */ > %1 = Y > ? (Y^2) % (X^3 - Y^2) > %2 = X^3 > ? (X^3) % (X^2 + 1) > %3 = -X > ? ((Y^2) % (X^3 - Y^2)) % (X^2 + 1) > %4 = 0 > > How come the outputs of the two last statements are different? Is this > a bug or am I doing something wrong? Any help would be appreciated. > A very pleasant problem in detection! Let's get some more data. Start from scratch each time in a new Pari-GP session. First yours. ? ?X *** X: unknown identifier. ? ?Y *** Y: unknown identifier. ? Y %1 = Y ? ?Y *** Y: user defined variable. ? (Y^2) % (X^3 - Y^2) %2 = X^3 Now don't define Y. ? (Y^2) % (X^3 - Y^2) %1 = X^3 Same result. Now define X but not Y. ? X %1 = X ? (Y^2) % (X^3 - Y^2) %2 = Y^2 Aha! Now define both. ? X %1 = X ? Y %2 = Y ? (Y^2) % (X^3 - Y^2) %3 = Y^2 Interesting. Let's change the order in which they are defined. ? Y %1 = Y ? X %2 = X ? (Y^2) % (X^3 - Y^2) %3 = X^3 Very interesting. I make the following hypothesis: When more than one atomic variable appears in an expression, the % function needs to decide which variable is independent. It decides in favour of the one that was defined first. If undefined identifiers appear, they are defined before the expression is evaluated, using a simple left-to-right scan. If the hypothesis is correct, the following expression should evaluate to Y^2 ... ? (0*X+Y^2) % (X^3 - Y^2) %1 = Y^2 ... but this one to X^3 ? (Y^2+0*X) % (X^3 - Y^2) %1 = X^3 The hypothesis so far stands up. To explain your original result: I guess that once the decision has been made, it remains in effect for the whole expression. So that in an expression like the one giving your %4, the independent variable is Y, since it was defined first. You can't have Y as independent in one subexpression and X in the other. Whereas in %3 there is no ambiguity. Dirk