I use sagemath to run the independent CAS integrations tests for Fricas, 
Giac and Maxima, since it is much easier to use the same script to all CAS 
systems instead of learning how to use each separate CAS. The result is put 
on this page <https://12000.org/my_notes/CAS_integration_tests/index.htm>.

I found that sympy now can be used from sagemath. 

So I said, great. Instead of having separate script for sympy in python 
will use the same sagemath script and just change the name of the algorithm 
to 'sympy'. Makes life easier.

But when I tried this on one test file, I found many integrals now fail, 
where they work using sympy directly in Python.

I am not sure if this is because sympy is not yet fully yet supported in 
sagemath or if this is just a bug and overlooked support.  

For example, on this one file,  sympy used to score 84.66% passing score 
when used directly, but now in sagemath it scores 65.64%.  

This translates to about 30 more integrals failing in this file of 163 
integrals.

Below will give one example. All seem to give the same exception

NotImplementedError('conversion to SageMath is not implemented')

Here is one example in sagemath 9.8

var('A B a alpha b beta m n x ')
integrate(x/((b*x^2+a)^m),x, algorithm='sympy')

---------------------------------------------------------------------------
NotImplementedError                       Traceback (most recent call last)
Cell In [2], line 1
----> 1 integrate(x/(b*x**Integer(3)+a)**Integer(2),x, algorithm='sympy')

File ~/TMP/sage-9.8/src/sage/misc/functional.py:773, in integral(x, *args, 
**kwds)
    648 """
    649 Return an indefinite or definite integral of an object ``x``.
    650 
   (...)
    770 
    771 """
    772 if hasattr(x, 'integral'):
--> 773     return x.integral(*args, **kwds)
    774 else:
    775     from sage.symbolic.ring import SR

File ~/TMP/sage-9.8/src/sage/symbolic/expression.pyx:13211, in 
sage.symbolic.expression.Expression.integral()
  13209                 R = SR
  13210         return R(integral(f, v, a, b, **kwds))
> 13211     return integral(self, *args, **kwds)
  13212 
  13213 integrate = integral

File ~/TMP/sage-9.8/src/sage/symbolic/integration/integral.py:1063, in 
integrate(expression, v, a, b, algorithm, hold)
   1061     if not integrator:
   1062         raise ValueError("Unknown algorithm: %s" % algorithm)
-> 1063     return integrator(expression, v, a, b)
   1064 if a is None:
   1065     return indefinite_integral(expression, v, hold=hold)

File ~/TMP/sage-9.8/src/sage/symbolic/integration/external.py:69, in 
sympy_integrator(expression, v, a, b)
     67 else:
     68     result = sympy.integrate(ex, (v, a._sympy_(), b._sympy_()))
---> 69 return result._sage_()

File ~/TMP/sage-9.8/src/sage/interfaces/sympy.py:216, in 
_sympysage_add(self)
    214 s = 0
    215 for x in self.args:
--> 216     s += x._sage_()
    217 return s

File 
~/TMP/sage-9.8/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages/sympy/core/basic.py:1959,
 
in Basic._sage_(self)
   1957 sympy_init()  # may monkey-patch _sage_ method into self's class or 
superclasses
   1958 if old_method == self._sage_:
-> 1959     raise NotImplementedError('conversion to SageMath is not 
implemented')
   1960 else:
   1961     # call the freshly monkey-patched method
   1962     return self._sage_()


Here is same integral in sympy itself. You see it works.

>python
Python 3.10.9 (main, Dec 19 2022, 17:35:49) [GCC 12.2.0] on linux
>>> from sympy import *
>>> A,B,a,alpha,b,beta,m,n,x= symbols('A B a alpha b beta m n x ')
>>> integrate(x/(b*x**3+a)**2,x)

x**2/(3*a**2 + 3*a*b*x**3) + RootSum(729*_t**3*a**4*b**2 + 1, Lambda(_t, 
_t*log(81*_t**2*a**3*b + x)))


The sympy version is 1.11.1 in both cases, all on Linux.

age: ver = installed_packages()
sage: ver['sympy']
'1.11.1'

Will give the list of failed integrals in this one file in a follow up post.

--Nasser




-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-devel/f756dced-6c0b-41cd-b510-6df90906629an%40googlegroups.com.

Reply via email to