Zhao Li on Wed, 04 May 2022 14:21:00 +0200


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

Re: slow factor


Thank you.

It looks that the priority really matters. However, how should we determine which one has higher priority, since we have seen another example which can be only be solved when ieta has higher priority. 

====================
default(parisize, 1200000000);

ep; 
ieta; 

fact(P) =
{
 my(x=variable(P),y=variable(Vec(P)));
 my(d=poldegree(P,y));
 my(C=content(P),FC=factor(C));
 for(i=1,oo,
   my(R=substpol(factor(subst(P/C,y,(x+i)^d)),(x+i)^d,y));
   R = matconcat([FC,R]~);
   my(F=factorback(R)*C);
   if(pollead(P)*F==pollead(F)*P,
     return(R)));
}

P = -28663841312*ep*ieta - 2274604*ep*ieta^2 - 68*ep*ieta^3 + 207812849512*ep^2*ieta + 6644238*ep^2*ieta^2 + 182*ep^2*ieta^3 - 372629937056*ep^3*ieta - 5656581*ep^3*ieta^2 - 147*ep^3*ieta^3 + 239432*ieta^2 + 8*ieta^3 ;

F = fact(P)
====================

Cheers,
Zhao

Theoretical Physics Division
Institute of High Energy Physics
Chinese Academy of Sciences

> On May 4, 2022, at 7:42 PM, Bill Allombert <Bill.Allombert@math.u-bordeaux.fr> wrote:
> 
> On Wed, May 04, 2022 at 07:20:59PM +0800, Zhao Li wrote:
>> We have run it for about an hour but it still does not stop. It seems it got into an infinite loop. 
>> 
>> We are using the version 2.13.4。 
>> The complete script is 
>> 
>> ==========================
>> default(parisize, 1200000000);
>> 
>> fact(P) =
>> {
>> my(x=variable(P),y=variable(Vec(P)));
>> my(d=poldegree(P,y));
>> my(C=content(P),FC=factor(C));
>> for(i=1,oo,
>>   my(R=substpol(factor(subst(P/C,ieta,(x+i)^d)),(x+i)^d,ieta));
>>   R= matconcat([FC,R]~);
>>   my(F=factorback(R)*C);
>>   if(pollead(P)*F==pollead(F)*P,
>>     return(R)));
>> }
>> 
>> 
>> P = -400000*ieta + 3600000*ep*ieta + 4*ep*ieta^2 - 11300000*ep^2*ieta - 20*ep^2*ieta^2 + 15000000*ep^3*ieta + 33*ep^3*ieta^2 - 7200000*ep^4*ieta - 18*ep^4*ieta^2;
> 
> OK I found the problem. This is due to variable priority, in my GP
> session ep has higher priority than ieta but it is the opposite in your.
> 
> My script mistakenly assumed the secondary variable to be always ieta and never ep.
> 
> Change the line 
>    my(R=substpol(factor(subst(P/C,ieta,(x+i)^d)),(x+i)^d,ieta));
> to
>    my(R=substpol(factor(subst(P/C,y,(x+i)^d)),(x+i)^d,y));
> 
> and it should work.
> 
> On the other hand, you can save you some potential confusion by forcing
> a variable order when you start gp:
> do
> ep;ieta;
> before using ieta to ensure ep always have higher priority.
> 
> Cheers,
> Bill.