Jacques Gélinas on Sun, 17 Jun 2018 06:49:42 +0200


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Rational functions equal almost everywhere, but not for "subst"


A perplexing (bad) use of global variables.

g1(r,R) = R / (2*r+1 - R);
g2(r,R) = a + r;
F(r,a,b,R) =   g1(r,a*b*R) / g1(r-1,a*R)     * g2(r,a*b*R) / g2(r-1,a*b*R) ;
G(r,a,b,R) = b * (2*r-1-a*R) / (2*r+1-a*b*R) * g2(r,a*b*R) / g2(r-1,a*b*R) ;
G(r,a,b,R) == F(r,a,b,R)               \\ identical !
1
G(r,0,b,R) == subst(F(r,a,b,R),a,0)    \\ not equal ??? (:-(
0
G(r,0,b,R) == (2*b*r^2 + (2*b*a - b)*r - b*a)/(2*r^2 + (2*a - 1)*r + (a - 1))
1
subst(F(r,a,b,R),a,0) == (2*b*r^2 - b*r)/(2*r^2 - r - 1)
1
g2(r,R) = a + 1;
G(r,a,b,R) == F(r,a,b,R)               \\ identical !
1
G(r,0,b,R) == subst(F(r,a,b,R),a,0)    \\ equal (:-)
1

Could someone explain why the substitution fails with the first definition of "g2" ?

(This problem occurs with GP 2.9.4, but not with GP 2.4.1).

Jacques Gélinas