On Thu, Aug 31, 2023 at 8:22 PM Shahriar Iravanian
<
irvani...@gmail.com> wrote:
>
> 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))
By the way, a big problem with heurisch is that it's very sensitive to
the way the derivative of the expression is represented, since that's
how it generates the ansatz. This is fundamental to the approach, but
an issue is that it just directly uses whatever sympy.diff() returns.
This is a big problem for algebraic functions because they can be
represented in multiple different ways, and that representation can
affect the result of integration (a big piece of the "real" Risch
algorithm for algebraic functions is normalizing things so that this
isn't a problem). For example, the derivative of s = sqrt(x) can be
represented as 1/(2*s) or s/(2*x). SymPy happens to use the former
form, because of the way the core combines exponents, but there are
integrals with square roots where heurisch can't find the answer but
would if it used the latter form (not so much because the latter form
is better, although in some ways it is since it's a polynomial in s,
but usually just by dumb luck of the way it generates the ansatz).
>
> 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!
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 also wondering if you've thought about symbolic constants and if
there's any tricks you could do to support them. I think there might
be, especially when still thinking about things in terms of just using
faster linear algebra as a pre-processor to a symbolic solve.
Aaron Meurer
> To view this discussion on the web visit
https://groups.google.com/d/msgid/sympy/c0d397a1-640f-477e-9897-e1157bb6ca67n%40googlegroups.com.