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

A taylor bug fixed by a more recent (5.47.0) version of Maxima #38599

Open
2 tasks done
EmmanuelCharpentier opened this issue Sep 1, 2024 · 0 comments · May be fixed by #38601
Open
2 tasks done

A taylor bug fixed by a more recent (5.47.0) version of Maxima #38599

EmmanuelCharpentier opened this issue Sep 1, 2024 · 0 comments · May be fixed by #38601

Comments

@EmmanuelCharpentier
Copy link
Contributor

EmmanuelCharpentier commented Sep 1, 2024

Steps To Reproduce

Environment : Sage 10.5.beta2

Run :

var('x1 x2 x3 x4 w1 w2 w3 w4 w5 w5 w6');
g= 1/4*((w1^2*w3^2*x1^4*x2^6*x3^8 + 2*(w1^2*w3^2*x1^4*x2^6 + w1^2*w3*x1^3*x2^5)*x3^7 + (w1^2*w3^2*x1^4*x2^6 + 2*w1^2*w3*x1^3*x2^5 + 2*w1^2*x1^2*x2^4)*x3^6)*x4^6 + 2*((w1^2*w3^2*x1^4*x2^6 + (w1^2*w3^2*x1^4 + (2*w1^2*w3 + w1*w3^2)*x1^3)*x2^5)*x3^7 + 2*(w1^2*w3^2*x1^4*x2^6 + (w1^2*w3^2*x1^4 + (3*w1^2*w3 + w1*w3^2)*x1^3)*x2^5 + (w1^2*w3*x1^3 + (w1^2 + w1*w3)*x1^2)*x2^4)*x3^6 + (w1^2*w3^2*x1^4*x2^6 + (w1^2*w3^2*x1^4 + (4*w1^2*w3 + w1*w3^2)*x1^3)*x2^5 + 2*(w1^2*w3*x1^3 + (2*w1^2 + w1*w3)*x1^2)*x2^4 + 2*(w1^2*x1^2 + w1*x1)*x2^3)*x3^5)*x4^5 + ((w1^2*w3^2*x1^4*x2^6 + 2*(w1^2*w3^2*x1^4 + (3*w1^2*w3 + 2*w1*w3^2)*x1^3)*x2^5 + (w1^2*w3^2*x1^4 + 2*(3*w1^2*w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 1)*x3^2 + ((w1 + w3)*x1*x2^3 + 2*((w1 + w3)*x1 + 3)*x2^2 + ((w1 + w3)*x1 + 7)*x2 + 1)*x3)*x4 + 48*x2 + 24)*e^(-w2*x1*x2*x3*x4)/((x2^3*x3^6*e^(w5*x1*x2) + 3*x2^3*x3^5*e^(w5*x1*x2) + 3*x2^3*x3^4*e^(w5*x1*x2) + x2^3*x3^3*e^(w5*x1*x2))*x4^3*e^(w6*x1*x2*x3) + 3*((x2^3 + x2^2)*x3^5*e^(w5*x1*x2) + 3*(x2^3 + x2^2)*x3^4*e^(w5*x1*x2) + 3*(x2^3 + x2^2)*x3^3*e^(w5*x1*x2) + (x2^3 + x2^2)*x3^2*e^(w5*x1*x2))*x4^2*e^(w6*x1*x2*x3) + 3*((x2^3 + 2*x2^2 + x2)*x3^4*e^(w5*x1*x2) + 3*(x2^3 + 2*x2^2 + x2)*x3^3*e^(w5*x1*x2) + 3*(x2^3 + 2*x2^2 + x2)*x3^2*e^(w5*x1*x2) + (x2^3 + 2*x2^2 + x2)*x3*e^(w5*x1*x2))*x4*e^(w6*x1*x2*x3) + ((x2^3 + 3*x2^2 + 3*x2 + 1)*x3^3*e^(w5*x1*x2) + 3*(x2^3 + 3*x2^2 + 3*x2 + 1)*x3^2*e^(w5*x1*x2) + 3*(x2^3 + 3*x2^2 + 3*x2 + 1)*x3*e^(w5*x1*x2) + (x2^3 + 3*x2^2 + 3*x2 + 1)*e^(w5*x1*x2))*e^(w6*x1*x2*x3));
foo=taylor(g, x4, 0, 8);

Expected Behavior

(Silent) computation of the Taylor series by Maxima.

Actual Behavior

Fails with

---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
File /usr/local/sage-10/src/sage/interfaces/interface.py:750, in InterfaceElement.__init__(self, parent, value, is_name, name)
    749 try:
--> 750     self._name = parent._create(value, name=name)
    751 except (TypeError, RuntimeError, ValueError) as x:

File /usr/local/sage-10/src/sage/interfaces/maxima_lib.py:623, in MaximaLib._create(self, value, name)
    622     else:
--> 623         self.set(name, value)
    624 except RuntimeError as error:

File /usr/local/sage-10/src/sage/interfaces/maxima_lib.py:533, in MaximaLib.set(self, var, value)
    532 cmd = '%s : %s$' % (var, value.rstrip(';'))
--> 533 self.eval(cmd)

File /usr/local/sage-10/src/sage/interfaces/maxima_lib.py:479, in MaximaLib._eval_line(self, line, locals, reformat, **kwds)
    478         if statement:
--> 479             maxima_eval("#$%s$" % statement)
    480 if not reformat:

File /usr/local/sage-10/src/sage/libs/ecl.pyx:830, in sage.libs.ecl.EclObject.__call__()
    829 lispargs = EclObject(list(args))
--> 830 return ecl_wrap(ecl_safe_apply(self.obj, (<EclObject>lispargs).obj))
    831 

File /usr/local/sage-10/src/sage/libs/ecl.pyx:358, in sage.libs.ecl.ecl_safe_apply()
    357     else:
--> 358         raise RuntimeError("ECL says: {}".format(message))
    359 else:

RuntimeError: ECL says: THROW: The catch RAT-ERR is undefined.

During handling of the above exception, another exception occurred:

TypeError                                 Traceback (most recent call last)
Cell In[74], line 1
----> 1 foo=taylor(g, x4, Integer(0), Integer(8));

File /usr/local/sage-10/src/sage/calculus/functional.py:422, in taylor(f, *args)
    420     from sage.symbolic.ring import SR
    421     f = SR(f)
--> 422 return f.taylor(*args)

File /usr/local/sage-10/src/sage/symbolic/expression.pyx:5044, in sage.symbolic.expression.Expression.taylor()
   5042 except Exception:
   5043     raise NotImplementedError("Wrong arguments passed to taylor. See taylor? for more details.")
-> 5044 l = self._maxima_().taylor(B)
   5045 return self.parent()(l)
   5046 

File /usr/local/sage-10/src/sage/interfaces/interface.py:698, in InterfaceFunctionElement.__call__(self, *args, **kwds)
    697 def __call__(self, *args, **kwds):
--> 698     return self._obj.parent().function_call(self._name, [self._obj] + list(args), kwds)

File /usr/local/sage-10/src/sage/interfaces/interface.py:617, in Interface.function_call(self, function, args, kwds)
    613 self._check_valid_function_name(function)
    614 s = self._function_call_string(function,
    615                                [s.name() for s in args],
    616                                ['%s=%s' % (key, value.name()) for key, value in kwds.items()])
--> 617 return self.new(s)

File /usr/local/sage-10/src/sage/interfaces/interface.py:386, in Interface.new(self, code)
    385 def new(self, code):
--> 386     return self(code)

File /usr/local/sage-10/src/sage/interfaces/interface.py:299, in Interface.__call__(self, x, name)
    296         pass
    298 if isinstance(x, str):
--> 299     return cls(self, x, name=name)
    300 try:
    301     # Special methods do not and should not have an option to
    302     # set the name directly, as the identifier assigned by the
    303     # interface should stay consistent. An identifier with a
    304     # user-assigned name might change its value, so we return a
    305     # new element.
    306     result = self._coerce_from_special_method(x)

File /usr/local/sage-10/src/sage/interfaces/interface.py:752, in InterfaceElement.__init__(self, parent, value, is_name, name)
    750     self._name = parent._create(value, name=name)
    751 except (TypeError, RuntimeError, ValueError) as x:
--> 752     raise TypeError(x)

TypeError: ECL says: THROW: The catch RAT-ERR is undefined.

Additional Information

Initial report and exploration in this ask.sagemath.orgquestion ; further discussion on sage-support.

Reproducible in "our" Maxima (5.46.0 as of Sep 1, 2024) :

;;; Loading #P"/usr/lib/x86_64-linux-gnu/ecl-21.2.1/sb-bsd-sockets.fas"
;;; Loading #P"/usr/lib/x86_64-linux-gnu/ecl-21.2.1/sockets.fas"
Maxima 5.46.0 https://maxima.sourceforge.io
using Lisp ECL 21.2.1
Distributed under the GNU Public License. See the file COPYING.
Dedicated to the memory of William Schelter.
The function bug_report() provides bug reporting information.
(%i1) display2d:false;

(%o1) false
(%i2) g:1/4*((w1^2*w3^2*x1^4*x2^6*x3^8 + 2*(w1^2*w3^2*x1^4*x2^6 + w1^2*w3*x1^3*x2^5)*x3^7 + (w1^2*w3^2*x1^4*x2^6 + 2*w1^2*w3*x1^3*x2^5 + 2*w1^2*x1^2*x2^4)*x3^6)*x4^6 + 2*((w1^2*w3^2*x1^4*x2^6 + (w1^2*w3^2*x1^4 + (2*w1^2*w3 + w1*w3^2)*x1^3)*x2^5)*x3^7 + 2*(w1^2*w3^2*x1^4*x2^6 + (w1^2*w3^2*x1^4 + (3*w1^2*w3 + w1*w3^2)*x1^3)*x2^5 +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+ (x2^3 + 3*x2^2 + 3*x2 + 1)*e^(w5*x1*x2))*e^(w6*x1*x2*x3))$

(%i3) T8:taylor(g, x4, 0, 8)$

PQUOTIENT: Quotient by a polynomial of higher degree (case 2a)
 -- an error. To debug this try: debugmode(true);

Solved in Maxima 5.47.0 (as installed by Debian testing packages) :

/* Same initialization... */
(%i3) T8:taylor(g, x4, 0, 8)$
(%i4) 

Of note :

  • g.series(x4==0, 8) works as expected ;
  • giac and the Wolfram engine also work.
  • Using their respective outputs to get the $x_4^7$ coefficient lead to expressions which can (penibly) proved equal (sometimes by borrowing sympy or Wolfram simplifiers).
  • Another workaround using (possibly lazy) power series rings also works (and can be similarlu checked).
  • sympy's series doesn't return. A mail on the Sympy list got me the answer "The general approach for computing series in SymPy is algorithmically misdesigned.".

Environment

- **OS**: Debian testing, as of 2024-09-01
- **Sage Version**: 10.5.beta2 (including Maxima 5.46.0).
- **External Maxima version**: 5.47.0

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
@EmmanuelCharpentier EmmanuelCharpentier changed the title A taylor bug fixed by recent (7.47.0) versions of Maxima A taylor bug fixed by a more recent (5.47.0) version of Maxima Sep 1, 2024
dimpase added a commit to dimpase/sage that referenced this issue Sep 2, 2024
followup to sagemath#35707 (make sage maxima 5.47-compatible)

fixes sagemath#38599
@dimpase dimpase linked a pull request Sep 2, 2024 that will close this issue
2 tasks
dimpase added a commit to dimpase/sage that referenced this issue Sep 3, 2024
followup to sagemath#35707 (make sage maxima 5.47-compatible)

fixes sagemath#38599
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant