Thank you very much for your comments. 

While hyint ansatz generation is similar in spirit to heurisch, it is less 
rigorous and more 
heuristic. One reason is that the numerical portion of hyint is much more 
forgiving and 
can filter out many undesirable ansatzes (by using QR decomposition to 
remove linearly 
dependent ones and sparse regression to solve the integral). Therefore, we 
can generate 
many different forms of ansatz, which allows hyint to solve integrals 
beyond what 
heurisch can do. 

For example, I use a set of 170 test cases (listed in test.py) to test 
hyint. The current version 
can solve 154 of them; heurisch solves 126 (of course, this list is curated 
for hyint). 

Some integrals that hyint can solve and heurisch cannot:

x/sqrt(x - 1) => 2*x*sqrt(x - 1)/3 + 4*sqrt(x - 1)/3
1/sqrt(x**2 + 4) => asinh(x/2)
sqrt(x)*log(x) => 2*x**(3/2)*log(x)/3 - 4*x**(3/2)/9 
log(log(x))/x => log(x)*log(log(x)) - log(x) 
log(cos(x))*tan(x) => -log(cos(x))**2/2 
sin(x + 1)/(x + 1) => Si(x + 1)
sqrt(1 - sin(x)) => 2*cos(x)/sqrt(1 - sin(x))

Some integrals that heurisch can solve and hyint cannot:

exp(x)/(exp(2*x) - 1) => log(exp(x) - 1)/2 - log(exp(x) + 1)/2
tan(x)**3 => -log(tan(x)**2 + 1)/2 + tan(x)**2/2

> Actually it wouldn't be much work to generalize this to something that
> gives an exact answer at least some of the time.

I completely agree. I believe the main application of hyint is as an ansatz 
discovery
engine rather than a standalone integrator. This is a line of research I'm 
actively
pursuing and would appreciate help, comments, and collaboration!

-- Shahriar 

On Thursday, August 31, 2023 at 6:48:24 PM UTC-4 [email protected] wrote:

> On Thu, Aug 31, 2023 at 5:07 AM Oscar Benjamin
> <[email protected]> wrote:
> >
> > On Tue, 29 Aug 2023 at 07:09, Shahriar Iravanian <[email protected]> 
> wrote:
> > >
> > > Hi All,
> > >
> >
> > Hi Shahriar,
> >
> > > I have uploaded a new package, hyint, to github and PyPi. It is a 
> hybrid (symbolic-numeric) integration package on top of SymPy and 
> numpy/scipy. I would appreciate it if it is added to the list of projects 
> using SymPy.
> > >
> > > You can find it at https://github.com/siravan/hyint or install it as 
> 'pip install hyint'.
> > >
> > > hyint uses an ansatz generation algorithm similar to the 
> Risch-Bronstein poor man's integrator combined with a sparse regression 
> algorithm
> > > adopted from the Sparse identification of nonlinear dynamics (SINDy) 
> to solve indefinite integration problems to univariate expressions. It can 
> solve a large subset of standard elementary integrals despite a very small 
> size (a few hundred lines of code).
> > >
> > > I'm one of the principal contributors to SymbolicNumericIntegartion.jl 
> (https://github.com/SciML/SymbolicNumericIntegration.jl), which is a 
> Julia package for symbolic-numeric integration and is the basis of hyint.
> >
> > This sounds excellent. Yes, you can add it to the list of projects
> > using SymPy using a pull request, I think to the website repo.
> >
> > How exactly is it different from Bronstein's poor man's integrator?
> >
> > SymPy has an integration algorithm called heurisch which is based on
> > the poor man's integrator but uses exact rather than approximate
> > solutions to the linear equations. Is exact vs approximate the main
> > distinction here between what hyint does and what heurisch does?
>
> Judging from the examples, it looks like it
>
> In: hyint.integrate(1 / (x**3 - 2*x + 1), x)
> Out: 2.17082039324994*log(x - 1) + 1.34164078649988*log(x + 1/2 +
> sqrt(5)/2) - 1.17082039324993*log(x**3 - 2*x + 1)
>
> And looking at the code, I'd say a difference is that the Bronstein
> algorithm is more rigorous and general in how it generates its ansatz.
> But actually one of the reasons heurisch() is so slow is that it can
> generate ansatz that are huge (especially when it's given an integrand
> that doesn't have an answer to begin with). Employing some heuristics
> like the ones used here in heurisch could help it out.
>
> Actually it wouldn't be much work to generalize this to something that
> gives an exact answer at least some of the time. For example, you
> could use nsimplify() to guess at exact values for numeric
> coefficients. As long as diff(answer) - integrand symbolically
> simplifies to 0 you know you have a correct answer.
>
> Aaron Meurer
>
> >
> > --
> > 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/CAHVvXxRyJ3FUZ1pN6GACMoHZBYGbUJAavKq5Y1RW5__1nFAT8w%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/c0d397a1-640f-477e-9897-e1157bb6ca67n%40googlegroups.com.

Reply via email to