[GiNaC-list] bug in series expansion of powers
Sheplyakov Alexei
varg at thsun1.jinr.ru
Sat Oct 2 11:47:47 CEST 2004
Hello!
This simple program
#include <iostream>
#include <ginac/ginac.h>
using namespace std;
using namespace GiNaC;
int main(int argc, char** argv)
{
symbol x("x");
symbol a("a");
symbol b("b");
ex test = pow(x+a,b);
cout << test << " = " << test.series(x,3) << endl;
return 0;
}
gives
(x+a)^b = 1+Order(x^3)
instead of
(x+a)^b = (a^b)+(a^b*b*a^(-1))*x+(1/2*a^b*b^2*a^(-2)-1/2*a^b*b*a^(-2))*x^2+Order(x^3)
Attached patch fix this bug.
-------------- next part --------------
diff -Nru GiNaC/ginac/pseries.cpp GiNaC-hacked/ginac/pseries.cpp
--- GiNaC/ginac/pseries.cpp 2004-08-09 18:32:09.000000000 +0400
+++ GiNaC-hacked/ginac/pseries.cpp 2004-10-01 10:21:00.000000000 +0400
@@ -955,10 +955,16 @@
if (!must_expand_basis && !exponent.info(info_flags::negint) && !is_a<add>(basis))
return basic::series(r, order, options);
+ if (!must_expand_basis && !exponent.info(info_flags::negint) && !is_a<numeric>(exponent))
+ return basic::series(r, order, options);
+
// Is the expression of type 0^something?
if (!must_expand_basis && !basis.subs(r, subs_options::no_pattern).is_zero() && !is_a<add>(basis))
return basic::series(r, order, options);
+ if (!must_expand_basis && !basis.subs(r, subs_options::no_pattern).is_zero() && !is_a<numeric>(exponent))
+ return basic::series(r, order, options);
+
// Singularity encountered, is the basis equal to (var - point)?
if (basis.is_equal(r.lhs() - r.rhs())) {
epvector new_seq;
More information about the GiNaC-list
mailing list