[GiNaC-list] factorization bug
Ivan Vasilyev
grabesstimme at gmail.com
Sun Jan 30 22:01:48 CET 2022
Hi! I believe there's an intermittent bug in GiNaC::factor() function.
Sometimes it leaves uncancelled terms with seemingly random coefficients
like:
w*(w^2*(K^4*B^2+B^2-2*K^2*B^2)+196*w^2*K^4+196*w^2+C^2-196*w^2*(1+K^4-2*K^2)-392*w^2*K^2)*A
The minimal code to reproduce the bug in GiNaC 1.8.2 is:
#include <ginac/ginac.h>
#include <iostream>
int main()
{
std::string input("w^3*B^2*A-2*w^3*K^2*B^2*A+w*C^2*A+w^3*K^4*B^2*A");
while (true)
{
std::ostringstream s;
GiNaC::parser reader;
s << factor(reader(input));
if (s.str().length() <= input.length())
continue;
std::cout << s.str() << '\n';
return 0;
}
}
Also, this problem can be reproduced on
https://daninet.github.io/ginac-wasm/ with the same expression being
calculated several times in a row:
factor(w^3*B^2*A-2*w^3*K^2*B^2*A+w*C^2*A+w^3*K^4*B^2*A);
With best regards,
Ivan.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.ginac.de/pipermail/ginac-list/attachments/20220131/dc8c1f63/attachment.htm>
More information about the GiNaC-list
mailing list