Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

why ECL says: Error executing code in Maxima: expt: undefined: 0 to a negative exponent

Why the error ECL says: Error executing code in Maxima: expt: undefined: 0 to a negative exponent shows up in this example? When running the same integral in maxima, no error is given. (it can't integrate it, but no error).

This happens when adding assume on a variable. Using sagemath 9.3 and maxima 5.44 on Linux

sage: var('x a')
(x, a)
sage: integrate(arcsin(x/a)^(3/2)/(a^2-x^2)^(1/2),x, algorithm="maxima")
integrate(arcsin(x/a)^(3/2)/sqrt(a^2 - x^2), x)

Now problems. .Now notice what happens when adding assume.

sage: assume(a>0)
sage: integrate(arcsin(x/a)^(3/2)/(a^2-x^2)^(1/2),x, algorithm="maxima")
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
<ipython-input-4-ac342accae00> in <module>
----> 1 integrate(arcsin(x/a)**(Integer(3)/Integer(2))/(a**Integer(2)-x**Integer(2))**(Integer(1)/Integer(2)),x, algorithm="maxima")

/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 maxima_integrator(expression, v, a, b)
     42         expression = SR(expression)
     43     if a is None:
---> 44         result = maxima.sr_integral(expression, v)
     45     else:
     46         result = maxima.sr_integral(expression, v, a, b)

/usr/lib/python3.9/site-packages/sage/interfaces/maxima_lib.py in sr_integral(self, *args)
    787         """
    788         try:
--> 789             return max_to_sr(maxima_eval(([max_integrate],[sr_to_max(SR(a)) for a in args])))
    790         except RuntimeError as error:
    791             s = str(error)

/usr/lib/python3.9/site-packages/sage/libs/ecl.pyx in sage.libs.ecl.EclObject.__call__ (build/cythonized/sage/libs/ecl.c:8632)()
    852         """
    853         lispargs = EclObject(list(args))
--> 854         return ecl_wrap(ecl_safe_apply(self.obj,(<EclObject>lispargs).obj))
    855 
    856     def __richcmp__(left, right, int op):

/usr/lib/python3.9/site-packages/sage/libs/ecl.pyx in sage.libs.ecl.ecl_safe_apply (build/cythonized/sage/libs/ecl.c:5914)()
    363 
    364     if error != NULL:
--> 365         raise RuntimeError("ECL says: {}".format(
    366             ecl_string_to_python(error)))
    367     else:

RuntimeError: ECL says: Error executing code in Maxima: expt: undefined: 0 to a negative exponent.
sage:

Now the same thing inside maxima itself causes no problem after adding assume

>maxima
;;; Loading #P"/usr/lib/ecl-20.4.24/sb-bsd-sockets.fas"
;;; Loading #P"/usr/lib/ecl-20.4.24/sockets.fas"
Maxima 5.44.0 http://maxima.sourceforge.net
using Lisp ECL 20.4.24
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) integrate(arcsin(x/a)^(3/2)/(a^2-x^2)^(1/2),x)                        
;
                                       x 3/2
                              / arcsin(-)
                              [        a
(%o1)                         I ------------- dx
                              ]       2    2
                              / sqrt(a  - x )
(%i2) assume(a>0);
(%o2)                               [a > 0]
(%i3) integrate(arcsin(x/a)^(3/2)/(a^2-x^2)^(1/2),x)                    
;
                                       x 3/2
                              / arcsin(-)
                              [        a
(%o3)                         I ------------- dx
                              ]       2    2
                              / sqrt(a  - x )
(%i4)

Why does sagemath gives exception when using assume but maxima itself does not? Is this a known issue?

why ECL says: Error executing code in Maxima: expt: undefined: 0 to a negative exponent

Why the error ECL says: Error executing code in Maxima: expt: undefined: 0 to a negative exponent shows up in this example? When running the same integral in maxima, no error is given. (it can't integrate it, but no error).

This happens when adding assume on a variable. Using sagemath 9.3 and maxima 5.44 on Linux

sage: var('x a')
(x, a)
sage: integrate(arcsin(x/a)^(3/2)/(a^2-x^2)^(1/2),x, algorithm="maxima")
integrate(arcsin(x/a)^(3/2)/sqrt(a^2 - x^2), x)

Now problems. .Now No problem. But now notice what happens when adding assume.

sage: assume(a>0)
sage: integrate(arcsin(x/a)^(3/2)/(a^2-x^2)^(1/2),x, algorithm="maxima")
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
<ipython-input-4-ac342accae00> in <module>
----> 1 integrate(arcsin(x/a)**(Integer(3)/Integer(2))/(a**Integer(2)-x**Integer(2))**(Integer(1)/Integer(2)),x, algorithm="maxima")

/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 maxima_integrator(expression, v, a, b)
     42         expression = SR(expression)
     43     if a is None:
---> 44         result = maxima.sr_integral(expression, v)
     45     else:
     46         result = maxima.sr_integral(expression, v, a, b)

/usr/lib/python3.9/site-packages/sage/interfaces/maxima_lib.py in sr_integral(self, *args)
    787         """
    788         try:
--> 789             return max_to_sr(maxima_eval(([max_integrate],[sr_to_max(SR(a)) for a in args])))
    790         except RuntimeError as error:
    791             s = str(error)

/usr/lib/python3.9/site-packages/sage/libs/ecl.pyx in sage.libs.ecl.EclObject.__call__ (build/cythonized/sage/libs/ecl.c:8632)()
    852         """
    853         lispargs = EclObject(list(args))
--> 854         return ecl_wrap(ecl_safe_apply(self.obj,(<EclObject>lispargs).obj))
    855 
    856     def __richcmp__(left, right, int op):

/usr/lib/python3.9/site-packages/sage/libs/ecl.pyx in sage.libs.ecl.ecl_safe_apply (build/cythonized/sage/libs/ecl.c:5914)()
    363 
    364     if error != NULL:
--> 365         raise RuntimeError("ECL says: {}".format(
    366             ecl_string_to_python(error)))
    367     else:

RuntimeError: ECL says: Error executing code in Maxima: expt: undefined: 0 to a negative exponent.
sage:

Now the same thing inside maxima itself causes no problem after adding assume

>maxima
;;; Loading #P"/usr/lib/ecl-20.4.24/sb-bsd-sockets.fas"
;;; Loading #P"/usr/lib/ecl-20.4.24/sockets.fas"
Maxima 5.44.0 http://maxima.sourceforge.net
using Lisp ECL 20.4.24
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) integrate(arcsin(x/a)^(3/2)/(a^2-x^2)^(1/2),x)                        
;
                                       x 3/2
                              / arcsin(-)
                              [        a
(%o1)                         I ------------- dx
                              ]       2    2
                              / sqrt(a  - x )
(%i2) assume(a>0);
(%o2)                               [a > 0]
(%i3) integrate(arcsin(x/a)^(3/2)/(a^2-x^2)^(1/2),x)                    
;
                                       x 3/2
                              / arcsin(-)
                              [        a
(%o3)                         I ------------- dx
                              ]       2    2
                              / sqrt(a  - x )
(%i4)

Why does sagemath gives exception when using assume but maxima itself does not? Is this a known issue?