Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sagemath-Fricas issue. AttributeError: 'NoneType' object has no attribute 'replace' calling integrate #37813

Open
2 tasks done
nasser1 opened this issue Apr 16, 2024 · 0 comments

Comments

@nasser1
Copy link

nasser1 commented Apr 16, 2024

Steps To Reproduce

Using sagemath 10.3 with Fricas :

sage --version
SageMath version 10.3, Release Date: 2024-03-19

>fricas --version
FriCAS 1.3.10
based on sbcl 2.3.11
>

Sage gives AttributeError: 'NoneType' object has no attribute 'replace' on an integral which Fricas directly can do


>sage
┌────────────────────────────────────────────────────────────────────┐
│ SageMath version 10.3, Release Date: 2024-03-19                    │
│ Using Python 3.11.8. Type "help()" for help.                       │
└────────────────────────────────────────────────────────────────────┘
sage: print(fricas.eval(")lisp |$build_version|"))

Value = "FriCAS 1.3.10"

sage: var('x a b B y A')
(x, a, b, B, y, A)
sage: integrate((x^2+1)^(1/2)/(x^2+(x+(x^2+1)^(1/2))^(1/2)),x, algorithm="fricas")
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[3], line 1
----> 1 integrate((x**Integer(2)+Integer(1))**(Integer(1)/Integer(2))/(x**Integer(2)+(x+(x**Integer(2)+Integer(1))**(Integer(1)/Integer(2)))**(Integer(1)/Integer(2))),x, algorithm="fricas")

File ~/TMP/sage-10.3/src/sage/misc/functional.py:788, in integral(x, *args, **kwds)
    655 """
    656 Return an indefinite or definite integral of an object ``x``.
    657 
   (...)
    785 
    786 """
    787 if hasattr(x, 'integral'):
--> 788     return x.integral(*args, **kwds)
    789 else:
    790     from sage.symbolic.ring import SR

File ~/TMP/sage-10.3/src/sage/symbolic/expression.pyx:13268, in sage.symbolic.expression.Expression.integral()
  13266                 R = SR
  13267         return R(integral(f, v, a, b, **kwds))
> 13268     return integral(self, *args, **kwds)
  13269 
  13270 integrate = integral

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

File ~/TMP/sage-10.3/src/sage/symbolic/integration/external.py:207, in fricas_integrator(expression, v, a, b, noPole)
    204     else:
    205         result = e_fricas.integrate(seg)
--> 207 result = result.sage()
    209 if result == "failed":
    210     result = expression.integrate(v, a, b, hold=True)

File ~/TMP/sage-10.3/src/sage/interfaces/interface.py:1123, in InterfaceElement.sage(self, *args, **kwds)
   1104 def sage(self, *args, **kwds):
   1105     """
   1106     Attempt to return a Sage version of this object.
   1107 
   (...)
   1121         [0 0]
   1122     """
-> 1123     return self._sage_(*args, **kwds)

File ~/TMP/sage-10.3/src/sage/interfaces/fricas.py:1999, in FriCASElement._sage_(self)
   1997 # finally translate domains with InputForm
   1998 try:
-> 1999     unparsed_InputForm = P.get_unparsed_InputForm(self._name)
   2000 except RuntimeError as error:
   2001     raise NotImplementedError("the translation of the FriCAS object\n\n%s\n\nto sage is not yet implemented:\n%s" % (self, error))

File ~/TMP/sage-10.3/src/sage/interfaces/fricas.py:805, in FriCAS.get_unparsed_InputForm(self, var)
    785 def get_unparsed_InputForm(self, var):
    786     """
    787     Return the unparsed ``InputForm`` as a string.
    788 
   (...)
    803 
    804     """
--> 805     return self.get_string('unparse((%s)::InputForm)' % str(var))

File ~/TMP/sage-10.3/src/sage/interfaces/fricas.py:755, in FriCAS.get_string(self, var)
    710 """
    711 Return the value of a FriCAS string as a string, without checking
    712 that it is a string.
   (...)
    750 
    751 """
    752 # strip removes leading and trailing whitespace, after that
    753 # we can assume that the first and the last character are
    754 # double quotes
--> 755 return self.get(str(var)).replace("\n", "").strip()[1:-1]

AttributeError: 'NoneType' object has no attribute 'replace'


Calling same integrate inside Fricas directly works and no exception is generated (output not show as output too large)


integrate((x^2+1)^(1/2)/(x^2+(x+(x^2+1)^(1/2))^(1/2)),x)
%no error


Expected Behavior

No exception should be generated

Actual Behavior

Exception generated by sagemath

Additional Information

No response

Environment

Linux on Virtual box

lsb_release -a
LSB Version:	n/a
Distributor ID:	ManjaroLinux
Description:	Manjaro Linux
Release:	23.1.4
Codename:	Vulcan


sage --version
SageMath version 10.3, Release Date: 2024-03-19

Checklist

  • I have searched the existing issues for a bug report that matches the one I want to file, without success.
  • I have read the documentation and troubleshoot guide
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants