ECL says: Memory limit reached calling expr.full_simplify()

103 views
Skip to first unread message

Nasser M. Abbasi

unread,
Jun 23, 2023, 3:15:18 AM6/23/23
to sage-devel
I obtained a large expression from CAS system (Fricas) calling it from sagemath.

When I did expr.full_simplify() sagemath 10.0 on Linux gave this error

TypeError: ECL says: Memory limit reached. Please jump to an outer pointer, quit program and enlarge the
memory limits before executing the program again.

Is this to be expected for very large expression? 

Here is full error

age: expr.full_simplify()
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
File ~/TMP/sage-10.0/src/sage/interfaces/interface.py:748, in InterfaceElement.__init__(self, parent, value, is_name, name)
    747 try:
--> 748     self._name = parent._create(value, name=name)
    749 except (TypeError, RuntimeError, ValueError) as x:

File ~/TMP/sage-10.0/src/sage/interfaces/maxima_lib.py:618, in MaximaLib._create(self, value, name)
    617     else:
--> 618         self.set(name, value)
    619 except RuntimeError as error:

File ~/TMP/sage-10.0/src/sage/interfaces/maxima_lib.py:526, in MaximaLib.set(self, var, value)
    525 cmd = '%s : %s$'%(var, value.rstrip(';'))
--> 526 self.eval(cmd)

File ~/TMP/sage-10.0/src/sage/interfaces/maxima_lib.py:472, in MaximaLib._eval_line(self, line, locals, reformat, **kwds)
    471         if statement:
--> 472             maxima_eval("#$%s$" % statement)
    473 if not reformat:

File ~/TMP/sage-10.0/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 ~/TMP/sage-10.0/src/sage/libs/ecl.pyx:353, in sage.libs.ecl.ecl_safe_apply()
    352     else:
--> 353         raise RuntimeError("ECL says: {}".format(message))
    354 else:

RuntimeError: ECL says: Memory limit reached. Please jump to an outer pointer, quit program and enlarge the
memory limits before executing the program again.

During handling of the above exception, another exception occurred:

TypeError                                 Traceback (most recent call last)
Cell In [7], line 1
----> 1 expr.full_simplify()

File ~/TMP/sage-10.0/src/sage/symbolic/expression.pyx:10749, in sage.symbolic.expression.Expression.simplify_full()
  10747 x = self
  10748 x = x.simplify_factorial()
> 10749 x = x.simplify_rectform()
  10750 x = x.simplify_trig()
  10751 x = x.simplify_rational()

File ~/TMP/sage-10.0/src/sage/symbolic/expression.pyx:10899, in sage.symbolic.expression.Expression.simplify_rectform()
  10897
  10898         """
> 10899         simplified_expr = self.rectform()
  10900
  10901         if complexity_measure is None:

File ~/TMP/sage-10.0/src/sage/symbolic/expression.pyx:10549, in sage.symbolic.expression.Expression.rectform()
  10547         0.0
  10548     """
> 10549     return self.maxima_methods().rectform()
  10550
  10551 def unhold(self, exclude=None):

File ~/TMP/sage-10.0/src/sage/symbolic/maxima_wrapper.py:31, in MaximaFunctionElementWrapper.__call__(self, *args, **kwds)
     18 def __call__(self, *args, **kwds):
     19     """
     20     Return a Sage expression instead of a Maxima pexpect interface element.
     21
   (...)
     29         Symbolic Ring
     30     """
---> 31     return super().__call__(*args, **kwds).sage()

File ~/TMP/sage-10.0/src/sage/interfaces/interface.py:696, in InterfaceFunctionElement.__call__(self, *args, **kwds)
    695 def __call__(self, *args, **kwds):
--> 696     return self._obj.parent().function_call(self._name, [self._obj] + list(args), kwds)

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

File ~/TMP/sage-10.0/src/sage/interfaces/interface.py:385, in Interface.new(self, code)
    384 def new(self, code):
--> 385     return self(code)

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

File ~/TMP/sage-10.0/src/sage/interfaces/interface.py:750, in InterfaceElement.__init__(self, parent, value, is_name, name)
    748     self._name = parent._create(value, name=name)
    749 except (TypeError, RuntimeError, ValueError) as x:
--> 750     raise TypeError(x)

TypeError: ECL says: Memory limit reached. Please jump to an outer pointer, quit program and enlarge the
memory limits before executing the program again.
sage:

Since expression is large, I will put a link to full code used if you think it is needed.

I am running this on Linux Virtual box with 43 GB of RAM. 

--Nasser
 

Nasser M. Abbasi

unread,
Jun 23, 2023, 3:21:57 AM6/23/23
to sage-devel
Here is the code to reproduce it. Using Fricas 1.3.8 on Linux via sagemath

var('x a')
expr=integrate(x/(a^5+x^5),x, algorithm="fricas");
len(str(expr))
     47199
expr.full_simplify()

TypeError: ECL says: Memory limit reached. Please jump to an outer pointer, quit program and enlarge the
memory limits before executing the program again.

--Nasser

Dima Pasechnik

unread,
Jun 23, 2023, 11:41:27 AM6/23/23
to sage-devel
What is the output provided by fricas (outside Sage) ?
(perhaps it's a short expression as a root sum?)


Simplifying an expression given as  a string of length 47K is not an easy task.



--
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+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sage-devel/7f96330e-fe0a-4858-8363-911122c1afb1n%40googlegroups.com.

Nasser M. Abbasi

unread,
Jun 23, 2023, 12:14:50 PM6/23/23
to sage-devel
This is output from Fricas itself directly

(2) -> setSimplifyDenomsFlag(true)

   (2)  false
                                                                Type: Boolean
(3) -> ii:=integrate(x/(a^5+x^5),x);

                                         Type: Union(Expression(Integer),...)
(4) -> unparse(ii::InputForm)

   (4)
  "(((-5)*a^3*(((-75)*a^6*rootOf((125*a^9*rootOf((625*%%E0^4*a^12+(-125)*%%E0^3
  *a^9+25*%%E0^2*a^6+(-5)*%%E0*a^3+1)/(625*a^12),%%E0)^3+(125*%%E1*a^9+(-25)*a^
  6)*rootOf((625*%%E0^4*a^12+(-125)*%%E0^3*a^9+25*%%E0^2*a^6+(-5)*%%E0*a^3+1)/(
  625*a^12),%%E0)^2+(125*%%E1^2*a^9+(-25)*%%E1*a^6+5*a^3)*rootOf((625*%%E0^4*a^
  12+(-125)*%%E0^3*a^9+25*%%E0^2*a^6+(-5)*%%E0*a^3+1)/(625*a^12),%%E0)+(125*%%E
  1^3*a^9+(-25)*%%E1^2*a^6+5*%%E1*a^3+(-1)))/(125*a^9),%%E1)^2+((-50)*a^6*rootO
  f((625*%%E0^4*a^12+(-125)*%%E0^3*a^9+25*%%E0^2*a^6+(-5)*%%E0*a^3+1)/(625*a^12
  ),%%E0)+10*a^3)*rootOf((125*a^9*rootOf((625*%%E0^4*a^12+(-125)*%%E0^3*a^9+25*
  %%E0^2*a^6+(-5)*%%E0*a^3+1)/(625*a^12),%%E0)^3+(125*%%E1*a^9+(-25)*a^6)*rootO
  f((625*%%E0^4*a^12+(-125)*%%E0^3*a^9+25*%%E0^2*a^6+(-5)*%%E0*a^3+1)/(625*a^12
  ),%%E0)^2+(125*%%E1^2*a^9+(-25)*%%E1*a^6+5*a^3)*rootOf((625*%%E0^4*a^12+(-125
  )*%%E0^3*a^9+25*%%E0^2*a^6+(-5)*%%E0*a^3+1)/(625*a^12),%%E0)+(125*%%E1^3*a^9+
  (-25)*%%E1^2*a^6+5*%%E1*a^3+(-1)))/(125*a^9),%%E1)+((-75)*a^6*rootOf((625*%%E
  0^4*a^12+(-125)*%%E0^3*a^9+25*%%E0^2*a^6+(-5)*%%E0*a^3+1)/(625*a^12),%%E0)^2+
  10*a^3*rootOf((625*%%E0^4*a^12+(-125)*%%E0^3*a^9+25*%%E0^2*a^6+(-5)*%%E0*a^3+
  1)/(625*a^12),%%E0)+(-3)))/(25*a^6))^(1/2)+((-5)*a^3*rootOf((125*a^9*rootOf((
  625*%%E0^4*a^12+(-125)*%%E0^3*a^9+25*%%E0^2*a^6+(-5)*%%E0*a^3+1)/(625*a^12),%
  %E0)^3+(125*%%E1*a^9+(-25)*a^6)*rootOf((625*%%E0^4*a^12+(-125)*%%E0^3*a^9+25*
  %%E0^2*a^6+(-5)*%%E0*a^3+1)/(625*a^12),%%E0)^2+(125*%%E1^2*a^9+(-25)*%%E1*a^6
  +5*a^3)*rootOf((625*%%E0^4*a^12+(-125)*%%E0^3*a^9+25*%%E0^2*a^6+(-5)*%%E0*a^3
  +1)/(625*a^12),%%E0)+(125*%%E1^3*a^9+(-25)*%%E1^2*a^6+5*%%E1*a^3+(-1)))/(125*
  a^9),%%E1)+((-5)*a^3*rootOf((625*%%E0^4*a^12+(-125)*%%E0^3*a^9+25*%%E0^2*a^6+
  (-5)*%%E0*a^3+1)/(625*a^12),%%E0)+1)))*log(((125*a^10*rootOf((625*%%E0^4*a^12
  +(-125)*%%E0^3*a^9+25*%%E0^2*a^6+(-5)*%%E0*a^3+1)/(625*a^12),%%E0)+(-25)*a^7)
  *rootOf((125*a^9*rootOf((625*%%E0^4*a^12+(-125)*%%E0^3*a^9+25*%%E0^2*a^6+(-5)
  *%%E0*a^3+1)/(625*a^12),%%E0)^3+(125*%%E1*a^9+(-25)*a^6)*rootOf((625*%%E0^4*a
  ^12+(-125)*%%E0^3*a^9+25*%%E0^2*a^6+(-5)*%%E0*a^3+1)/(625*a^12),%%E0)^2+(125*
  %%E1^2*a^9+(-25)*%%E1*a^6+5*a^3)*rootOf((625*%%E0^4*a^12+(-125)*%%E0^3*a^9+25
  *%%E0^2*a^6+(-5)*%%E0*a^3+1)/(625*a^12),%%E0)+(125*%%E1^3*a^9+(-25)*%%E1^2*a^
  6+5*%%E1*a^3+(-1)))/(125*a^9),%%E1)+(-25)*a^7*rootOf((625*%%E0^4*a^12+(-125)*
  %%E0^3*a^9+25*%%E0^2*a^6+(-5)*%%E0*a^3+1)/(625*a^12),%%E0))*(((-75)*a^6*rootO
  f((125*a^9*rootOf((625*%%E0^4*a^12+(-125)*%%E0^3*a^9+25*%%E0^2*a^6+(-5)*%%E0*
  a^3+1)/(625*a^12),%%E0)^3+(125*%%E1*a^9+(-25)*a^6)*rootOf((625*%%E0^4*a^12+(-
  125)*%%E0^3*a^9+25*%%E0^2*a^6+(-5)*%%E0*a^3+1)/(625*a^12),%%E0)^2+(125*%%E1^2
  *a^9+(-25)*%%E1*a^6+5*a^3)*rootOf((625*%%E0^4*a^12+(-125)*%%E0^3*a^9+25*%%E0^
  2*a^6+(-5)*%%E0*a^3+1)/(625*a^12),%%E0)+(125*%%E1^3*a^9+(-25)*%%E1^2*a^6+5*%%
  E1*a^3+(-1)))/(125*a^9),%%E1)^2+((-50)*a^6*rootOf((625*%%E0^4*a^12+(-125)*%%E
  0^3*a^9+25*%%E0^2*a^6+(-5)*%%E0*a^3+1)/(625*a^12),%%E0)+10*a^3)*rootOf((125*a
  ^9*rootOf((625*%%E0^4*a^12+(-125)*%%E0^3*a^9+25*%%E0^2*a^6+(-5)*%%E0*a^3+1)/(
  625*a^12),%%E0)^3+(125*%%E1*a^9+(-25)*a^6)*rootOf((625*%%E0^4*a^12+(-125)*%%E
  0^3*a^9+25*%%E0^2*a^6+(-5)*%%E0*a^3+1)/(625*a^12),%%E0)^2+(125*%%E1^2*a^9+(-2
  5)*%%E1*a^6+5*a^3)*rootOf((625*%%E0^4*a^12+(-125)*%%E0^3*a^9+25*%%E0^2*a^6+(-
  5)*%%E0*a^3+1)/(625*a^12),%%E0)+(125*%%E1^3*a^9+(-25)*%%E1^2*a^6+5*%%E1*a^3+(
  -1)))/(125*a^9),%%E1)+((-75)*a^6*rootOf((625*%%E0^4*a^12+(-125)*%%E0^3*a^9+25
  *%%E0^2*a^6+(-5)*%%E0*a^3+1)/(625*a^12),%%E0)^2+10*a^3*rootOf((625*%%E0^4*a^1
  2+(-125)*%%E0^3*a^9+25*%%E0^2*a^6+(-5)*%%E0*a^3+1)/(625*a^12),%%E0)+(-3)))/(2
  5*a^6))^(1/2)+(((-125)*a^10*rootOf((625*%%E0^4*a^12+(-125)*%%E0^3*a^9+25*%%E0
  ^2*a^6+(-5)*%%E0*a^3+1)/(625*a^12),%%E0)+25*a^7)*rootOf((125*a^9*rootOf((625*
  %%E0^4*a^12+(-125)*%%E0^3*a^9+25*%%E0^2*a^6+(-5)*%%E0*a^3+1)/(625*a^12),%%E0)
  ^3+(125*%%E1*a^9+(-25)*a^6)*rootOf((625*%%E0^4*a^12+(-125)*%%E0^3*a^9+25*%%E0
  ^2*a^6+(-5)*%%E0*a^3+1)/(625*a^12),%%E0)^2+(125*%%E1^2*a^9+(-25)*%%E1*a^6+5*a
  ^3)*rootOf((625*%%E0^4*a^12+(-125)*%%E0^3*a^9+25*%%E0^2*a^6+(-5)*%%E0*a^3+1)/
  (625*a^12),%%E0)+(125*%%E1^3*a^9+(-25)*%%E1^2*a^6+5*%%E1*a^3+(-1)))/(125*a^9)
  ,%%E1)^2+((-125)*a^10*rootOf((625*%%E0^4*a^12+(-125)*%%E0^3*a^9+25*%%E0^2*a^6
  +(-5)*%%E0*a^3+1)/(625*a^12),%%E0)^2+25*a^7*rootOf((625*%%E0^4*a^12+(-125)*%%
  E0^3*a^9+25*%%E0^2*a^6+(-5)*%%E0*a^3+1)/(625*a^12),%%E0)+(-5)*a^4)*rootOf((12
  5*a^9*rootOf((625*%%E0^4*a^12+(-125)*%%E0^3*a^9+25*%%E0^2*a^6+(-5)*%%E0*a^3+1
  )/(625*a^12),%%E0)^3+(125*%%E1*a^9+(-25)*a^6)*rootOf((625*%%E0^4*a^12+(-125)*
  %%E0^3*a^9+25*%%E0^2*a^6+(-5)*%%E0*a^3+1)/(625*a^12),%%E0)^2+(125*%%E1^2*a^9+
  (-25)*%%E1*a^6+5*a^3)*rootOf((625*%%E0^4*a^12+(-125)*%%E0^3*a^9+25*%%E0^2*a^6
  +(-5)*%%E0*a^3+1)/(625*a^12),%%E0)+(125*%%E1^3*a^9+(-25)*%%E1^2*a^6+5*%%E1*a^
  3+(-1)))/(125*a^9),%%E1)+(25*a^7*rootOf((625*%%E0^4*a^12+(-125)*%%E0^3*a^9+25
  *%%E0^2*a^6+(-5)*%%E0*a^3+1)/(625*a^12),%%E0)^2+(-5)*a^4*rootOf((625*%%E0^4*a
  ^12+(-125)*%%E0^3*a^9+25*%%E0^2*a^6+(-5)*%%E0*a^3+1)/(625*a^12),%%E0)+2*x)))+
  ((5*a^3*(((-75)*a^6*rootOf((125*a^9*rootOf((625*%%E0^4*a^12+(-125)*%%E0^3*a^9
  +25*%%E0^2*a^6+(-5)*%%E0*a^3+1)/(625*a^12),%%E0)^3+(125*%%E1*a^9+(-25)*a^6)*r
  ootOf((625*%%E0^4*a^12+(-125)*%%E0^3*a^9+25*%%E0^2*a^6+(-5)*%%E0*a^3+1)/(625*
  a^12),%%E0)^2+(125*%%E1^2*a^9+(-25)*%%E1*a^6+5*a^3)*rootOf((625*%%E0^4*a^12+(
  -125)*%%E0^3*a^9+25*%%E0^2*a^6+(-5)*%%E0*a^3+1)/(625*a^12),%%E0)+(125*%%E1^3*
  a^9+(-25)*%%E1^2*a^6+5*%%E1*a^3+(-1)))/(125*a^9),%%E1)^2+((-50)*a^6*rootOf((6
  25*%%E0^4*a^12+(-125)*%%E0^3*a^9+25*%%E0^2*a^6+(-5)*%%E0*a^3+1)/(625*a^12),%%
  E0)+10*a^3)*rootOf((125*a^9*rootOf((625*%%E0^4*a^12+(-125)*%%E0^3*a^9+25*%%E0
  ^2*a^6+(-5)*%%E0*a^3+1)/(625*a^12),%%E0)^3+(125*%%E1*a^9+(-25)*a^6)*rootOf((6
  25*%%E0^4*a^12+(-125)*%%E0^3*a^9+25*%%E0^2*a^6+(-5)*%%E0*a^3+1)/(625*a^12),%%
  E0)^2+(125*%%E1^2*a^9+(-25)*%%E1*a^6+5*a^3)*rootOf((625*%%E0^4*a^12+(-125)*%%
  E0^3*a^9+25*%%E0^2*a^6+(-5)*%%E0*a^3+1)/(625*a^12),%%E0)+(125*%%E1^3*a^9+(-25
  )*%%E1^2*a^6+5*%%E1*a^3+(-1)))/(125*a^9),%%E1)+((-75)*a^6*rootOf((625*%%E0^4*
  a^12+(-125)*%%E0^3*a^9+25*%%E0^2*a^6+(-5)*%%E0*a^3+1)/(625*a^12),%%E0)^2+10*a
  ^3*rootOf((625*%%E0^4*a^12+(-125)*%%E0^3*a^9+25*%%E0^2*a^6+(-5)*%%E0*a^3+1)/(
  625*a^12),%%E0)+(-3)))/(25*a^6))^(1/2)+((-5)*a^3*rootOf((125*a^9*rootOf((625*
  %%E0^4*a^12+(-125)*%%E0^3*a^9+25*%%E0^2*a^6+(-5)*%%E0*a^3+1)/(625*a^12),%%E0)
  ^3+(125*%%E1*a^9+(-25)*a^6)*rootOf((625*%%E0^4*a^12+(-125)*%%E0^3*a^9+25*%%E0
  ^2*a^6+(-5)*%%E0*a^3+1)/(625*a^12),%%E0)^2+(125*%%E1^2*a^9+(-25)*%%E1*a^6+5*a
  ^3)*rootOf((625*%%E0^4*a^12+(-125)*%%E0^3*a^9+25*%%E0^2*a^6+(-5)*%%E0*a^3+1)/
  (625*a^12),%%E0)+(125*%%E1^3*a^9+(-25)*%%E1^2*a^6+5*%%E1*a^3+(-1)))/(125*a^9)
  ,%%E1)+((-5)*a^3*rootOf((625*%%E0^4*a^12+(-125)*%%E0^3*a^9+25*%%E0^2*a^6+(-5)
  *%%E0*a^3+1)/(625*a^12),%%E0)+1)))*log((((-125)*a^10*rootOf((625*%%E0^4*a^12+
  (-125)*%%E0^3*a^9+25*%%E0^2*a^6+(-5)*%%E0*a^3+1)/(625*a^12),%%E0)+25*a^7)*roo
  tOf((125*a^9*rootOf((625*%%E0^4*a^12+(-125)*%%E0^3*a^9+25*%%E0^2*a^6+(-5)*%%E
  0*a^3+1)/(625*a^12),%%E0)^3+(125*%%E1*a^9+(-25)*a^6)*rootOf((625*%%E0^4*a^12+
  (-125)*%%E0^3*a^9+25*%%E0^2*a^6+(-5)*%%E0*a^3+1)/(625*a^12),%%E0)^2+(125*%%E1
  ^2*a^9+(-25)*%%E1*a^6+5*a^3)*rootOf((625*%%E0^4*a^12+(-125)*%%E0^3*a^9+25*%%E
  0^2*a^6+(-5)*%%E0*a^3+1)/(625*a^12),%%E0)+(125*%%E1^3*a^9+(-25)*%%E1^2*a^6+5*
  %%E1*a^3+(-1)))/(125*a^9),%%E1)+25*a^7*rootOf((625*%%E0^4*a^12+(-125)*%%E0^3*
  a^9+25*%%E0^2*a^6+(-5)*%%E0*a^3+1)/(625*a^12),%%E0))*(((-75)*a^6*rootOf((125*
  a^9*rootOf((625*%%E0^4*a^12+(-125)*%%E0^3*a^9+25*%%E0^2*a^6+(-5)*%%E0*a^3+1)/
  (625*a^12),%%E0)^3+(125*%%E1*a^9+(-25)*a^6)*rootOf((625*%%E0^4*a^12+(-125)*%%
  E0^3*a^9+25*%%E0^2*a^6+(-5)*%%E0*a^3+1)/(625*a^12),%%E0)^2+(125*%%E1^2*a^9+(-
  25)*%%E1*a^6+5*a^3)*rootOf((625*%%E0^4*a^12+(-125)*%%E0^3*a^9+25*%%E0^2*a^6+(
  -5)*%%E0*a^3+1)/(625*a^12),%%E0)+(125*%%E1^3*a^9+(-25)*%%E1^2*a^6+5*%%E1*a^3+
  (-1)))/(125*a^9),%%E1)^2+((-50)*a^6*rootOf((625*%%E0^4*a^12+(-125)*%%E0^3*a^9
  +25*%%E0^2*a^6+(-5)*%%E0*a^3+1)/(625*a^12),%%E0)+10*a^3)*rootOf((125*a^9*root
  Of((625*%%E0^4*a^12+(-125)*%%E0^3*a^9+25*%%E0^2*a^6+(-5)*%%E0*a^3+1)/(625*a^1
  2),%%E0)^3+(125*%%E1*a^9+(-25)*a^6)*rootOf((625*%%E0^4*a^12+(-125)*%%E0^3*a^9
  +25*%%E0^2*a^6+(-5)*%%E0*a^3+1)/(625*a^12),%%E0)^2+(125*%%E1^2*a^9+(-25)*%%E1
  *a^6+5*a^3)*rootOf((625*%%E0^4*a^12+(-125)*%%E0^3*a^9+25*%%E0^2*a^6+(-5)*%%E0
  *a^3+1)/(625*a^12),%%E0)+(125*%%E1^3*a^9+(-25)*%%E1^2*a^6+5*%%E1*a^3+(-1)))/(
  125*a^9),%%E1)+((-75)*a^6*rootOf((625*%%E0^4*a^12+(-125)*%%E0^3*a^9+25*%%E0^2
  *a^6+(-5)*%%E0*a^3+1)/(625*a^12),%%E0)^2+10*a^3*rootOf((625*%%E0^4*a^12+(-125
  )*%%E0^3*a^9+25*%%E0^2*a^6+(-5)*%%E0*a^3+1)/(625*a^12),%%E0)+(-3)))/(25*a^6))
  ^(1/2)+(((-125)*a^10*rootOf((625*%%E0^4*a^12+(-125)*%%E0^3*a^9+25*%%E0^2*a^6+
  (-5)*%%E0*a^3+1)/(625*a^12),%%E0)+25*a^7)*rootOf((125*a^9*rootOf((625*%%E0^4*
  a^12+(-125)*%%E0^3*a^9+25*%%E0^2*a^6+(-5)*%%E0*a^3+1)/(625*a^12),%%E0)^3+(125
  *%%E1*a^9+(-25)*a^6)*rootOf((625*%%E0^4*a^12+(-125)*%%E0^3*a^9+25*%%E0^2*a^6+
  (-5)*%%E0*a^3+1)/(625*a^12),%%E0)^2+(125*%%E1^2*a^9+(-25)*%%E1*a^6+5*a^3)*roo
  tOf((625*%%E0^4*a^12+(-125)*%%E0^3*a^9+25*%%E0^2*a^6+(-5)*%%E0*a^3+1)/(625*a^
  12),%%E0)+(125*%%E1^3*a^9+(-25)*%%E1^2*a^6+5*%%E1*a^3+(-1)))/(125*a^9),%%E1)^
  2+((-125)*a^10*rootOf((625*%%E0^4*a^12+(-125)*%%E0^3*a^9+25*%%E0^2*a^6+(-5)*%
  %E0*a^3+1)/(625*a^12),%%E0)^2+25*a^7*rootOf((625*%%E0^4*a^12+(-125)*%%E0^3*a^
  9+25*%%E0^2*a^6+(-5)*%%E0*a^3+1)/(625*a^12),%%E0)+(-5)*a^4)*rootOf((125*a^9*r
  ootOf((625*%%E0^4*a^12+(-125)*%%E0^3*a^9+25*%%E0^2*a^6+(-5)*%%E0*a^3+1)/(625*
  a^12),%%E0)^3+(125*%%E1*a^9+(-25)*a^6)*rootOf((625*%%E0^4*a^12+(-125)*%%E0^3*
  a^9+25*%%E0^2*a^6+(-5)*%%E0*a^3+1)/(625*a^12),%%E0)^2+(125*%%E1^2*a^9+(-25)*%
  %E1*a^6+5*a^3)*rootOf((625*%%E0^4*a^12+(-125)*%%E0^3*a^9+25*%%E0^2*a^6+(-5)*%
  %E0*a^3+1)/(625*a^12),%%E0)+(125*%%E1^3*a^9+(-25)*%%E1^2*a^6+5*%%E1*a^3+(-1))
  )/(125*a^9),%%E1)+(25*a^7*rootOf((625*%%E0^4*a^12+(-125)*%%E0^3*a^9+25*%%E0^2
  *a^6+(-5)*%%E0*a^3+1)/(625*a^12),%%E0)^2+(-5)*a^4*rootOf((625*%%E0^4*a^12+(-1
  25)*%%E0^3*a^9+25*%%E0^2*a^6+(-5)*%%E0*a^3+1)/(625*a^12),%%E0)+2*x)))+(10*a^3
  *rootOf((125*a^9*rootOf((625*%%E0^4*a^12+(-125)*%%E0^3*a^9+25*%%E0^2*a^6+(-5)
  *%%E0*a^3+1)/(625*a^12),%%E0)^3+(125*%%E1*a^9+(-25)*a^6)*rootOf((625*%%E0^4*a
  ^12+(-125)*%%E0^3*a^9+25*%%E0^2*a^6+(-5)*%%E0*a^3+1)/(625*a^12),%%E0)^2+(125*
  %%E1^2*a^9+(-25)*%%E1*a^6+5*a^3)*rootOf((625*%%E0^4*a^12+(-125)*%%E0^3*a^9+25
  *%%E0^2*a^6+(-5)*%%E0*a^3+1)/(625*a^12),%%E0)+(125*%%E1^3*a^9+(-25)*%%E1^2*a^
  6+5*%%E1*a^3+(-1)))/(125*a^9),%%E1)*log((125*a^10*rootOf((625*%%E0^4*a^12+(-1
  25)*%%E0^3*a^9+25*%%E0^2*a^6+(-5)*%%E0*a^3+1)/(625*a^12),%%E0)+(-25)*a^7)*roo
  tOf((125*a^9*rootOf((625*%%E0^4*a^12+(-125)*%%E0^3*a^9+25*%%E0^2*a^6+(-5)*%%E
  0*a^3+1)/(625*a^12),%%E0)^3+(125*%%E1*a^9+(-25)*a^6)*rootOf((625*%%E0^4*a^12+
  (-125)*%%E0^3*a^9+25*%%E0^2*a^6+(-5)*%%E0*a^3+1)/(625*a^12),%%E0)^2+(125*%%E1
  ^2*a^9+(-25)*%%E1*a^6+5*a^3)*rootOf((625*%%E0^4*a^12+(-125)*%%E0^3*a^9+25*%%E
  0^2*a^6+(-5)*%%E0*a^3+1)/(625*a^12),%%E0)+(125*%%E1^3*a^9+(-25)*%%E1^2*a^6+5*
  %%E1*a^3+(-1)))/(125*a^9),%%E1)^2+(125*a^10*rootOf((625*%%E0^4*a^12+(-125)*%%
  E0^3*a^9+25*%%E0^2*a^6+(-5)*%%E0*a^3+1)/(625*a^12),%%E0)^2+(-25)*a^7*rootOf((
  625*%%E0^4*a^12+(-125)*%%E0^3*a^9+25*%%E0^2*a^6+(-5)*%%E0*a^3+1)/(625*a^12),%
  %E0)+5*a^4)*rootOf((125*a^9*rootOf((625*%%E0^4*a^12+(-125)*%%E0^3*a^9+25*%%E0
  ^2*a^6+(-5)*%%E0*a^3+1)/(625*a^12),%%E0)^3+(125*%%E1*a^9+(-25)*a^6)*rootOf((6
  25*%%E0^4*a^12+(-125)*%%E0^3*a^9+25*%%E0^2*a^6+(-5)*%%E0*a^3+1)/(625*a^12),%%
  E0)^2+(125*%%E1^2*a^9+(-25)*%%E1*a^6+5*a^3)*rootOf((625*%%E0^4*a^12+(-125)*%%
  E0^3*a^9+25*%%E0^2*a^6+(-5)*%%E0*a^3+1)/(625*a^12),%%E0)+(125*%%E1^3*a^9+(-25
  )*%%E1^2*a^6+5*%%E1*a^3+(-1)))/(125*a^9),%%E1)+(125*a^10*rootOf((625*%%E0^4*a
  ^12+(-125)*%%E0^3*a^9+25*%%E0^2*a^6+(-5)*%%E0*a^3+1)/(625*a^12),%%E0)^3+(-25)
  *a^7*rootOf((625*%%E0^4*a^12+(-125)*%%E0^3*a^9+25*%%E0^2*a^6+(-5)*%%E0*a^3+1)
  /(625*a^12),%%E0)^2+5*a^4*rootOf((625*%%E0^4*a^12+(-125)*%%E0^3*a^9+25*%%E0^2
  *a^6+(-5)*%%E0*a^3+1)/(625*a^12),%%E0)+(x+(-1)*a)))+(10*a^3*rootOf((625*%%E0^
  4*a^12+(-125)*%%E0^3*a^9+25*%%E0^2*a^6+(-5)*%%E0*a^3+1)/(625*a^12),%%E0)*log(
  (-125)*a^10*rootOf((625*%%E0^4*a^12+(-125)*%%E0^3*a^9+25*%%E0^2*a^6+(-5)*%%E0
  *a^3+1)/(625*a^12),%%E0)^3+x)+(-2)*log(x+a)))))/(10*a^3)"
                                                                 Type: String
(5) -> 

I understand it is not an easy task to simplify it. But the question is why it ran out of RAM
and if this is to be expected. Now I changed all my code to put a try/except around
each time full_simplify is called.

--Nasser

Dima Pasechnik

unread,
Jun 23, 2023, 12:28:03 PM6/23/23
to sage-devel
This looks suboptimal and unclear - there are e.g. several occurrences of 

rootOf((625*%%E0^4*a
  ^12+(-125)*%%E0^3*a^9+25*%%E0^2*a^6+(-5)*%%E0*a^3+1)/(625*a^12),%%E0)


Do these occurrences correspond to just one fixed root?
(and so one can write it as the sum over all the roots, divided by the number of roots)





Nils Bruin

unread,
Jun 23, 2023, 12:36:30 PM6/23/23
to sage-devel
On Friday, 23 June 2023 at 17:28:03 UTC+1 Dima Pasechnik wrote:
This looks suboptimal and unclear - there are e.g. several occurrences of 

rootOf((625*%%E0^4*a
  ^12+(-125)*%%E0^3*a^9+25*%%E0^2*a^6+(-5)*%%E0*a^3+1)/(625*a^12),%%E0)
Apart from parsing problems inherent in not knowing  which roots are meant exactly, translation of these expressions to sage's internal symbolic system and maximalib (where it ends up judging from the ECL error) is problematic because neiither has a native object to represent RootOf. So these expressions cannot really be handled anyway and simplification is unnlikely to do something useful. Better simplify in fricas.

Considering memory errors from large simplification tasks: yes, simplification (particularly full simplification) can involve some algorithms with very high time and space complexities, so seeing memory errors is not surprising by itself.
 

Emmanuel Charpentier

unread,
Jun 23, 2023, 1:08:59 PM6/23/23
to sage-devel
FWIW:

```
sage: a, x = var("a, x")
sage: Ex0=x/(a^5+x^5)
sage: FE1=Ex0.integrate(x, algorithm="fricas")
sage: len(repr(FE1))
47199
```

Fricas may be out of joint here... FWIW, I have been unable to typeset this expression with neither `pdflate` nor `xelatex`. The only way I had to visualize it was to compute it in a Jupyter worksheet, where Mathjax gave me a giant expression, explorable only thanks to the side bars (estimated size about 4 (kinfg size) bedsheets...).

More on this later.

I note that Sage's default integrator gives a much "smaller" answer : 

```sage: %time SE1=Ex0.integrate(x) # Use Sage's (=Maxima's) default integrator
CPU times: user 14.2 ms, sys: 0 ns, total: 14.2 ms
Wall time: 22.1 ms
sage: len(repr(SE1))
607
sage: SE1
-1/5*log(x + (a^5)^(1/5))/(a^5)^(3/5) + 1/5*sqrt(5)*log(((a^5)^(1/5)*(sqrt(5) + 1) - 4*x + (a^5)^(1/5)*sqrt(2*sqrt(5) - 10))/((a^5)^(1/5)*(sqrt(5) + 1) - 4*x - (a^5)^(1/5)*sqrt(2*sqrt(5) - 10)))/((a^5)^(3/5)*sqrt(2*sqrt(5) - 10)) - 1/5*sqrt(5)*log(((a^5)^(1/5)*(sqrt(5) - 1) + 4*x - (a^5)^(1/5)*sqrt(-2*sqrt(5) - 10))/((a^5)^(1/5)*(sqrt(5) - 1) + 4*x + (a^5)^(1/5)*sqrt(-2*sqrt(5) - 10)))/((a^5)^(3/5)*sqrt(-2*sqrt(5) - 10)) - 1/5*log(-(a^5)^(1/5)*x*(sqrt(5) + 1) + 2*x^2 + 2*(a^5)^(2/5))/((a^5)^(3/5)*(sqrt(5) + 1)) + 1/5*log((a^5)^(1/5)*x*(sqrt(5) - 1) + 2*x^2 + 2*(a^5)^(2/5))/((a^5)^(3/5)*(sqrt(5) - 1))
```

which *does* differentiate back to the original expression :

```
sage: SE1.diff(x).simplify_full()
x/(a^5 + x^5)
```
 
Fly in the ointment : this expression does not plot : Sage fails to compute a real value  for `a=1` and `x` in (-2, 2). This may be attributable to the numerous fifth roots occuring in the expression.

Mathematica's results are different :

```
sage: mathematica.Integrate(Ex0, x).sage().simplify_full()
-1/20*((sqrt(5) - 1)*log(-1/2*a*x*(sqrt(5) + 1) + a^2 + x^2) - (sqrt(5) + 1)*log(1/2*a*x*(sqrt(5) - 1) + a^2 + x^2) + 2*sqrt(-2*sqrt(5) + 10)*arctan((a*(sqrt(5) - 1) + 4*x)/(a*sqrt(2*sqrt(5) + 10))) + 2*sqrt(2*sqrt(5) + 10)*arctan((a*(sqrt(5) + 1) - 4*x)/(a*sqrt(-2*sqrt(5) + 10))) + 4*log(a + x))/a^3
```

This expression, with `a=1`, *does* plot as real for x>-1 to x=2.

Nasser M. Abbasi

unread,
Jun 24, 2023, 12:38:35 AM6/24/23
to sage-devel
" yes, simplification (particularly full simplification) can involve some algorithms with very high time and space complexities, so seeing memory errors is not surprising by itself."

Yes, I know this. But I had to use full_simplify() as simplify() does not do the job on some basic expressions. Here is an example using V 10.0

sage: var('x')
x

sage: expr=(1-x)^3+(-x^2+x)^3+(x^2-1)^3-3*(1-x)*(-x^2+x)*(x^2-1)

sage: expr.simplify()
-(x^2 - x)^3 + (x^2 - 1)^3 - 3*(x^2 - x)*(x^2 - 1)*(x - 1) - (x - 1)^3

sage: expr.full_simplify()
0

I think simplify should have been able to do it? in Mathematica Simplify can and no need to use its FullSimplify which also uses more resources than Simplify. But I understand, simplification is not an easy problem and different systems do things differently.

So instead of keeping trying, I was using full_simplify() instead of simplify() but this causes problems in some cases.

--Nasser

Emmanuel Charpentier

unread,
Jun 24, 2023, 3:40:16 AM6/24/23
to sage-devel

FWIW :

sage: reset() sage: expr=(1-x)^3+(-x^2+x)^3+(x^2-1)^3-3*(1-x)*(-x^2+x)*(x^2-1) sage: expr.is_zero() True

full_simplify may not be necessary…

HTH,

Emmanuel Charpentier

unread,
Jun 24, 2023, 3:42:17 AM6/24/23
to sage-devel

Similarly :

sage: expr.expand() 0 sage: expr.factor() 0

HTH,

Nils Bruin

unread,
Jun 24, 2023, 4:35:54 AM6/24/23
to sage-devel
On Saturday, 24 June 2023 at 05:38:35 UTC+1 Nasser M. Abbasi wrote:
I think simplify should have been able to do it? in Mathematica Simplify can and no need to use its FullSimplify which also uses more resources than Simplify. But I understand, simplification is not an easy problem and different systems do things differently.

simplify isn't even a mathematically well-defined notion. Different computer algebra systems make different choices what transformations they attempt. Maxima, from which sagemath still gets a significant amount of its symbolic capabilities, doesn't have a "simplify", but instead has several "simplify_*" routines that try specific rewrite strategies, focussing on particular special function properties. As the documentation and code show, presently "simplify" just consists of a round-trip to maxima, so it only rewrites expressions to the extent that maxima automatically rewrites expressions. That's a very weak kind of "simplification". The documentation points to several other routines. simplify_full tries a whole bunch of them, including some that may not be valid for all specializations of your variables (e.g., (1-x^)2/(1-x) :-> (1+x) )
Reply all
Reply to author
Forward
0 new messages