[GiNaC-list] normal() bug-or-feature

Sheplyakov Alexei varg at thsun1.jinr.ru
Wed Nov 10 15:55:05 CET 2004


Hello!

Sometimes running normal() takes *really* long time. I've attached
an example, at first glance it looks horrible, but in fact 
the expression equals zero.

The root of the problem seems to be that gcd(e1, e2, &ca, &cb)
returns cb in expanded form, as in:


#include <iostream>
#include <ginac/ginac.h>
using namespace std;
using namespace GiNaC;

int main(int argc, char** argv)
{
	symbol m1("m1");
	symbol m2("m2");
	symbol x("x");
	ex e1 = pow(x,2)*pow(m1,2) - pow(x,2)*pow(m2,2);
	ex e2 = pow(pow(x,2)*pow(m1,2)-pow(x,2)*pow(m2,2),100);
	ex ca, cb, gc;
	gc = gcd(e1, e2, &ca, &cb, false);
	cout << c2 << endl;
	// this won't be just x^198*(m1^2-m2^2)^99.
	// (m1^2-m2^2)^99 gets expanded.
	cout << (e1/e2).normal() << endl;
	// won't print just x^(-198)*(m1^2-m2^2)^(-99), 
	// (m1^2-m2^2)^99 gets expanded 

	return 0;
}

so normal() in fact expands denominators.


Is there any way to fix this bug/feature?

Thanks in advance,
	Alexei.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: normal_bug.cpp.gz
Type: application/x-gunzip
Size: 2509 bytes
Desc: not available
Url : http://www.cebix.net/pipermail/ginac-list/attachments/20041109/1d586602/normal_bug.cpp.gz


More information about the GiNaC-list mailing list