I noticed one test file I have that all intergate problems fail when using Fricas. But these work when using Fricas directly.
I do not know now if these issues are known or not.
Here are some examples. Most give TypeError TypeError: unsupported operand parent(s) for *: 'Integer Ring' and '<class 'function'>'
and TypeError: unsupported operand type(s) for *: 'function' and 'sage.symbolic.expression.Expression'
Yet the same exact input works with no problem in Fricas. I am using Fricas 1.3.6 on Linux (via sagemath 9.3)
Example 1
sage: var('x d b c a D C A B')
(x, d, b, c, a, D, C, A, B)
sage: integrate((b*x+a)^2*(D*x^3+C*x^2+B*x+A)/(d*x+c),x, algorithm="fricas")
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-48-ea922a26bbb0> in <module>
----> 1 integrate((b*x+a)**Integer(2)*(D*x**Integer(3)+C*x**Integer(2)+B*x+A)/(d*x+c),x, algorithm="fricas")
/usr/lib/python3.9/site-packages/sage/misc/functional.py in integral(x, *args, **kwds)
757 """
758 if hasattr(x, 'integral'):
--> 759 return x.integral(*args, **kwds)
760 else:
761 from sage.symbolic.ring import SR
/usr/lib/python3.9/site-packages/sage/symbolic/expression.pyx in sage.symbolic.expression.Expression.integral (build/cythonized/sage/symbolic/expression.cpp:66867)()
12645 R = SR
12646 return R(integral(f, v, a, b, **kwds))
> 12647 return integral(self, *args, **kwds)
12648
12649 integrate = integral
/usr/lib/python3.9/site-packages/sage/symbolic/integration/integral.py in integrate(expression, v, a, b, algorithm, hold)
988 if not integrator:
989 raise ValueError("Unknown algorithm: %s" % algorithm)
--> 990 return integrator(expression, v, a, b)
991 if a is None:
992 return indefinite_integral(expression, v, hold=hold)
/usr/lib/python3.9/site-packages/sage/symbolic/integration/external.py in fricas_integrator(expression, v, a, b, noPole)
409 result = ex.integrate(seg)
410
--> 411 result = result.sage()
412
413 if result == "failed":
/usr/lib/python3.9/site-packages/sage/interfaces/interface.py in sage(self, *args, **kwds)
1090 [0 0]
1091 """
-> 1092 return self._sage_(*args, **kwds)
1093
1094 def __repr__(self):
/usr/lib/python3.9/site-packages/sage/interfaces/fricas.py in _sage_(self)
1966 # we treat Expression Integer and Expression Complex
1967 # Integer just the same
-> 1968 return FriCASElement._sage_expression(P.get_InputForm(self._name))
1969
1970 if head == 'DistributedMultivariatePolynomial':
/usr/lib/python3.9/site-packages/sage/interfaces/fricas.py in _sage_expression(fricas_InputForm)
1654 register_symbol(convert_rootOf, {'fricas': 'rootOf'})
1655
-> 1656 ex, _ = FriCASElement._parse_and_eval(fricas_InputForm)
1657 # postprocessing of rootOf
1658 from sage.rings.all import QQbar, PolynomialRing
/usr/lib/python3.9/site-packages/sage/interfaces/fricas.py in _parse_and_eval(s, start)
1233
1234 if s[a] == FriCASElement._LEFTBRACKET:
-> 1235 return FriCASElement._parse_list(s, start=a)
1236 elif s[a] == FriCASElement._STRINGMARKER:
1237 return FriCASElement._parse_string(s, start=a)
/usr/lib/python3.9/site-packages/sage/interfaces/fricas.py in _parse_list(s, start)
1275 args = []
1276 while s[a] != FriCASElement._RIGHTBRACKET:
-> 1277 e, a = FriCASElement._parse_and_eval(s, start=a)
1278 args.append(e)
1279 a += 1
/usr/lib/python3.9/site-packages/sage/interfaces/fricas.py in _parse_and_eval(s, start)
1233
1234 if s[a] == FriCASElement._LEFTBRACKET:
-> 1235 return FriCASElement._parse_list(s, start=a)
1236 elif s[a] == FriCASElement._STRINGMARKER:
1237 return FriCASElement._parse_string(s, start=a)
/usr/lib/python3.9/site-packages/sage/interfaces/fricas.py in _parse_list(s, start)
1275 args = []
1276 while s[a] != FriCASElement._RIGHTBRACKET:
-> 1277 e, a = FriCASElement._parse_and_eval(s, start=a)
1278 args.append(e)
1279 a += 1
/usr/lib/python3.9/site-packages/sage/interfaces/fricas.py in _parse_and_eval(s, start)
1233
1234 if s[a] == FriCASElement._LEFTBRACKET:
-> 1235 return FriCASElement._parse_list(s, start=a)
1236 elif s[a] == FriCASElement._STRINGMARKER:
1237 return FriCASElement._parse_string(s, start=a)
/usr/lib/python3.9/site-packages/sage/interfaces/fricas.py in _parse_list(s, start)
1275 args = []
1276 while s[a] != FriCASElement._RIGHTBRACKET:
-> 1277 e, a = FriCASElement._parse_and_eval(s, start=a)
1278 args.append(e)
1279 a += 1
/usr/lib/python3.9/site-packages/sage/interfaces/fricas.py in _parse_and_eval(s, start)
1233
1234 if s[a] == FriCASElement._LEFTBRACKET:
-> 1235 return FriCASElement._parse_list(s, start=a)
1236 elif s[a] == FriCASElement._STRINGMARKER:
1237 return FriCASElement._parse_string(s, start=a)
/usr/lib/python3.9/site-packages/sage/interfaces/fricas.py in _parse_list(s, start)
1275 args = []
1276 while s[a] != FriCASElement._RIGHTBRACKET:
-> 1277 e, a = FriCASElement._parse_and_eval(s, start=a)
1278 args.append(e)
1279 a += 1
/usr/lib/python3.9/site-packages/sage/interfaces/fricas.py in _parse_and_eval(s, start)
1233
1234 if s[a] == FriCASElement._LEFTBRACKET:
-> 1235 return FriCASElement._parse_list(s, start=a)
1236 elif s[a] == FriCASElement._STRINGMARKER:
1237 return FriCASElement._parse_string(s, start=a)
/usr/lib/python3.9/site-packages/sage/interfaces/fricas.py in _parse_list(s, start)
1275 args = []
1276 while s[a] != FriCASElement._RIGHTBRACKET:
-> 1277 e, a = FriCASElement._parse_and_eval(s, start=a)
1278 args.append(e)
1279 a += 1
/usr/lib/python3.9/site-packages/sage/interfaces/fricas.py in _parse_and_eval(s, start)
1233
1234 if s[a] == FriCASElement._LEFTBRACKET:
-> 1235 return FriCASElement._parse_list(s, start=a)
1236 elif s[a] == FriCASElement._STRINGMARKER:
1237 return FriCASElement._parse_string(s, start=a)
/usr/lib/python3.9/site-packages/sage/interfaces/fricas.py in _parse_list(s, start)
1275 args = []
1276 while s[a] != FriCASElement._RIGHTBRACKET:
-> 1277 e, a = FriCASElement._parse_and_eval(s, start=a)
1278 args.append(e)
1279 a += 1
/usr/lib/python3.9/site-packages/sage/interfaces/fricas.py in _parse_and_eval(s, start)
1233
1234 if s[a] == FriCASElement._LEFTBRACKET:
-> 1235 return FriCASElement._parse_list(s, start=a)
1236 elif s[a] == FriCASElement._STRINGMARKER:
1237 return FriCASElement._parse_string(s, start=a)
/usr/lib/python3.9/site-packages/sage/interfaces/fricas.py in _parse_list(s, start)
1275 args = []
1276 while s[a] != FriCASElement._RIGHTBRACKET:
-> 1277 e, a = FriCASElement._parse_and_eval(s, start=a)
1278 args.append(e)
1279 a += 1
/usr/lib/python3.9/site-packages/sage/interfaces/fricas.py in _parse_and_eval(s, start)
1233
1234 if s[a] == FriCASElement._LEFTBRACKET:
-> 1235 return FriCASElement._parse_list(s, start=a)
1236 elif s[a] == FriCASElement._STRINGMARKER:
1237 return FriCASElement._parse_string(s, start=a)
/usr/lib/python3.9/site-packages/sage/interfaces/fricas.py in _parse_list(s, start)
1275 args = []
1276 while s[a] != FriCASElement._RIGHTBRACKET:
-> 1277 e, a = FriCASElement._parse_and_eval(s, start=a)
1278 args.append(e)
1279 a += 1
/usr/lib/python3.9/site-packages/sage/interfaces/fricas.py in _parse_and_eval(s, start)
1233
1234 if s[a] == FriCASElement._LEFTBRACKET:
-> 1235 return FriCASElement._parse_list(s, start=a)
1236 elif s[a] == FriCASElement._STRINGMARKER:
1237 return FriCASElement._parse_string(s, start=a)
/usr/lib/python3.9/site-packages/sage/interfaces/fricas.py in _parse_list(s, start)
1275 args = []
1276 while s[a] != FriCASElement._RIGHTBRACKET:
-> 1277 e, a = FriCASElement._parse_and_eval(s, start=a)
1278 args.append(e)
1279 a += 1
/usr/lib/python3.9/site-packages/sage/interfaces/fricas.py in _parse_and_eval(s, start)
1233
1234 if s[a] == FriCASElement._LEFTBRACKET:
-> 1235 return FriCASElement._parse_list(s, start=a)
1236 elif s[a] == FriCASElement._STRINGMARKER:
1237 return FriCASElement._parse_string(s, start=a)
/usr/lib/python3.9/site-packages/sage/interfaces/fricas.py in _parse_list(s, start)
1275 args = []
1276 while s[a] != FriCASElement._RIGHTBRACKET:
-> 1277 e, a = FriCASElement._parse_and_eval(s, start=a)
1278 args.append(e)
1279 a += 1
/usr/lib/python3.9/site-packages/sage/interfaces/fricas.py in _parse_and_eval(s, start)
1233
1234 if s[a] == FriCASElement._LEFTBRACKET:
-> 1235 return FriCASElement._parse_list(s, start=a)
1236 elif s[a] == FriCASElement._STRINGMARKER:
1237 return FriCASElement._parse_string(s, start=a)
/usr/lib/python3.9/site-packages/sage/interfaces/fricas.py in _parse_list(s, start)
1278 args.append(e)
1279 a += 1
-> 1280 return fun(*args), a
1281
1282 @staticmethod
/usr/lib/python3.9/site-packages/sage/interfaces/fricas.py in <lambda>(x, y)
1600 register_symbol(lambda x, y: x + y, {'fricas': '+'})
1601 register_symbol(lambda x, y: x - y, {'fricas': '-'})
-> 1602 register_symbol(lambda x, y: x * y, {'fricas': '*'})
1603 register_symbol(lambda x, y: x / y, {'fricas': '/'})
1604 register_symbol(lambda x, y: x ** y, {'fricas': '^'})
/usr/lib/python3.9/site-packages/sage/rings/integer.pyx in sage.rings.integer.Integer.__mul__ (build/cythonized/sage/rings/integer.c:14021)()
1980 return y
1981
-> 1982 return coercion_model.bin_op(left, right, operator.mul)
1983
1984 cpdef _mul_(self, right):
/usr/lib/python3.9/site-packages/sage/structure/coerce.pyx in sage.structure.coerce.CoercionModel.bin_op (build/cythonized/sage/structure/coerce.c:11710)()
1246 # We should really include the underlying error.
1247 # This causes so much headache.
-> 1248 raise bin_op_exception(op, x, y)
1249
1250 cpdef canonical_coercion(self, x, y):
TypeError: unsupported operand parent(s) for *: 'Integer Ring' and '<class 'function'>'
sage:
Example 2
sage: integrate((D*x^3+C*x)/x,x, algorithm="fricas")
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-46-cd8aba19a8a6> in <module>
----> 1 integrate((D*x**Integer(3)+C*x)/x,x, algorithm="fricas")
/usr/lib/python3.9/site-packages/sage/misc/functional.py in integral(x, *args, **kwds)
757 """
758 if hasattr(x, 'integral'):
--> 759 return x.integral(*args, **kwds)
760 else:
761 from sage.symbolic.ring import SR
/usr/lib/python3.9/site-packages/sage/symbolic/expression.pyx in sage.symbolic.expression.Expression.integral (build/cythonized/sage/symbolic/expression.cpp:66867)()
12645 R = SR
12646 return R(integral(f, v, a, b, **kwds))
> 12647 return integral(self, *args, **kwds)
12648
12649 integrate = integral
/usr/lib/python3.9/site-packages/sage/symbolic/integration/integral.py in integrate(expression, v, a, b, algorithm, hold)
988 if not integrator:
989 raise ValueError("Unknown algorithm: %s" % algorithm)
--> 990 return integrator(expression, v, a, b)
991 if a is None:
992 return indefinite_integral(expression, v, hold=hold)
/usr/lib/python3.9/site-packages/sage/symbolic/integration/external.py in fricas_integrator(expression, v, a, b, noPole)
409 result = ex.integrate(seg)
410
--> 411 result = result.sage()
412
413 if result == "failed":
/usr/lib/python3.9/site-packages/sage/interfaces/interface.py in sage(self, *args, **kwds)
1090 [0 0]
1091 """
-> 1092 return self._sage_(*args, **kwds)
1093
1094 def __repr__(self):
/usr/lib/python3.9/site-packages/sage/interfaces/fricas.py in _sage_(self)
1966 # we treat Expression Integer and Expression Complex
1967 # Integer just the same
-> 1968 return FriCASElement._sage_expression(P.get_InputForm(self._name))
1969
1970 if head == 'DistributedMultivariatePolynomial':
/usr/lib/python3.9/site-packages/sage/interfaces/fricas.py in _sage_expression(fricas_InputForm)
1654 register_symbol(convert_rootOf, {'fricas': 'rootOf'})
1655
-> 1656 ex, _ = FriCASElement._parse_and_eval(fricas_InputForm)
1657 # postprocessing of rootOf
1658 from sage.rings.all import QQbar, PolynomialRing
/usr/lib/python3.9/site-packages/sage/interfaces/fricas.py in _parse_and_eval(s, start)
1233
1234 if s[a] == FriCASElement._LEFTBRACKET:
-> 1235 return FriCASElement._parse_list(s, start=a)
1236 elif s[a] == FriCASElement._STRINGMARKER:
1237 return FriCASElement._parse_string(s, start=a)
/usr/lib/python3.9/site-packages/sage/interfaces/fricas.py in _parse_list(s, start)
1275 args = []
1276 while s[a] != FriCASElement._RIGHTBRACKET:
-> 1277 e, a = FriCASElement._parse_and_eval(s, start=a)
1278 args.append(e)
1279 a += 1
/usr/lib/python3.9/site-packages/sage/interfaces/fricas.py in _parse_and_eval(s, start)
1233
1234 if s[a] == FriCASElement._LEFTBRACKET:
-> 1235 return FriCASElement._parse_list(s, start=a)
1236 elif s[a] == FriCASElement._STRINGMARKER:
1237 return FriCASElement._parse_string(s, start=a)
/usr/lib/python3.9/site-packages/sage/interfaces/fricas.py in _parse_list(s, start)
1275 args = []
1276 while s[a] != FriCASElement._RIGHTBRACKET:
-> 1277 e, a = FriCASElement._parse_and_eval(s, start=a)
1278 args.append(e)
1279 a += 1
/usr/lib/python3.9/site-packages/sage/interfaces/fricas.py in _parse_and_eval(s, start)
1233
1234 if s[a] == FriCASElement._LEFTBRACKET:
-> 1235 return FriCASElement._parse_list(s, start=a)
1236 elif s[a] == FriCASElement._STRINGMARKER:
1237 return FriCASElement._parse_string(s, start=a)
/usr/lib/python3.9/site-packages/sage/interfaces/fricas.py in _parse_list(s, start)
1278 args.append(e)
1279 a += 1
-> 1280 return fun(*args), a
1281
1282 @staticmethod
/usr/lib/python3.9/site-packages/sage/interfaces/fricas.py in <lambda>(x, y)
1600 register_symbol(lambda x, y: x + y, {'fricas': '+'})
1601 register_symbol(lambda x, y: x - y, {'fricas': '-'})
-> 1602 register_symbol(lambda x, y: x * y, {'fricas': '*'})
1603 register_symbol(lambda x, y: x / y, {'fricas': '/'})
1604 register_symbol(lambda x, y: x ** y, {'fricas': '^'})
TypeError: unsupported operand type(s) for *: 'function' and 'sage.symbolic.expression.Expression'
sage:
I have many many more such examples. Here is the same examples above, run inside Fricas directly. You can see they work there.
(3) -> ii:=integrate((b*x+a)^3*(D*x^3+C*x^2+B*x+A)/(d*x+c)^(1/2),x);
Type: Union(Expression(Integer),...)
(4) -> unparse(ii::InputForm)
"((6930*D*b^3*d^6*x^6+((8190*C*b^3+24570*D*a*b^2)*d^6+(-7560)*D*b^3*c*d^5)*x^
5+((10010*B*b^3+30030*C*a*b^2+30030*D*a^2*b)*d^6+((-9100)*C*b^3+(-27300)*D*a*
b^2)*c*d^5+8400*D*b^3*c^2*d^4)*x^4+((12870*A*b^3+38610*B*a*b^2+38610*C*a^2*b+
12870*D*a^3)*d^6+((-11440)*B*b^3+(-34320)*C*a*b^2+(-34320)*D*a^2*b)*c*d^5+(10
400*C*b^3+31200*D*a*b^2)*c^2*d^4+(-9600)*D*b^3*c^3*d^3)*x^3+((54054*A*a*b^2+5
4054*B*a^2*b+18018*C*a^3)*d^6+((-15444)*A*b^3+(-46332)*B*a*b^2+(-46332)*C*a^2
*b+(-15444)*D*a^3)*c*d^5+(13728*B*b^3+41184*C*a*b^2+41184*D*a^2*b)*c^2*d^4+((
-12480)*C*b^3+(-37440)*D*a*b^2)*c^3*d^3+11520*D*b^3*c^4*d^2)*x^2+((90090*A*a^
2*b+30030*B*a^3)*d^6+((-72072)*A*a*b^2+(-72072)*B*a^2*b+(-24024)*C*a^3)*c*d^5
+(20592*A*b^3+61776*B*a*b^2+61776*C*a^2*b+20592*D*a^3)*c^2*d^4+((-18304)*B*b^
3+(-54912)*C*a*b^2+(-54912)*D*a^2*b)*c^3*d^3+(16640*C*b^3+49920*D*a*b^2)*c^4*
d^2+(-15360)*D*b^3*c^5*d)*x+(90090*A*a^3*d^6+((-180180)*A*a^2*b+(-60060)*B*a^
3)*c*d^5+(144144*A*a*b^2+144144*B*a^2*b+48048*C*a^3)*c^2*d^4+((-41184)*A*b^3+
(-123552)*B*a*b^2+(-123552)*C*a^2*b+(-41184)*D*a^3)*c^3*d^3+(36608*B*b^3+1098
24*C*a*b^2+109824*D*a^2*b)*c^4*d^2+((-33280)*C*b^3+(-99840)*D*a*b^2)*c^5*d+30
720*D*b^3*c^6))*(d*x+c)^(1/2))/(45045*d^7)"
(5) -> ii:=integrate((D*x^3+C*x)/x,x);
Type: Union(Expression(Integer),...)
(6) -> unparse(ii::InputForm)
(6) "(D*x^3+3*C*x)/3"
Type: String
I wanted to ask if there is a ticket on these issue already, or if I should enter a new one. It is hard to know, but may be someone here would know better.