[GiNaC-list] Bug in expand

Richard B. Kreckel kreckel at in.terlu.de
Thu May 7 09:06:15 CEST 2015


Hi Isuru,

On 05/05/2015 07:48 AM, Isuru Fernando wrote:
> I modified the first benchmark at http://www.ginac.de/csSC-0004015.pdf to,
> 
> e = expanded value of  (a0 + a1 + sqrt(3)*a2 + sqrt(3)*a3 + ... +
> sqrt(3)*a(n-1))^2
> 
> in e, substitute a0 with  -sqrt(3)*a2 - sqrt(3)*a3 - ... - sqrt(3)*a(n-1)
> 
> expand e again to obtain a1^2
> 
> 
> For n = 4, I get,
> 
>  -3*a3^2+2*3*a2^2+a1^2-6*a2^2+3*a3^2
> 
> Or 
> 
> 3*a3^2-3*a2^2-3*a3^2+a1^2+3*a2^2
> 
> which is true, but not the expression I expected. Why are the terms
> 3*a2^2 and -3*a2^2, not canceled out immediately? Also a term like
> 2*3*a2^2 means there is some bug right?
> 
> I am using ginac-1.6.3 on Ubuntu 14.10 with gcc-4.9.1. I am attaching
> the sample program.

Thank you for reporting this bug.
It turns out to be a problem in expand().
It has nothing to do with subs().
I am attaching a preliminary patch.

   -richy.
-- 
Richard B. Kreckel
<http://in.terlu.de/~kreckel/>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: isuru.patch
Type: text/x-diff
Size: 893 bytes
Desc: not available
URL: <http://www.cebix.net/pipermail/ginac-list/attachments/20150507/6ad5c14d/attachment.bin>


More information about the GiNaC-list mailing list