> I like the idea of using some faster linear algebra as a preprocessor
> to reduce the size of the problem to be solved. You could then take
> the reduced problem and solve it with exact symbolic arithmetic. The
> worst that can happen is you might drop an ansatz that shouldn't have
> been dropped, but you would still always give a symbolically correct
> answer when you do.

I'm testing this idea and it seems to be working fine. I just uploaded a 
new 
version of hyint that exports a `hints(eq, x)` function to return a 
filtered list 
of ansatz for eq. This version accepts expressions with symbolic 
constants. 

The output of hyint.hints() can then be fed to the `hints` argument of 
heurisch as a preprocessor. Example:

>>> from sympy import log
>>> from sympy.integrals.heurisch import heurisch
>>> from sympy.abc import a, x
>>> import hyint   

>>> y = log(log(x) + a) / x

>>> heurisch(y, x)
# returns None, no solution

>>> hints = hyint.hints(y, x)
>>> print(hints)
[log(a + log(x)), log(x)*log(a + log(x)), log(x)]
    
>>> heurisch(y, x, hints=hints)
a*log(a + log(x)) + log(x)*log(a + log(x)) - log(x)
    
Thanks,

Shahriar Iravanian

On Friday, September 1, 2023 at 3:58:27 PM UTC-4 [email protected] wrote:

> On Fri, Sep 1, 2023 at 4:12 AM Oscar Benjamin
> <[email protected]> wrote:
> >
> > On Fri, 1 Sept 2023 at 06:45, Aaron Meurer <[email protected]> wrote:
> > >
> > > I like the idea of using some faster linear algebra as a preprocessor
> > > to reduce the size of the problem to be solved. You could then take
> > > the reduced problem and solve it with exact symbolic arithmetic. The
> > > worst that can happen is you might drop an ansatz that shouldn't have
> > > been dropped, but you would still always give a symbolically correct
> > > answer when you do.
> > >
> > > If heurisch could support much larger, possibly linearly dependent
> > > ansatz, then that would open up a lot of possibilities, like for
> > > instance, trying to use ansatz coming from both sqrt(x) and x/sqrt(x)
> > > simultaneously. But right now it's way too slow even with just the
> > > linear system it generates.
> >
> > I'm not sure if I've interpreted this point correctly but when
> > heurisch is slow it is not usually because of the linear algebra part.
> > Probably that is the easiest part to speed up as well.
>
> Maybe things have changed since the introduction of things like
> DomainMatrix, but when I benchmarked it years ago this was the case.
> That and the fact that it was using the dense poly representation with
> hundreds of variables.
>
> >
> > The slow parts of heurisch are converting back and forth between Expr
> > and the domains, differentiation, and cancel.
> >
> > If heurisch was being rewritten then I think it could be written
> > without the back and forth conversions. The differentiation could be
> > handled in the domain representation. The cancellation could be
> > handled there as well.
>
> We could probably merge a lot of the code in risch and heurisch, but
> loosening the restrictive rigorous code from risch. Actually Risch
> itself can solve some algebraic integrals if the restrictions are
> removed (just the nonelementary integral errors would be incorrect).
>
> >
> > I suspect that heurisch was implemented at a time when SymPy did not
> > have as many of the pieces that it now has that you would want to use
> > to implement the algorithm within the algebra subsystem rather than
> > the symbolic subsystem.
>
> Yes, heurisch predates the polys module. I integrated it with the
> polys back in 2012 or 2013, but I didn't really refactor it in any
> major way.
>
> Aaron Meurer
>
> >
> > Possibly the limiting factor for SymPy implementing heurisch in the
> > ideal way right now is support for symbolic algebraic extensions like
> > Q(x)[sqrt(x)] within the domain system although polys.agca has
> > FiniteMonogenicExtension that could represent that.
> >
> > --
> > Oscar
> >
> > --
> > You received this message because you are subscribed to the Google 
> Groups "sympy" group.
> > To unsubscribe from this group and stop receiving emails from it, send 
> an email to [email protected].
> > To view this discussion on the web visit 
> https://groups.google.com/d/msgid/sympy/CAHVvXxSN%2BVBubjX6i3mq%3DwE7nXZSorg7drnSP_X3-2daxbzE0Q%40mail.gmail.com
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/0025efdb-0dc4-4be0-8897-85c0ea2b50efn%40googlegroups.com.

Reply via email to