Re: [sympy] Hey i was experimenting with sympy trying to find bugs and issues when i was trying to solve a particular integral Sympy was not able to evaluate it

48 views
Skip to first unread message

Sam Blake

unread,
Oct 7, 2026, 5:06:09 AMOct 7
to sy...@googlegroups.com
Here is a solution in sympy using a generalisation of the Parallel (Risch-Norman) for mixed towers of algebraic (simple radical extensions) and transcendental extensions that I published recently: 


$ python3.11

Python 3.11.15 (main, Mar  3 2026, 00:52:57) [Clang 17.0.0 (clang-1700.6.4.2)] on darwin

Type "help", "copyright", "credits" or "license" for more information.

>>> import sympy as sp

>>> from parallel_mixed import Tower, parallel_integrate_mixed as PIM

>>> x = sp.symbols('x', positive=True)

>>> q = 2*x**4 - 2*x**2 + 1

>>> N = (x**2 + 1)/x**3

>>> T = Tower([x], [(sp.S(1), sp.S(0))], q=q)

>>> f = (sp.S(0), sp.cancel(N/q))

>>> I = PIM(f, T)

>>> print(I)

log(x**2 - sqrt(2)*sqrt(2*x**4 - 2*x**2 + 1)/2 + sqrt(2)/2) + log(x**2 + sqrt(2)*sqrt(2*x**4 - 2*x**2 + 1)/2 - 1/2) - log(x**2 + sqrt(2)*sqrt(2*x**4 - 2*x**2 + 1)/2 + sqrt(2)/2) - sqrt(2*x**4 - 2*x**2 + 1)/(2*x**2)

>>> integrand = (x**2 + 1)/(x**3*sp.sqrt(q))

>>> print(sp.N((sp.diff(I, x) - integrand).subs(x, 2), 30))

0.e-166

>>> 


On Tue, Oct 6, 2026 at 5:25 PM Prabhav Puranik <prabhavo...@gmail.com> wrote:
that particular integral was  (x**2 - 1) / (x**3 * sqrt(2*x**4 - 2*x**2 + 1))
it can be solved using pen and paper by a common old trick taking out an x from the sqrt part and dividing in numerator and now we will be left with form   f'/sqrt(f) form which can be easily integrated 

--
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 sympy+un...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/sympy/3baf0b21-ae63-48cc-a7ae-827ec1d00d30n%40googlegroups.com.

Sam Blake

unread,
Oct 7, 2026, 5:15:01 AMOct 7
to sy...@googlegroups.com
Apologies, there was a typo in my numerator. 

$ python3.11 

Python 3.11.15 (main, Mar  3 2026, 00:52:57) [Clang 17.0.0 (clang-1700.6.4.2)] on darwin

Type "help", "copyright", "credits" or "license" for more information.

>>> import sympy as sp

>>> from sympy import sqrt

>>> from build_tower import integrate_surface

>>> x = sp.Symbol('x', positive=True)

>>> f = (x**2 - 1)/(x**3 * sqrt(2*x**4 - 2*x**2 + 1))

>>> F = integrate_surface(f, x)

>>> print(F)

sqrt(2*x**4 - 2*x**2 + 1)/(2*x**2)

>>> sp.simplify(sp.diff(F, x) - f)

0

>>> 

Sangyub Lee

unread,
Oct 7, 2026, 11:30:46 AMOct 7
to sympy
Do you have idea to formalize complete Risch algorithm in Lean4 with AI?

Aaron Meurer

unread,
Oct 7, 2026, 12:48:53 PMOct 7
to sy...@googlegroups.com
This integral is evaluated in the latest git version:

>>> integrate((x**2 - 1) / (x**3 * sqrt(2*x**4 - 2*x**2 + 1)))
-(1 + sqrt(2))/(2*(sqrt(2)*x**2 + sqrt(2*x**4 - 2*x**2 + 1) + 1)) - (1
- sqrt(2))/(2*(sqrt(2)*x**2 + sqrt(2*x**4 - 2*x**2 + 1) - 1))

it can also be integrated to a simpler answer in my risch-algebraic
branch (https://github.com/sympy/sympy/pull/30239):

>>> integrate((x**2 - 1) / (x**3 * sqrt(2*x**4 - 2*x**2 + 1)))
sqrt(2*x**4 - 2*x**2 + 1)/(2*x**2)

Aaron Meurer

On Tue, Oct 6, 2026 at 12:25 AM Prabhav Puranik
Reply all
Reply to author
Forward
0 new messages