Opened 10 years ago

Last modified 18 months ago

#5930 closed enhancement

switch from maxima to pynac for core symbolic manipulation system — at Version 5

Reported by: was Owned by: tbd
Priority: blocker Milestone: sage-4.0
Component: symbolics Keywords:
Cc: burcin Merged in:
Authors: Reviewers:
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Description (last modified by was)

SEE http://wiki.sagemath.org/symbolics/pynac_todo/push

If you want to try the code out do this:

  1. Install sage-3.4.2.
  1. Build pynac (should take about 3-5 minutes):
    ./sage -i http://sage.math.washington.edu/home/mhansen/symbolics/pynac-0.1.6-mh.spkg
    
  1. Apply the two patches at http://sage.math.washington.edu/home/mhansen/symbolics/
    sage: hg_sage.apply('http://sage.math.washington.edu/home/mhansen/symbolics/symbolics_1.patch')
    sage: hg_sage.apply('http://sage.math.washington.edu/home/mhansen/symbolics/symbolics_2.patch')
    

Just check in each with some random comment.

  1. Delete all traces of constants.so:
    rm devel/sage/build/*/sage/symbolic/constants*
    rm devel/sage/build/sage/symbolic/constants.so
    
  1. Build with "sage -br", and it should work. Building will take a while, since the patches touch many files.

Change History (5)

comment:1 Changed 10 years ago by burcin

  • Cc burcin added
  • Component changed from algebra to symbolics

comment:2 Changed 10 years ago by was

  • Description modified (diff)

Bug/Issue?: Control-C doesn't work in some cases.

----------------------------------------------------------------------
| Sage Version 3.4.2, Release Date: 2009-05-05                       |
| Type notebook() for the GUI, and license() for information.        |
----------------------------------------------------------------------
sage: var('x,y,z')
(x, y, z)
sage: time f = (x+y+z)^5
CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s
Wall time: 0.00 s
sage: g = f*(f+1)
sage: timeit('g.expand()')
5 loops, best of 3: 53.2 ms per loop
sage: %prun g.expand()
         8890 function calls in 0.069 CPU seconds

   Ordered by: internal time

   ncalls  tottime  percall  cumtime  percall filename:lineno(function)
        1    0.065    0.065    0.069    0.069 {method 'expand' of 'sage.symbolic.expression.Expression' objects}
     8863    0.003    0.000    0.003    0.000 functional.py:393(imag)
        1    0.000    0.000    0.069    0.069 <string>:1(<module>)
        4    0.000    0.000    0.000    0.000 arith.py:1140(gcd)
        4    0.000    0.000    0.000    0.000 {method 'lcm' of 'sage.structure.element.PrincipalIdealDomainElement' objects}
        4    0.000    0.000    0.000    0.000 arith.py:1256(lcm)
        4    0.000    0.000    0.000    0.000 {method 'gcd' of 'sage.rings.integer.Integer' objects}
        8    0.000    0.000    0.000    0.000 {hasattr}
        1    0.000    0.000    0.000    0.000 {method 'disable' of '_lsprof.Profiler' objects}

sage: %prun v = [g.expand() for _ in range(1000)]
^CException exceptions.KeyboardInterrupt: KeyboardInterrupt() in 'sage.symbolic.pynac.py_is_real' ignored
^CException exceptions.KeyboardInterrupt: KeyboardInterrupt() in 'sage.symbolic.pynac.py_is_real' ignored
^CException exceptions.KeyboardInterrupt: KeyboardInterrupt() in 'sage.symbolic.pynac.py_is_real' ignored

comment:3 Changed 10 years ago by was

  • Description modified (diff)

comment:4 Changed 10 years ago by was

There is a sequence of *serious* speed regressions that I think Burcin caused by changes to the pynac spkg:

IN SAGE-3.2 we get OK timings for this benchmarks. They aren't great, but I can live with them, since it is"only" 57 times slower than Singular:

sage: var('x,y,z', ns=1); f = (x+y+z)^6;
sage: timeit('(f*(f+1)).expand()')
125 loops, best of 3: 3.25 ms per loop

In Singular:

sage: R.<x,y,z> = QQ[]
sage: timeit('g=(x+y+z)^6*((x+y+z)^6+1)')
625 loops, best of 3: 56.3 µs per loop
sage: 3250/56.3
57.7264653641208

It's hard to tell, but Mathematica seems to take about 1.7ms, which is comparable to the above:

sage: timeit("s=mathematica('Expand[(x+y+z)^6*((x+y+z)^6+1)]')")
125 loops, best of 3: 1.81 ms per loop
sage: timeit("s=mathematica('2+3')")
625 loops, best of 3: 125 µs per loop

Maxima via Sage takes about 61 ms, since I guess (c)lisp is slow, etc.:

sage: timeit("s=maxima('expand((x+y+z)^6*((x+y+z)^6+1))')")
5 loops, best of 3: 61.8 ms per loop

First there was a MAJOR unacceptable speed regression going to sage-3.3 (this is probably all caused by the pynac spkg). The timing jumped all the way to 42ms, so now it's almost as bad as Maxima:

sage: var('x,y,z', ns=1); f = (x+y+z)^6
(x, y, z)
sage: timeit('(f*(f+1)).expand()')
5 loops, best of 3: 42.1 ms per loop

In fact, directly in sage-3.2 with old Maxima symbolics:

sage: var('x,y,z', ns=0); f = (x+y+z)^6
sage: timeit('(f*(f+1)).expand()')
5 loops, best of 3: 106 ms per loop

IN SAGE-3.4.2 with new symbolics:

sage: var('x,y,z', ns=1); f = (x+y+z)^6
(x, y, z)
sage: timeit('(f*(f+1)).expand()')
5 loops, best of 3: 206 ms per loop

This may be due to a change in the pynac layer, where it is calling out to Python for some reason, even though it shouldn't need to. 206ms is really unacceptable. It's much slower than Maxima itself, it's 63 times slower than Pynac *was* just a few months ago, and it's 367 times slower than Singular.

comment:5 Changed 10 years ago by was

  • Description modified (diff)
Note: See TracTickets for help on using tickets.