[GiNaC-list] Ginac not collecting terms when multiplying powers (bug?)
Vladimir V. Kisil
kisilv at maths.leeds.ac.uk
Mon Jul 20 12:19:21 CEST 2015
Dear Jonathan,
>>>>> On Mon, 20 Jul 2015 01:18:59 +0200, Jonathan Mills <jpamills at gmail.com> said:
JM> Consider this short programme:
JM> #include <iostream> #include <ginac/ginac.h> using namespace
JM> std; using namespace GiNaC;
JM> int main() { possymbol x("x"); cout << pow(4,x + 1) * pow(4,-1)
JM> << endl; }
JM> The result produced is: 1/4*4^(1+x), the expected output is 4^x.
JM> a positive value, I'm confused why this expression is not
JM> considered safe?
I think, that the issue here is not "safety". Making all possible
simplifications of this type will require to try all possible
simplification rules for each term of an expression. If done
automatically on every step this will make the system very slow. Thus,
GiNaC may require some assistance from a human.
In this particular example you will get the expected answer 4^x from
cout << (pow(4,x + 1) * GiNaC::pow(4,-1)).expand() << endl;
Best wishes,
Vladimir
--
Vladimir V. Kisil http://www.maths.leeds.ac.uk/~kisilv/
Book: Geometry of Mobius Transformations http://goo.gl/EaG2Vu
Software: Geometry of cycles http://moebinv.sourceforge.net/
More information about the GiNaC-list
mailing list