[GiNaC-list] [sage-devel] Re: GiNaC as the symbolic manipulation engine in Sage

Burcin Erocal burcin at erocal.org
Mon Aug 11 12:41:43 CEST 2008


On Mon, 11 Aug 2008 02:37:40 -0700
"William Stein" <wstein at gmail.com> wrote:

> 
> On Mon, Aug 11, 2008 at 1:30 AM, Burcin Erocal <burcin at erocal.org> wrote:
<snip>
> >
> > At the ACA'08 conference, I've met some physicists using GiNaC
> > (http://www.ginac.de/), a C++ library that provides symbolic
> > manipulation and pattern matching facilities. Its lastest release was
> > on Apr 04 2008, it also has extensive documentation, and active mailing
> > lists. I wrote a basic Cython wrapper to benchmark its performance.
> > Here are the numbers:
> >
> > sage: var("x y z",ns=1)
> > (x, y, z)
> > sage: a = (x+y)^2
> > sage: %time t = sum( [a^i for i in xrange(10000)] )
> > CPU times: user 1.83 s, sys: 0.00 s, total: 1.83 s
> > Wall time: 1.83 s
> 
> This benchmark might be lame. Even the current "insanely slow"
> maxima-based symbolics in Sage seem to do better than what you
> just wrote above:
> 
> sage: var('x,y')
> (x, y)
> sage: a = (x+y)^2
> sage: time t = sum(a^i for i in xrange(10000))
> CPU times: user 0.51 s, sys: 0.03 s, total: 0.54 s
> Wall time: 0.55 s
> 
> and
> 
> sage: var('y,z'); b = (y+z)^2
> sage: time t = sum([a^i*b^j for i in xrange(1,200,5) for j in
> xrange(1, 300,  3)] )
> CPU times: user 0.30 s, sys: 0.01 s, total: 0.31 s
> Wall time: 0.32 s
> 
> That's because the benchmark is maybe testing nothing
> but memory allocation.

Your benchmark doesn't call maxima at all. When you quit Sage after
these lines, there is no 

Exiting spawned Maxima process.

notice printed.


> I have seen a lot of *real* benchmarks involving symbolic calculus
> when sad users and students come to me and ask why their code
> is 1000 times slower than Mathematica.  This happened a *few* times
> today at Sage Days 9 today.  It also comes up in sage-support all
> the time.  I really need to come up with a large list of specific examples
> like this, since I'm getting way too confused by benchmarks.

I couldn't find any standard benchmarks, and had to come up with the
one above. I think it is reflects some aspect of performance, as the
power operator is very similar to a symbolic function application, and
the system has to do a basic simplification like

((x+y)^2)^i = (x+y)^(2*i)

for each step.


Cheers,

Burcin


More information about the GiNaC-list mailing list