https://trac.sagemath.org/ticket/32386 proposes to merge the pynac sources as src/sage/symbolic/ginac into the Sage source tree. This will solve packaging issues and also make it easier for developers to work on symbolics issues.As this is a large change, this ticket will benefit from thorough testing and reviews.
--
You received this message because you are subscribed to the Google Groups "sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sage-devel/fae9f540-d0cc-4a8e-9034-d2bc9ad21074n%40googlegroups.com.
The main problem of pynac is not that the present setup makes it hard to work on symbolic issues, but that Sage depends on it at all.
On Wednesday, 25 August 2021 at 03:19:15 UTC-7 dim...@gmail.com wrote:The main problem of pynac is not that the present setup makes it hard to work on symbolic issues, but that Sage depends on it at all.Aren't these separate issues? It may be the case that we should switch symbolic engine (which is a big job!), but without a candidate that's not something we can plan on right now.
So, it looks to me we're bound to pynac for the foreseeable future. Since sage is the sole user of pynac, any work on pynac will happen in the context of sage. From that perspective, putting the code itself in the sage source seems to make sense. Doing so doesn't preclude throwing it out later (although it might grow other dependencies, making that harder).So, perhaps we should make a quick assessment if moving to another symbolic engine is something that's on the horizon? Sympy has grown ... would that be sufficiently high-performance? (Sage has changed symbolic engines before and it is a huge pain. It will cause all kinds of incompatible changes to happen that are very hard to patch up -- and patching some of them will be very unattractive because backwards-compatibility changes tend to ruin the conceptual consistency of the new solution)
--
You received this message because you are subscribed to the Google Groups "sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sage-devel/a45b37bd-6176-431c-b792-b3b272ea1c6en%40googlegroups.com.
perhaps we should make a quick assessment if moving to another symbolic engine is something that's on the horizon?
On Wed, Aug 25, 2021 at 9:58 AM Dima Pasechnik <dim...@gmail.com> wrote:
> symengine appears to be such a candidate:
> https://symengine.org/
(1 minute thought) That website says that sympy uses symengine as a
backend for speed. In that case, maybe we can switch to sympy more...
and contribute to sympy making better use of symengine, if necessary?
E.g. it looks like integration is not there.
Le jeudi 26 août 2021 à 13:25:50 UTC+2, kcrisman a écrit :
E.g. it looks like integration is not there.If I recall correctly, we use ginac/pynac only for symbolics proper (i.e. not calculus), as well as for differentiation. I don't know if symengine is something to switch to (and Matthias is surely right about developer time, given the amazing and very long effort involved in switching to pynac all these years ago), but integration isn't something to worry about with that. (Whether it's time to start having sympy as default integration engine is another question.)
To which the answer is currently “Hell no ! “ :
sage: import sympy
sage: from sympy import sympify
sage: var("a, b", domain="positive")
(a, b)
sage: dgamma(x, a, b)=x^(a-1)*(1-x)^(b-1)/beta(a, b)
sage: %time integrate(dgamma(x, a, b), x, 0, 1)
CPU times: user 5.34 ms, sys: 0 ns, total: 5.34 ms
Wall time: 5.54 ms
1
sage: %time sympy.integrate(*map(sympify, (dgamma(x, a, b).subs({a:a+1, b:b+1}), (x, 0, 1)))).simplify()._sage_().subs({a:a-1, b:b-1})
CPU times: user 2.08 s, sys: 10 µs, total: 2.08 s
Wall time: 2.08 s
1
sage: %time integrate(x*dgamma(x, a, b), x, 0, 1).simplify_factorial()
CPU times: user 30.9 ms, sys: 0 ns, total: 30.9 ms
Wall time: 31.1 ms
a/(a + b)
sage: %time sympy.integrate(*map(sympify, (x*dgamma(x, a, b).subs({a:a+1, b:b+1}), (x, 0, 1)))).simplify()._sage_().subs({a:a-1, b:b-1})
CPU times: user 2.72 s, sys: 3 µs, total: 2.72 s
Wall time: 2.72 s
a/(a + b)
sage: %time integrate((x-(a/(a+b)))^2*dgamma(x, a, b), x, 0, 1).simplify_full()
CPU times: user 398 ms, sys: 0 ns, total: 398 ms
Wall time: 312 ms
a*b/(a^3 + (3*a + 1)*b^2 + b^3 + a^2 + (3*a^2 + 2*a)*b)
sage: %time sympy.integrate(*map(sympify, ((x-(a/(a+b)))^2*dgamma(x, a, b).subs({a:a+1, b:b+1}), (x, 0, 1)))).simplify()._sage_().subs({a:a-1, b:b-1})
CPU times: user 30.5 s, sys: 4.03 ms, total: 30.5 s
Wall time: 30.5 s
((a - 1)^2*(b - 1) + (a - 1)*(b - 1)^2 + 2*(a - 1)^2 - 2*(a - 1)*(b - 1) + 2*(b - 1)^2)/((a + b + 1)*(a + b)*(a + b - 2)^2)
and sympy.integrate(*map(sympify, (dgamma(x, a, b), (x, 0, 1)))).simplify()._sage_()
never returns. Res ipsa loquitur…
BTW : many Sympy integrations result in Sympy’s Piecewise
expressions (correctly transcripted as Sage’s cases
) involving logical expressions using Sympy’s symbolic logical functions/operators And
, Or
and Not
, which have currently no equivalent in Sage (but see Trac#31911…)
To view this discussion on the web visit https://groups.google.com/d/msgid/sage-devel/CACLE5GBhpFYXvbfqE8u-AU42cdDN8dQP320znbPHRkvivPXVRA%40mail.gmail.com.
On Fri, Aug 27, 2021 at 2:21 AM Dima Pasechnik <dim...@gmail.com> wrote:
> How are these integrals above computed by Sage? Via Maxima, or in some
> other way?
When I implemented this, they were all computed in Maxima by default,
unless otherwise requested. Thus symbolic integration may be
orthogonal to the pynac vs symengine discussion. You can browse some
of the beautiful decades(!) old Maxima lisp code for integration
starting here:
https://github.com/andrejv/maxima/blob/master/src/defint.lisp
I'm cc'ing RJF in case he has some perspective to add.
Pynac has a lot of I think nontrivial efficient hooks back into Sage
for working with various data types, and doing things like equality
testing, fast evaluation of expression (fast_float, etc.), so it'll be
quite a lot of work to switch away from. I created pynac as a fork
of ginac only because there was a very talented student trying for a
year to do something similar more from scratch in Cython, and I got
impatient. It's too bad pynac is unmaintained now; I think the basic
idea wasn't so bad, and the performance was pretty good.
-- William
> > and sympy.integrate(*map(sympify, (dgamma(x, a, b), (x, 0, 1)))).simplify()._sage_() never returns. Res ipsa loquitur…
> >
> > BTW : many Sympy integrations result in Sympy’s Piecewise expressions (correctly transcripted as Sage’s cases) involving logical expressions using Sympy’s symbolic logical functions/operators And, Or and Not, which have currently no equivalent in Sage (but see Trac#31911…)
> >
> > --
> > You received this message because you are subscribed to the Google Groups "sage-devel" group.
> > To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+...@googlegroups.com.
> > To view this discussion on the web visit https://groups.google.com/d/msgid/sage-devel/eb1cfbc2-3339-4031-8e24-fc0ceca307ben%40googlegroups.com.
>
> --
> You received this message because you are subscribed to the Google Groups "sage-devel" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/sage-devel/CAAWYfq0kcukS4RfSJ4oaxNM0yZHt3n5zFvdGk%2BuRr34M6YZ2SA%40mail.gmail.com.
--
William (http://wstein.org)
--
You received this message because you are subscribed to the Google Groups "sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sage-devel/CACLE5GBhpFYXvbfqE8u-AU42cdDN8dQP320znbPHRkvivPXVRA%40mail.gmail.com.
Hello Isuru -- thanks for popping in to comment!
On Fri, Aug 27, 2021 at 10:56 AM Isuru Fernando <isu...@gmail.com> wrote:
>
> Hi,
>
> A SymEngine maintainer here.
>
> > Pynac has a lot of I think nontrivial efficient hooks back into Sage
> for working with various data types, and doing things like equality
> testing, fast evaluation of expression (fast_float, etc.),
>
> With SymEngine, we do have fast evaluation of expressions with
> several backends. One backend is LLVM, where we compile the function
> using LLVM and generate a callable C function using that.
Wow, that's very cool. Do you know how it compares to Sage's
fast_float and fast_callable "compilers" in terms of speed? Sage's
don't actually depend on having LLVM installed (they aren't compiling
to machine code), so I assume might be significantly slower, except
that the people (=Robert Bradshaw) who wrote them are very clever, so
you never know. It's probably also interesting to benchmark the
compile time itself.
Do you know how it compares to Sage's
fast_float and fast_callable "compilers" in terms of speed?
> How are these integrals above computed by Sage? Via Maxima, or in some
> other way?
When I implemented this, they were all computed in Maxima by default,
unless otherwise requested. Thus symbolic integration may be
orthogonal to the pynac vs symengine discussion.