Bug in subst?

jocaps
Messages : 118
Inscription : lun. avr. 17, 2017 4:32 pm

Bug in subst?

Message par jocaps » lun. mars 26, 2018 12:16 pm

Hi,

Here is a python script that baffles me a bit.

Code : Tout sélectionner

from giacpy import giac

Tv2= giac("matrix[[(-2*l1*l2+2)/2,(2*l1+2*l2)/2,0,0,(-l1*a2-l1*a1-l2*a2-l2*a1)/2,(-l1*l2*a2-l1*l2*a1+a2+a1)/2,(-l1*d2+l2*d2)/2,(l1*l2*d2+d2)/2,0,0,0,0,0,0,0,0],[0,0,(-2*l1+2*l2)/2,(2*l1*l2+2)/2,(l1*l2*d2-d2)/2,(-l1*d2-l2*d2)/2,(l1*l2*a2-l1*l2*a1+a2-a1)/2,(l1*a2-l1*a1-l2*a2+l2*a1)/2,(-2*l1*l2+2)/2,(2*l1+2*l2)/2,0,0,(-l1*a2-l1*a1-l2*a2-l2*a1)/2,(-l1*l2*a2-l1*l2*a1+a2+a1)/2,(-l1*d2+l2*d2)/2,(l1*l2*d2+d2)/2],[0,0,0,0,0,0,0,0,0,0,(-2*l1+2*l2)/2,(2*l1*l2+2)/2,(l1*l2*d2-d2)/2,(-l1*d2-l2*d2)/2,(l1*l2*a2-l1*l2*a1+a2-a1)/2,(l1*a2-l1*a1-l2*a2+l2*a1)/2],[0,0,0,0,0,0,(l1+l2)/2,(l1*l2-1)/2,0,0,0,0,0,0,0,0],[0,0,0,0,(l1*l2+1)/2,(l1-l2)/2,0,0,0,0,0,0,0,0,(l1+l2)/2,(l1*l2-1)/2],[0,0,0,0,0,0,0,0,0,0,0,0,(l1*l2+1)/2,(l1-l2)/2,0,0],[0,0,(2*l1+2*l2)/2,(-2*l1*l2+2)/2,(-l1*l2*d2-d2)/2,(l1*d2-l2*d2)/2,(-l1*l2*a2-l1*l2*a1+a2+a1)/2,(-l1*a2-l1*a1-l2*a2-l2*a1)/2,0,0,0,0,0,0,0,0],[(-2*l1*l2-2)/2,(2*l1-2*l2)/2,0,0,(-l1*a2+l1*a1+l2*a2-l2*a1)/2,(-l1*l2*a2+l1*l2*a1-a2+a1)/2,(-l1*d2-l2*d2)/2,(l1*l2*d2-d2)/2,0,0,(2*l1+2*l2)/2,(-2*l1*l2+2)/2,(-l1*l2*d2-d2)/2,(l1*d2-l2*d2)/2,(-l1*l2*a2-l1*l2*a1+a2+a1)/2,(-l1*a2-l1*a1-l2*a2-l2*a1)/2],[0,0,0,0,0,0,0,0,(-2*l1*l2-2)/2,(2*l1-2*l2)/2,0,0,(-l1*a2+l1*a1+l2*a2-l2*a1)/2,(-l1*l2*a2+l1*l2*a1-a2+a1)/2,(-l1*d2-l2*d2)/2,(l1*l2*d2-d2)/2],[0,0,0,0,(-l1*l2+1)/2,(-l1-l2)/2,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,(l1-l2)/2,(l1*l2+1)/2,0,0,0,0,(-l1*l2+1)/2,(-l1-l2)/2,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,(l1-l2)/2,(l1*l2+1)/2]]")


print "Bug in subst (there should be no l1 or l2 in the matrix):"
print Tv2.subst("[ll,l2]","[1,1]")
The printed matrix has still entries with l1 and l2 variables in them (although I already made the substitution for them in the code). I get the expected result in Xcas but not in giacpy. Can anyone explain this? Is this a bug in subst?

Edit: using Tv2.subst("[l1=1,l2=1]") does work but that is rather awkward.

Edit2: I think I'm going mad. I can reproduce this sometimes and sometimes not. This is bizzare. I'll let you know if I can always reproduce this.

Jose

frederic han
Messages : 1113
Inscription : dim. mai 20, 2007 7:09 am
Localisation : Paris
Contact :

Re: Bug in subst?

Message par frederic han » mar. mars 27, 2018 5:31 am

NB: if I cut and paste your post I have a small L instead of a 1:

Code : Tout sélectionner

print Tv2.subst("[ll,l2]","[1,1]")  # ll instead of l1

Répondre