The problem is that sqrt(1/x) is not the same as 1/sqrt(x). If you are
working in a situation where it is, you can do integrate(1/sqrt(1 -
x**2), x) and this works.

These algebraic integrals are tricky. They only work with the current
heurisch algorithm "by accident", because they happen to come out to
the right form for it to recognize the antiderivative. But since
algebraic functions have multiple equivalent forms that look
completely different to the algorithm (e.g., sqrt(x)/x == 1/sqrt(x)),
and SymPy's default canonicalization is only based on combining
powers, this doesn't happen in general.

The *right* solution is to implement the algebraic Risch algorithm.
This is a lot of work, though Katja's GSoC project will hopefully
implement some of the needed algorithms in the polys. The workaround
is to modify the heuristics. In heurisch, there is a part that does
some pattern matching and tries to add terms here
https://github.com/sympy/sympy/blob/master/sympy/integrals/heurisch.py#L278.
I suppose we could add a pattern for sqrt(a**2/(a**2 - x**2)) (or
something more general than that). You have to be careful with this,
though, because the more terms you add to the candidate integral, the
more powerful the algorithm becomes, but also, the slower it becomes.

It might also be possible to modify the Meijer G algorithm to work
with this. I don't know enough about how to do this. I think it means
finding and adding some entry to the lookup table (which is currently
http://docs.sympy.org/dev/modules/integrals/g-functions.html#implemented-g-function-formulae).
Tom and/or Raoul can comment more on this approach. Modifying Meijer G
would be preferable to modifying heurisch if it can work, because the
algorithm is not a slow, and it will also automatically make some
definite integrals work.

Aaron Meurer

On Sun, Sep 8, 2013 at 5:14 PM, Ondřej Čertík <[email protected]> wrote:
> Hi,
>
> Currently SymPy can't do this integral:
>
> integrate(sqrt(a**2/(a**2-x**2)), x)
>
> and I reported it here:
>
> https://code.google.com/p/sympy/issues/detail?id=4010
>
> It seems SymPy cannot even do this integral:
>
> integrate(sqrt(1/(1-x**2)), x)
>
> the solution of which is asin(x), at least for real "x".
>
> Any ideas how to "help" sympy do this kind of integral?
>
> Ondrej
>
> --
> 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 post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/sympy.
> For more options, visit https://groups.google.com/groups/opt_out.

-- 
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 post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sympy.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to