simplify_rational and Pynac

24 views
Skip to first unread message

Ben Goodrich

unread,
Nov 13, 2010, 1:39:38 PM11/13/10
to sage-devel
Hi,

The simplify_rational method has three choices for Maxima functions,
but I wanted to try GiNaC's normal method described here

http://www.ginac.de/tutorial/Rational-expressions.html#Rational-expressions

to see if it was faster. Has someone already tried this and concluded
Maxima was better?

I see that there is an expand_rational method in sage that uses Pynac
whose main part is just

_sig_on
cdef GEx x = self_.gobj.expand(0)
_sig_off
return new_Expression_from_GEx(self._parent, x)

So I guess I would need to copy those lines and change .expand(0)
to .normal(). But how do I add the .normal() method to Pynac's table
of eligible GiNaC functions?

Thanks,
Ben



kcrisman

unread,
Nov 13, 2010, 9:45:14 PM11/13/10
to sage-devel


On Nov 13, 1:39 pm, Ben Goodrich <goodrich....@gmail.com> wrote:
> Hi,
>
> The simplify_rational method has three choices for Maxima functions,
> but I wanted to try GiNaC's normal method described here
>
> http://www.ginac.de/tutorial/Rational-expressions.html#Rational-expre...
>
> to see if it was faster. Has someone already tried this and concluded
> Maxima was better?
>

Maxima has a very large number of very specific types of
simplifications/expansions. It allows for quite a bit of control.
That said, the main reason our Maxima stuff is slow is because we use
'pexpect' to communicate with it. Nils Bruin has a patch allowing us
to "turn on" a library interface (which is now already built inside
Sage) to Maxima instead; it would be great if someone who knew enough
about Lisp and whatever else needed would give it a positive review,
so that we could check such things at the library level.

That's a little orthogonal to your main question, which I should know
the answer to, but have forgotten off hand. Might this be in sage/
libs/ginac/ ?

- kcrisman

Ben Goodrich

unread,
Nov 15, 2010, 10:56:46 AM11/15/10
to sage-devel
On Nov 13, 9:45 pm, kcrisman <kcris...@gmail.com> wrote:
> That's a little orthogonal to your main question, which I should know
> the answer to, but have forgotten off hand.  Might this be in sage/
> libs/ginac/ ?

Thanks for the tip, which seems to have worked. I opened a ticket
(10268), attached my patch, and uploaded a benchmark. The new GiNaC
option is about 10x faster than the default. It would be interesting
to benchmark it again when Maxima can be used as a library. Then
again, my benchmark was not too clever. Is there something else out
there that I should analyze?

Thanks,
Ben

Ben Goodrich

unread,
Nov 15, 2010, 5:33:11 PM11/15/10
to sage-devel
On Nov 15, 10:56 am, Ben Goodrich <goodrich....@gmail.com> wrote:
> Thanks for the tip, which seems to have worked. I opened a ticket
> (10268), attached my patch, and uploaded a benchmark.

Now I have a un-minimal example of using GiNaC's normal function that
finishes in about 1 minute when done directly in the GiNaC shell. But
doing it via patched sage / Pynac is taking hours and still not
finishing. Can someone try my patch and help me figure out why there
is such a disparity? Everything is attached at

http://trac.sagemath.org/sage_trac/ticket/10268

Thanks,
Ben

John H Palmieri

unread,
Nov 15, 2010, 6:40:32 PM11/15/10
to sage-devel
On Nov 13, 6:45 pm, kcrisman <kcris...@gmail.com> wrote:
> Maxima has a very large number of very specific types of
> simplifications/expansions.  It allows for quite a bit of control.
> That said, the main reason our Maxima stuff is slow is because we use
> 'pexpect' to communicate with it. Nils Bruin has a patch allowing us
> to "turn on" a library interface (which is now already built inside
> Sage) to Maxima instead; it would be great if someone who knew enough
> about Lisp and whatever else needed would give it a positive review,
> so that we could check such things at the library level.

This is <http://trac.sagemath.org/sage_trac/ticket/7377>, right?

--
John

kcrisman

unread,
Nov 15, 2010, 8:51:21 PM11/15/10
to sage-devel
Yes.
Reply all
Reply to author
Forward
0 new messages