[GiNaC-list] Ordering of expressions

Burcin Erocal burcin at erocal.org
Wed Aug 12 14:45:07 CEST 2009


On Mon, 10 Aug 2009 23:06:30 +0200
"Richard B. Kreckel" <kreckel at ginac.de> wrote:

> Burcin Erocal wrote:
> > In order to use ginac as the symbolics backend in Sage [1], we also
> > had to work around this random printing problem.
> 
> May I ask why stable printing is a requirement for use in Sage?

Sage is also meant to be used interactively, besides just a computation
engine where you run a program and expect a number as output.
Inspection of intermediate results is so much easier if the output is
consistent between different sessions.


> > In retrospect, this was not the right way to fix the printing
> > problem. I should have done as the ginac developers suggested when
> > I first asked about this [2]. Unfortunately, I didn't know much
> > about the design of the ginac library then, and I wanted to get
> > things done quickly.
> > 
> > [2] http://www.ginac.de/pipermail/ginac-list/2008-August/001406.html
> > 
> > 
> > When I find the time, I plan to move the new comparison functions
> > out of the way and bring back the old ones to make things fast
> > again. Then, add some code in expairseq to sort its arguments with
> > the new comparison functions before printing, and cache the sorted
> > sequence somewhere. I don't expect to have the time to do this in
> > the near future however.
> > 
> > I hope some of this will be useful if you try to stabilize printing
> > order in ginac.
> 
> It won't be difficult to sort terms lexicographically, when printing,
> as opposed to based on hash values. But I doubt that caching the
> sorted sequence will be of practical use.

I thought that caching might help with printing large expressions
repeatedly. It could well be that it is pointless.

Now that I have the compression functions, using them only for printing
should be easy. I just don't have much time to work on this.


BTW, I would welcome any comments and suggestions on the patches we've
added to GiNaC for Sage, which you can browse here:

http://pynac.sagemath.org/hg/

Especially, automatic simplification of powers and multiples of exp

http://pynac.sagemath.org/hg/rev/24e8ecd16228 exp(a)*exp(b) -> exp(a+b)
http://pynac.sagemath.org/hg/rev/5c4862f90e17 (e^x)^y -> e^(x*y)

and new constants for infinity

http://pynac.sagemath.org/hg/rev/7ebab844bcef
http://pynac.sagemath.org/hg/rev/0b112e7dd282

might be useful. Note that there is still more work to be done on
making special functions handle infinity properly, what I added in the
second patch above is a blind copy of Mathematica behavior.

I was hoping that the capability to work with infinity would help
series expansions, where 1/ (1/0) could be evaluated as 1/infinity ->
0. Here is an example which demonstrates this problem:

http://groups.google.com/group/sage-devel/browse_thread/thread/d95c952e05951d8e/a59f3c5d0586766b?#a59f3c5d0586766b


Cheers,
Burcin


More information about the GiNaC-list mailing list