[GiNaC-list] About 'unoptimal' expanding (Was: GiNaC Licensing)

Alexei Sheplyakov varg at theor.jinr.ru
Wed Oct 22 12:58:55 CEST 2008

Dear Ondrej,

On Wed, Oct 22, 2008 at 12:16:23AM +0200, Ondrej Certik wrote:

> Ginac is expanding in an unoptimal way though,

Are you sure?

$ cat simple.ginsh
#!/usr/bin/env ginsh
e = (x^10+x^9+x^8+x^7+x^6+x^4+x^3+x^2+x+1)*(x-1);
g = e^10*(e^10+1);
./simple.ginsh | tail -n1

Your "optimal" method runs out of memory:

$ cat smart.ginsh
#!/usr/bin/env ginsh
e = (x^10+x^9+x^8+x^7+x^6+x^4+x^3+x^2+x+1)*(x-1);
g = e^20 + e^10;
./smart.ginsh | tail -n1
syntax error, unexpected ')' at )

In many calculations the initial and final expressions are (much) smaller
than intermediate ones. That's why GiNaC tries to to cancel intermediate
terms as early as possible. Hence 'unoptimal' (bottom-up instead of top-down)
expand(), eval(), etc.

Best regards,

All science is either physics or stamp collecting.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 827 bytes
Desc: Digital signature
Url : http://www.cebix.net/pipermail/ginac-list/attachments/20081022/1e260558/attachment.sig 

More information about the GiNaC-list mailing list