series taking too looooooong.

Chris Dams chrisd at sci.kun.nl
Mon Apr 19 16:01:35 CEST 2004


Hello,

I found out that if I make the series expansion of a multiplication that
has somewhere in it a factor to a rather large power (say 8), determining
the lowest order of that takes very long. For instance, determinging the
lowest order of

b0^(-10)*(-2*b0^(-7)*log(-b0^(-2)*b1*recs)*b1^3*recs^4-b0^(-5)*log(-b0^(-2)*b1*recs)^2*b1^2*recs^3+b0^(-5)*b1^2*recs^3+b0^(-7)*log(-b0^(-2)*b1*recs)^3*b1^3*recs^4+b0^(-3)*log(-b0^(-2)*b1*recs)*b1*recs^2+3*b0^(-6)*b2*log(-b0^(-2)*b1*recs)*b1*recs^4-1/2*b0^(-7)*b1^3*recs^4-b0^(-4)*b2*recs^3+1/2*b0^(-5)*recs^4*b3-b0^(-1)*recs-b0^(-5)*log(-b0^(-2)*b1*recs)*b1^2*recs^3+5/2*b0^(-7)*log(-b0^(-2)*b1*recs)^2*b1^3*recs^4)^8*b1^9

with respect to the variable recs takes a few seconds on my pentium 1.8
GHz.

The attached patch should make this much faster by determining the lowest
order of the base and simply multiplying it with the exponent.

Bye,
Chris

-------------- next part --------------
Index: pseries.cpp
===================================================================
RCS file: /home/cvs/GiNaC/ginac/pseries.cpp,v
retrieving revision 1.76
diff -r1.76 pseries.cpp
787,788c787,794
< 
< 		ex buf = recombine_pair_to_ex(*it);
---
> 		ex expon = it->coeff;
> 		int factor = 1;
> 		ex buf;
> 		if(expon.info(info_flags::integer)) {
> 			buf = it->rest;
> 			factor = ex_to<numeric>(expon).to_int();
> 		} else
> 			buf = recombine_pair_to_ex(*it);
804c810
< 		ldegrees.push_back(real_ldegree);
---
> 		ldegrees.push_back(factor*real_ldegree);


More information about the GiNaC-devel mailing list