Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

still getting Malform expression using giac in 9.6

I am using sagemath 9.6 with latest giac 1.9.0-7

I am not using giac that comes with sagemath 9.6 since that is old. So I points it to use the latest giac outside of sagemath.

Here is an example of such problem

>sage
┌────────────────────────────────────────────────────────────────────┐
│ SageMath version 9.6, Release Date: 2022-05-15                     │
│ Using Python 3.10.4. Type "help()" for help.                       │
└────────────────────────────────────────────────────────────────────┘
sage: var('x,b')
(x, b)

sage: integrate(x^(3/2)*(b*x+2)^(1/2),x,algorithm="giac")
---------------------------------------------------------------------------
SyntaxError                               Traceback (most recent call last)
~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/interfaces/giac.py in _sage_(self, locals)
   1138             try:
-> 1139                 return symbolic_expression_from_string(result, lsymbols,
   1140                     accept_sequence=True, parser=SR_parser_giac)

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/calculus/calculus.py in symbolic_expression_from_string(s, syms, accept_sequence, parser)
   2568                                               if _is_function(v)})
-> 2569     return parse_func(s)
   2570

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/misc/parser.pyx in sage.misc.parser.Parser.parse_sequence (build/cythonized/sage/misc/parser.c:6025)()
    574
--> 575     cpdef parse_sequence(self, s):
    576         """

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/misc/parser.pyx in sage.misc.parser.Parser.parse_sequence (build/cythonized/sage/misc/parser.c:5912)()
    592         if tokens.next() != EOS:
--> 593             self.parse_error(tokens)
    594         if len(all) == 1 and isinstance(all, list):

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/misc/parser.pyx in sage.misc.parser.Parser.parse_error (build/cythonized/sage/misc/parser.c:10396)()
   1043     cdef parse_error(self, Tokenizer tokens, msg="Malformed expression"):
-> 1044         raise SyntaxError(msg, tokens.s, tokens.pos)
   1045

SyntaxError: Malformed expression

During handling of the above exception, another exception occurred:

NotImplementedError                       Traceback (most recent call last)
<ipython-input-6-2f599f779b32> in <module>
----> 1 integrate(x**(Integer(3)/Integer(2))*(b*x+Integer(2))**(Integer(1)/Integer(2)),x,algorithm="giac")

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/misc/functional.py in integral(x, *args, **kwds)
    762     """
    763     if hasattr(x, 'integral'):
--> 764         return x.integral(*args, **kwds)
    765     else:
    766         from sage.symbolic.ring import SR

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/symbolic/expression.pyx in sage.symbolic.expression.Expression.integral (build/cythonized/sage/symbolic/expression.cpp:95445)()
  13192                     R = SR
  13193             return R(integral(f, v, a, b, **kwds))
> 13194         return integral(self, *args, **kwds)
  13195
  13196     integrate = integral

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/symbolic/integration/integral.py in integrate(expression, v, a, b, algorithm, hold)
   1045         if not integrator:
   1046             raise ValueError("Unknown algorithm: %s" % algorithm)
-> 1047         return integrator(expression, v, a, b)
   1048     if a is None:
   1049         return indefinite_integral(expression, v, hold=hold)

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/symbolic/integration/external.py in giac_integrator(expression, v, a, b)
    256         return expression.integrate(v, a, b, hold=True)
    257     else:
--> 258         return result._sage_()
    259
    260 def libgiac_integrator(expression, v, a=None, b=None):

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/interfaces/giac.py in _sage_(self, locals)
   1141
   1142             except Exception:
-> 1143                 raise NotImplementedError("Unable to parse Giac output: %s" % result)
   1144         else:
   1145             return [entry.sage() for entry in self]

NotImplementedError: Unable to parse Giac output: Warning, choosing root of [1,0,%%%{-4,[1,1]%%%}+%%%{-4,[1,0]%%%}+%%%{-4,[0,1]%%%}+%%%{-8,[0,0]%%%},0,%%%{6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}+%%%{-128,[1,1]%%%}+%%%{16,[1,0]%%%}+%%%{-4,[0,3]%%%}+%%%{8,[0,2]%%%}+%%%{16,[0,1]%%%}+%%%{-32,[0,0]%%%},0,%%%{1,[4,4]%%%}+%%%{-4,[4,3]%%%}+%%%{6,[4,2]%%%}+%%%{-4,[4,1]%%%}+%%%{1,[4,0]%%%}+%%%{-4,[3,4]%%%}+%%%{12,[3,3]%%%}+%%%{-20,[3,2]%%%}+%%%{20,[3,1]%%%}+%%%{-8,[3,0]%%%}+%%%{6,[2,4]%%%}+%%%{-20,[2,3]%%%}+%%%{46,[2,2]%%%}+%%%{-40,[2,1]%%%}+%%%{24,[2,0]%%%}+%%%{-4,[1,4]%%%}+%%%{20,[1,3]%%%}+%%%{-40,[1,2]%%%}+%%%{48,[1,1]%%%}+%%%{-32,[1,0]%%%}+%%%{1,[0,4]%%%}+%%%{-8,[0,3]%%%}+%%%{24,[0,2]%%%}+%%%{-32,[0,1]%%%}+%%%{16,[0,0]%%%}] at parameters values [18.4052062202,51.6443148847]

1/sageVARb*(2*sageVARb*abs(sageVARb)/sageVARb^2*(2*((12*sageVARb^5/144/sageVARb^7*sqrt(sageVARb*sageVARx+2)*sqrt(sageVARb*sageVARx+2)-78*sageVARb^5/144/sageVARb^7)*sqrt(sageVARb*sageVARx+2)*sqrt(sageVARb*sageVARx+2)+198*sageVARb^5/144/sageVARb^7)*sqrt(sageVARb*sageVARx+2)*sqrt(sageVARb*(sageVARb*sageVARx+2)-2*sageVARb)+5/2/sageVARb/sqrt(sageVARb)*ln(abs(sqrt(sageVARb*(sageVARb*sageVARx+2)-2*sageVARb)-sqrt(sageVARb)*sqrt(sageVARb*sageVARx+2))))+4*abs(sageVARb)/sageVARb^2/sageVARb*(2*(1/8*sqrt(sageVARb*sageVARx+2)*sqrt(sageVARb*sageVARx+2)-5/8)*sqrt(sageVARb*sageVARx+2)*sqrt(sageVARb*(sageVARb*sageVARx+2)-2*sageVARb)-6*sageVARb/4/sqrt(sageVARb)*ln(abs(sqrt(sageVARb*(sageVARb*sageVARx+2)-2*sageVARb)-sqrt(sageVARb)*sqrt(sageVARb*sageVARx+2)))))
sage:

But when using giac directly, it works with no errors

>giac
// Using locale /usr/local/share/locale/
// C.UTF-8
// /usr/local/share/locale/
// giac
// UTF-8
// Maximum number of parallel threads 24
Added 0 synonyms
Welcome to giac readline interface, version 1.9.0
(c) 2001,2021 B. Parisse & others
Homepage http://www-fourier.ujf-grenoble.fr/~parisse/giac.html
Released under the GPL license 3.0 or above
See http://www.gnu.org for license details
May contain BSD licensed software parts (lapack, atlas, tinymt)
-------------------------------------------------
Press CTRL and D simultaneously to finish session
Type ?commandname for help
0>> integrate( x^(3/2)*(b*x+2)^(1/2),x)
2*(2*((12*b^4*1/144/b^4*sqrt(x)*sqrt(x)+6*b^3*1/144/b^4)*sqrt(x)*sqrt(x)-18*b^2*1/144/b^4)*sqrt(x)*sqrt(b*x+2)-1/2/b^2/sqrt(b)*ln(sqrt(b*x+2)-sqrt(b)*sqrt(x)))
// Time 0.01
1>>

Here are more information

>which sage
/home/me/DATA/sage-9.6/sage
>sage --version
SageMath version 9.6, Release Date: 2022-05-15
>which giac
/usr/local/bin/giac
>giac --version
// Using locale /usr/local/share/locale/
// C.UTF-8
// /usr/local/share/locale/
// giac
// UTF-8
// Maximum number of parallel threads 24
// (c) 2001, 2021 B. Parisse & others
1.9.0

>cat /etc/*-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=22.04
DISTRIB_CODENAME=jammy
DISTRIB_DESCRIPTION="Ubuntu 22.04 LTS"
PRETTY_NAME="Ubuntu 22.04 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04 LTS (Jammy Jellyfish)"
VERSION_CODENAME=jammy

I see many integrals that fail the same way using giac. I was hoping this will be fixed in sage 9.6

Any idea what is going on?

still getting Malform expression using giac in 9.6

I am using sagemath 9.6 with latest giac 1.9.0-7

I am not using giac that comes with sagemath 9.6 since that is old. So I points it to use the latest giac outside of sagemath.

Here is an example of such problem

>sage
┌────────────────────────────────────────────────────────────────────┐
│ SageMath version 9.6, Release Date: 2022-05-15                     │
│ Using Python 3.10.4. Type "help()" for help.                       │
└────────────────────────────────────────────────────────────────────┘
sage: var('x,b')
(x, b)

sage: integrate(x^(3/2)*(b*x+2)^(1/2),x,algorithm="giac")
---------------------------------------------------------------------------
SyntaxError                               Traceback (most recent call last)
~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/interfaces/giac.py in _sage_(self, locals)
   1138             try:
-> 1139                 return symbolic_expression_from_string(result, lsymbols,
   1140                     accept_sequence=True, parser=SR_parser_giac)

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/calculus/calculus.py in symbolic_expression_from_string(s, syms, accept_sequence, parser)
   2568                                               if _is_function(v)})
-> 2569     return parse_func(s)
   2570

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/misc/parser.pyx in sage.misc.parser.Parser.parse_sequence (build/cythonized/sage/misc/parser.c:6025)()
    574
--> 575     cpdef parse_sequence(self, s):
    576         """

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/misc/parser.pyx in sage.misc.parser.Parser.parse_sequence (build/cythonized/sage/misc/parser.c:5912)()
    592         if tokens.next() != EOS:
--> 593             self.parse_error(tokens)
    594         if len(all) == 1 and isinstance(all, list):

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/misc/parser.pyx in sage.misc.parser.Parser.parse_error (build/cythonized/sage/misc/parser.c:10396)()
   1043     cdef parse_error(self, Tokenizer tokens, msg="Malformed expression"):
-> 1044         raise SyntaxError(msg, tokens.s, tokens.pos)
   1045

SyntaxError: Malformed expression

During handling of the above exception, another exception occurred:

NotImplementedError                       Traceback (most recent call last)
<ipython-input-6-2f599f779b32> in <module>
----> 1 integrate(x**(Integer(3)/Integer(2))*(b*x+Integer(2))**(Integer(1)/Integer(2)),x,algorithm="giac")

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/misc/functional.py in integral(x, *args, **kwds)
    762     """
    763     if hasattr(x, 'integral'):
--> 764         return x.integral(*args, **kwds)
    765     else:
    766         from sage.symbolic.ring import SR

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/symbolic/expression.pyx in sage.symbolic.expression.Expression.integral (build/cythonized/sage/symbolic/expression.cpp:95445)()
  13192                     R = SR
  13193             return R(integral(f, v, a, b, **kwds))
> 13194         return integral(self, *args, **kwds)
  13195
  13196     integrate = integral

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/symbolic/integration/integral.py in integrate(expression, v, a, b, algorithm, hold)
   1045         if not integrator:
   1046             raise ValueError("Unknown algorithm: %s" % algorithm)
-> 1047         return integrator(expression, v, a, b)
   1048     if a is None:
   1049         return indefinite_integral(expression, v, hold=hold)

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/symbolic/integration/external.py in giac_integrator(expression, v, a, b)
    256         return expression.integrate(v, a, b, hold=True)
    257     else:
--> 258         return result._sage_()
    259
    260 def libgiac_integrator(expression, v, a=None, b=None):

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/interfaces/giac.py in _sage_(self, locals)
   1141
   1142             except Exception:
-> 1143                 raise NotImplementedError("Unable to parse Giac output: %s" % result)
   1144         else:
   1145             return [entry.sage() for entry in self]

NotImplementedError: Unable to parse Giac output: Warning, choosing root of [1,0,%%%{-4,[1,1]%%%}+%%%{-4,[1,0]%%%}+%%%{-4,[0,1]%%%}+%%%{-8,[0,0]%%%},0,%%%{6,[2,2]%%%}+%%%{4,[2,1]%%%}+%%%{6,[2,0]%%%}+%%%{4,[1,2]%%%}+%%%{28,[1,1]%%%}+%%%{8,[1,0]%%%}+%%%{6,[0,2]%%%}+%%%{8,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%%%}+%%%{-4,[4,3]%%%}+%%%{6,[4,2]%%%}+%%%{-4,[4,1]%%%}+%%%{1,[4,0]%%%}+%%%{-4,[3,4]%%%}+%%%{12,[3,3]%%%}+%%%{-20,[3,2]%%%}+%%%{20,[3,1]%%%}+%%%{-8,[3,0]%%%}+%%%{6,[2,4]%%%}+%%%{-20,[2,3]%%%}+%%%{46,[2,2]%%%}+%%%{-40,[2,1]%%%}+%%%{24,[2,0]%%%}+%%%{-4,[1,4]%%%}+%%%{20,[1,3]%%%}+%%%{-40,[1,2]%%%}+%%%{48,[1,1]%%%}+%%%{-32,[1,0]%%%}+%%%{1,[0,4]%%%}+%%%{-8,[0,3]%%%}+%%%{24,[0,2]%%%}+%%%{-32,[0,1]%%%}+%%%{16,[0,0]%%%}] at parameters values [18.4052062202,51.6443148847]

1/sageVARb*(2*sageVARb*abs(sageVARb)/sageVARb^2*(2*((12*sageVARb^5/144/sageVARb^7*sqrt(sageVARb*sageVARx+2)*sqrt(sageVARb*sageVARx+2)-78*sageVARb^5/144/sageVARb^7)*sqrt(sageVARb*sageVARx+2)*sqrt(sageVARb*sageVARx+2)+198*sageVARb^5/144/sageVARb^7)*sqrt(sageVARb*sageVARx+2)*sqrt(sageVARb*(sageVARb*sageVARx+2)-2*sageVARb)+5/2/sageVARb/sqrt(sageVARb)*ln(abs(sqrt(sageVARb*(sageVARb*sageVARx+2)-2*sageVARb)-sqrt(sageVARb)*sqrt(sageVARb*sageVARx+2))))+4*abs(sageVARb)/sageVARb^2/sageVARb*(2*(1/8*sqrt(sageVARb*sageVARx+2)*sqrt(sageVARb*sageVARx+2)-5/8)*sqrt(sageVARb*sageVARx+2)*sqrt(sageVARb*(sageVARb*sageVARx+2)-2*sageVARb)-6*sageVARb/4/sqrt(sageVARb)*ln(abs(sqrt(sageVARb*(sageVARb*sageVARx+2)-2*sageVARb)-sqrt(sageVARb)*sqrt(sageVARb*sageVARx+2)))))
sage:

But when using giac directly, it works with no errors

>giac
// Using locale /usr/local/share/locale/
// C.UTF-8
// /usr/local/share/locale/
// giac
// UTF-8
// Maximum number of parallel threads 24
Added 0 synonyms
Welcome to giac readline interface, version 1.9.0
(c) 2001,2021 B. Parisse & others
Homepage http://www-fourier.ujf-grenoble.fr/~parisse/giac.html
Released under the GPL license 3.0 or above
See http://www.gnu.org for license details
May contain BSD licensed software parts (lapack, atlas, tinymt)
-------------------------------------------------
Press CTRL and D simultaneously to finish session
Type ?commandname for help
0>> integrate( x^(3/2)*(b*x+2)^(1/2),x)
2*(2*((12*b^4*1/144/b^4*sqrt(x)*sqrt(x)+6*b^3*1/144/b^4)*sqrt(x)*sqrt(x)-18*b^2*1/144/b^4)*sqrt(x)*sqrt(b*x+2)-1/2/b^2/sqrt(b)*ln(sqrt(b*x+2)-sqrt(b)*sqrt(x)))
// Time 0.01
1>>

Here are more information

>which sage
/home/me/DATA/sage-9.6/sage
>sage --version
SageMath version 9.6, Release Date: 2022-05-15
>which giac
/usr/local/bin/giac
>giac --version
// Using locale /usr/local/share/locale/
// C.UTF-8
// /usr/local/share/locale/
// giac
// UTF-8
// Maximum number of parallel threads 24
// (c) 2001, 2021 B. Parisse & others
1.9.0

>cat /etc/*-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=22.04
DISTRIB_CODENAME=jammy
DISTRIB_DESCRIPTION="Ubuntu 22.04 LTS"
PRETTY_NAME="Ubuntu 22.04 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04 LTS (Jammy Jellyfish)"
VERSION_CODENAME=jammy


>$SAGE_ROOT/sage --version
 SageMath version 9.6, Release Date: 2022-05-15

>cd $SAGE_ROOT/local/bin

>ls -l giac
lrwxrwxrwx 1 me me 19 May 16 17:02 giac -> /usr/local/bin/giac
>

I see many integrals that fail the same way using giac. I was hoping this will be fixed in sage 9.6

Any idea what is going on? on?

still getting Malform expression using giac in 9.6

I am using sagemath 9.6 with latest giac 1.9.0-7

I am not using giac that comes with sagemath 9.6 since that is old. So I points it to use the latest giac outside of sagemath.

Here is an example of such problem

>sage
┌────────────────────────────────────────────────────────────────────┐
│ SageMath version 9.6, Release Date: 2022-05-15                     │
│ Using Python 3.10.4. Type "help()" for help.                       │
└────────────────────────────────────────────────────────────────────┘
sage: var('x,b')
(x, b)

sage: integrate(x^(3/2)*(b*x+2)^(1/2),x,algorithm="giac")
---------------------------------------------------------------------------
SyntaxError                               Traceback (most recent call last)
~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/interfaces/giac.py in _sage_(self, locals)
   1138             try:
-> 1139                 return symbolic_expression_from_string(result, lsymbols,
   1140                     accept_sequence=True, parser=SR_parser_giac)

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/calculus/calculus.py in symbolic_expression_from_string(s, syms, accept_sequence, parser)
   2568                                               if _is_function(v)})
-> 2569     return parse_func(s)
   2570

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/misc/parser.pyx in sage.misc.parser.Parser.parse_sequence (build/cythonized/sage/misc/parser.c:6025)()
    574
--> 575     cpdef parse_sequence(self, s):
    576         """

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/misc/parser.pyx in sage.misc.parser.Parser.parse_sequence (build/cythonized/sage/misc/parser.c:5912)()
    592         if tokens.next() != EOS:
--> 593             self.parse_error(tokens)
    594         if len(all) == 1 and isinstance(all, list):

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/misc/parser.pyx in sage.misc.parser.Parser.parse_error (build/cythonized/sage/misc/parser.c:10396)()
   1043     cdef parse_error(self, Tokenizer tokens, msg="Malformed expression"):
-> 1044         raise SyntaxError(msg, tokens.s, tokens.pos)
   1045

SyntaxError: Malformed expression

During handling of the above exception, another exception occurred:

NotImplementedError                       Traceback (most recent call last)
<ipython-input-6-2f599f779b32> in <module>
----> 1 integrate(x**(Integer(3)/Integer(2))*(b*x+Integer(2))**(Integer(1)/Integer(2)),x,algorithm="giac")

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/misc/functional.py in integral(x, *args, **kwds)
    762     """
    763     if hasattr(x, 'integral'):
--> 764         return x.integral(*args, **kwds)
    765     else:
    766         from sage.symbolic.ring import SR

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/symbolic/expression.pyx in sage.symbolic.expression.Expression.integral (build/cythonized/sage/symbolic/expression.cpp:95445)()
  13192                     R = SR
  13193             return R(integral(f, v, a, b, **kwds))
> 13194         return integral(self, *args, **kwds)
  13195
  13196     integrate = integral

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/symbolic/integration/integral.py in integrate(expression, v, a, b, algorithm, hold)
   1045         if not integrator:
   1046             raise ValueError("Unknown algorithm: %s" % algorithm)
-> 1047         return integrator(expression, v, a, b)
   1048     if a is None:
   1049         return indefinite_integral(expression, v, hold=hold)

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/symbolic/integration/external.py in giac_integrator(expression, v, a, b)
    256         return expression.integrate(v, a, b, hold=True)
    257     else:
--> 258         return result._sage_()
    259
    260 def libgiac_integrator(expression, v, a=None, b=None):

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/interfaces/giac.py in _sage_(self, locals)
   1141
   1142             except Exception:
-> 1143                 raise NotImplementedError("Unable to parse Giac output: %s" % result)
   1144         else:
   1145             return [entry.sage() for entry in self]

NotImplementedError: Unable to parse Giac output: Warning, choosing root of [1,0,%%%{-4,[1,1]%%%}+%%%{-4,[1,0]%%%}+%%%{-4,[0,1]%%%}+%%%{-8,[0,0]%%%},0,%%%{6,[2,2]%%%}+%%%{4,[2,1]%%%}+%%%{6,[2,0]%%%}+%%%{4,[1,2]%%%}+%%%{28,[1,1]%%%}+%%%{8,[1,0]%%%}+%%%{6,[0,2]%%%}+%%%{8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]%%%}+%%%{-4,[4,3]%%%}+%%%{6,[4,2]%%%}+%%%{-4,[4,1]%%%}+%%%{1,[4,0]%%%}+%%%{-4,[3,4]%%%}+%%%{12,[3,3]%%%}+%%%{-20,[3,2]%%%}+%%%{20,[3,1]%%%}+%%%{-8,[3,0]%%%}+%%%{6,[2,4]%%%}+%%%{-20,[2,3]%%%}+%%%{46,[2,2]%%%}+%%%{-40,[2,1]%%%}+%%%{24,[2,0]%%%}+%%%{-4,[1,4]%%%}+%%%{20,[1,3]%%%}+%%%{-40,[1,2]%%%}+%%%{48,[1,1]%%%}+%%%{-32,[1,0]%%%}+%%%{1,[0,4]%%%}+%%%{-8,[0,3]%%%}+%%%{24,[0,2]%%%}+%%%{-32,[0,1]%%%}+%%%{16,[0,0]%%%}] at parameters values [18.4052062202,51.6443148847]

1/sageVARb*(2*sageVARb*abs(sageVARb)/sageVARb^2*(2*((12*sageVARb^5/144/sageVARb^7*sqrt(sageVARb*sageVARx+2)*sqrt(sageVARb*sageVARx+2)-78*sageVARb^5/144/sageVARb^7)*sqrt(sageVARb*sageVARx+2)*sqrt(sageVARb*sageVARx+2)+198*sageVARb^5/144/sageVARb^7)*sqrt(sageVARb*sageVARx+2)*sqrt(sageVARb*(sageVARb*sageVARx+2)-2*sageVARb)+5/2/sageVARb/sqrt(sageVARb)*ln(abs(sqrt(sageVARb*(sageVARb*sageVARx+2)-2*sageVARb)-sqrt(sageVARb)*sqrt(sageVARb*sageVARx+2))))+4*abs(sageVARb)/sageVARb^2/sageVARb*(2*(1/8*sqrt(sageVARb*sageVARx+2)*sqrt(sageVARb*sageVARx+2)-5/8)*sqrt(sageVARb*sageVARx+2)*sqrt(sageVARb*(sageVARb*sageVARx+2)-2*sageVARb)-6*sageVARb/4/sqrt(sageVARb)*ln(abs(sqrt(sageVARb*(sageVARb*sageVARx+2)-2*sageVARb)-sqrt(sageVARb)*sqrt(sageVARb*sageVARx+2)))))
sage:

But when using giac directly, it works with no errors

>giac
// Using locale /usr/local/share/locale/
// C.UTF-8
// /usr/local/share/locale/
// giac
// UTF-8
// Maximum number of parallel threads 24
Added 0 synonyms
Welcome to giac readline interface, version 1.9.0
(c) 2001,2021 B. Parisse & others
Homepage http://www-fourier.ujf-grenoble.fr/~parisse/giac.html
Released under the GPL license 3.0 or above
See http://www.gnu.org for license details
May contain BSD licensed software parts (lapack, atlas, tinymt)
-------------------------------------------------
Press CTRL and D simultaneously to finish session
Type ?commandname for help
0>> integrate( x^(3/2)*(b*x+2)^(1/2),x)
2*(2*((12*b^4*1/144/b^4*sqrt(x)*sqrt(x)+6*b^3*1/144/b^4)*sqrt(x)*sqrt(x)-18*b^2*1/144/b^4)*sqrt(x)*sqrt(b*x+2)-1/2/b^2/sqrt(b)*ln(sqrt(b*x+2)-sqrt(b)*sqrt(x)))
// Time 0.01
1>>

Here are more information

>which sage
/home/me/DATA/sage-9.6/sage
>sage --version
SageMath version 9.6, Release Date: 2022-05-15
>which giac
/usr/local/bin/giac
>giac --version
// Using locale /usr/local/share/locale/
// C.UTF-8
// /usr/local/share/locale/
// giac
// UTF-8
// Maximum number of parallel threads 24
// (c) 2001, 2021 B. Parisse & others
1.9.0

>cat /etc/*-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=22.04
DISTRIB_CODENAME=jammy
DISTRIB_DESCRIPTION="Ubuntu 22.04 LTS"
PRETTY_NAME="Ubuntu 22.04 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04 LTS (Jammy Jellyfish)"
VERSION_CODENAME=jammy


>$SAGE_ROOT/sage --version
 SageMath version 9.6, Release Date: 2022-05-15

>cd $SAGE_ROOT/local/bin

>ls -l giac
lrwxrwxrwx 1 me me 19 May 16 17:02 giac -> /usr/local/bin/giac
>

I see many integrals that fail the same way using giac. I was hoping this will be fixed in sage 9.6

Where is choosing root of message coming from? As when calling giac directly, I see no such message displayed. Is sagemath reading additionl output from giac somehow that do not show up on the terminal when using giac directly?

Any idea what is going on?

still getting Malform expression using giac in 9.6

I am using sagemath 9.6 with latest giac 1.9.0-7 1.9.0-7

I am not using giac that comes with sagemath 9.6 since that is old. So I points it to use the latest giac outside of sagemath.

Here is an example of such problem

>sage
┌────────────────────────────────────────────────────────────────────┐
│ SageMath version 9.6, Release Date: 2022-05-15                     │
│ Using Python 3.10.4. Type "help()" for help.                       │
└────────────────────────────────────────────────────────────────────┘
sage: var('x,b')
(x, b)

sage: integrate(x^(3/2)*(b*x+2)^(1/2),x,algorithm="giac")
---------------------------------------------------------------------------
SyntaxError                               Traceback (most recent call last)
~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/interfaces/giac.py in _sage_(self, locals)
   1138             try:
-> 1139                 return symbolic_expression_from_string(result, lsymbols,
   1140                     accept_sequence=True, parser=SR_parser_giac)

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/calculus/calculus.py in symbolic_expression_from_string(s, syms, accept_sequence, parser)
   2568                                               if _is_function(v)})
-> 2569     return parse_func(s)
   2570

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/misc/parser.pyx in sage.misc.parser.Parser.parse_sequence (build/cythonized/sage/misc/parser.c:6025)()
    574
--> 575     cpdef parse_sequence(self, s):
    576         """

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/misc/parser.pyx in sage.misc.parser.Parser.parse_sequence (build/cythonized/sage/misc/parser.c:5912)()
    592         if tokens.next() != EOS:
--> 593             self.parse_error(tokens)
    594         if len(all) == 1 and isinstance(all, list):

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/misc/parser.pyx in sage.misc.parser.Parser.parse_error (build/cythonized/sage/misc/parser.c:10396)()
   1043     cdef parse_error(self, Tokenizer tokens, msg="Malformed expression"):
-> 1044         raise SyntaxError(msg, tokens.s, tokens.pos)
   1045

SyntaxError: Malformed expression

During handling of the above exception, another exception occurred:

NotImplementedError                       Traceback (most recent call last)
<ipython-input-6-2f599f779b32> in <module>
----> 1 integrate(x**(Integer(3)/Integer(2))*(b*x+Integer(2))**(Integer(1)/Integer(2)),x,algorithm="giac")

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/misc/functional.py in integral(x, *args, **kwds)
    762     """
    763     if hasattr(x, 'integral'):
--> 764         return x.integral(*args, **kwds)
    765     else:
    766         from sage.symbolic.ring import SR

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/symbolic/expression.pyx in sage.symbolic.expression.Expression.integral (build/cythonized/sage/symbolic/expression.cpp:95445)()
  13192                     R = SR
  13193             return R(integral(f, v, a, b, **kwds))
> 13194         return integral(self, *args, **kwds)
  13195
  13196     integrate = integral

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/symbolic/integration/integral.py in integrate(expression, v, a, b, algorithm, hold)
   1045         if not integrator:
   1046             raise ValueError("Unknown algorithm: %s" % algorithm)
-> 1047         return integrator(expression, v, a, b)
   1048     if a is None:
   1049         return indefinite_integral(expression, v, hold=hold)

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/symbolic/integration/external.py in giac_integrator(expression, v, a, b)
    256         return expression.integrate(v, a, b, hold=True)
    257     else:
--> 258         return result._sage_()
    259
    260 def libgiac_integrator(expression, v, a=None, b=None):

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/interfaces/giac.py in _sage_(self, locals)
   1141
   1142             except Exception:
-> 1143                 raise NotImplementedError("Unable to parse Giac output: %s" % result)
   1144         else:
   1145             return [entry.sage() for entry in self]

NotImplementedError: Unable to parse Giac output: Warning, choosing root of [1,0,%%%{-4,[1,1]%%%}+%%%{-4,[1,0]%%%}+%%%{-4,[0,1]%%%}+%%%{-8,[0,0]%%%},0,%%%{6,[2,2]%%%}+%%%{4,[2,1]%%%}+%%%{6,[2,0]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{-4,[0,3]%%%}+%%%{8,[0,2]%%%}+%%%{16,[0,1]%%%}+%%%{-32,[0,0]%%%},0,%%%{1,[4,4]%%%}+%%%{-4,[4,3]%%%}+%%%{6,[4,2]%%%}+%%%{-4,[4,1]%%%}+%%%{1,[4,0]%%%}+%%%{-4,[3,4]%%%}+%%%{12,[3,3]%%%}+%%%{-20,[3,2]%%%}+%%%{20,[3,1]%%%}+%%%{-8,[3,0]%%%}+%%%{6,[2,4]%%%}+%%%{-20,[2,3]%%%}+%%%{46,[2,2]%%%}+%%%{-40,[2,1]%%%}+%%%{24,[2,0]%%%}+%%%{-4,[1,4]%%%}+%%%{20,[1,3]%%%}+%%%{-40,[1,2]%%%}+%%%{48,[1,1]%%%}+%%%{-32,[1,0]%%%}+%%%{1,[0,4]%%%}+%%%{-8,[0,3]%%%}+%%%{24,[0,2]%%%}+%%%{-32,[0,1]%%%}+%%%{16,[0,0]%%%}] at parameters values [18.4052062202,51.6443148847]

1/sageVARb*(2*sageVARb*abs(sageVARb)/sageVARb^2*(2*((12*sageVARb^5/144/sageVARb^7*sqrt(sageVARb*sageVARx+2)*sqrt(sageVARb*sageVARx+2)-78*sageVARb^5/144/sageVARb^7)*sqrt(sageVARb*sageVARx+2)*sqrt(sageVARb*sageVARx+2)+198*sageVARb^5/144/sageVARb^7)*sqrt(sageVARb*sageVARx+2)*sqrt(sageVARb*(sageVARb*sageVARx+2)-2*sageVARb)+5/2/sageVARb/sqrt(sageVARb)*ln(abs(sqrt(sageVARb*(sageVARb*sageVARx+2)-2*sageVARb)-sqrt(sageVARb)*sqrt(sageVARb*sageVARx+2))))+4*abs(sageVARb)/sageVARb^2/sageVARb*(2*(1/8*sqrt(sageVARb*sageVARx+2)*sqrt(sageVARb*sageVARx+2)-5/8)*sqrt(sageVARb*sageVARx+2)*sqrt(sageVARb*(sageVARb*sageVARx+2)-2*sageVARb)-6*sageVARb/4/sqrt(sageVARb)*ln(abs(sqrt(sageVARb*(sageVARb*sageVARx+2)-2*sageVARb)-sqrt(sageVARb)*sqrt(sageVARb*sageVARx+2)))))
sage:

But when using giac directly, it works with no errors

>giac
// Using locale /usr/local/share/locale/
// C.UTF-8
// /usr/local/share/locale/
// giac
// UTF-8
// Maximum number of parallel threads 24
Added 0 synonyms
Welcome to giac readline interface, version 1.9.0
(c) 2001,2021 B. Parisse & others
Homepage http://www-fourier.ujf-grenoble.fr/~parisse/giac.html
Released under the GPL license 3.0 or above
See http://www.gnu.org for license details
May contain BSD licensed software parts (lapack, atlas, tinymt)
-------------------------------------------------
Press CTRL and D simultaneously to finish session
Type ?commandname for help
0>> integrate( x^(3/2)*(b*x+2)^(1/2),x)
2*(2*((12*b^4*1/144/b^4*sqrt(x)*sqrt(x)+6*b^3*1/144/b^4)*sqrt(x)*sqrt(x)-18*b^2*1/144/b^4)*sqrt(x)*sqrt(b*x+2)-1/2/b^2/sqrt(b)*ln(sqrt(b*x+2)-sqrt(b)*sqrt(x)))
// Time 0.01
1>>

Here are more information

>which sage
/home/me/DATA/sage-9.6/sage
>sage --version
SageMath version 9.6, Release Date: 2022-05-15
>which giac
/usr/local/bin/giac
>giac --version
// Using locale /usr/local/share/locale/
// C.UTF-8
// /usr/local/share/locale/
// giac
// UTF-8
// Maximum number of parallel threads 24
// (c) 2001, 2021 B. Parisse & others
1.9.0

>cat /etc/*-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=22.04
DISTRIB_CODENAME=jammy
DISTRIB_DESCRIPTION="Ubuntu 22.04 LTS"
PRETTY_NAME="Ubuntu 22.04 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04 LTS (Jammy Jellyfish)"
VERSION_CODENAME=jammy


>$SAGE_ROOT/sage --version
 SageMath version 9.6, Release Date: 2022-05-15

>cd $SAGE_ROOT/local/bin

>ls -l giac
lrwxrwxrwx 1 me me 19 May 16 17:02 giac -> /usr/local/bin/giac
>

I see many integrals that fail the same way using giac. I was hoping this will be fixed in sage 9.6

Where is choosing root of message coming from? As when calling giac directly, I see no such message displayed. Is sagemath reading additionl output from giac somehow that do not show up on the terminal when using giac directly?

Any idea what is going on?

still getting Malform expression using giac in 9.6

I am using sagemath 9.6 with latest giac 1.9.0-7

I am not using giac that comes with sagemath 9.6 since that is old. So I points it to use the latest giac outside of sagemath.

Here is an example of such problem

>sage
┌────────────────────────────────────────────────────────────────────┐
│ SageMath version 9.6, Release Date: 2022-05-15                     │
│ Using Python 3.10.4. Type "help()" for help.                       │
└────────────────────────────────────────────────────────────────────┘
sage: var('x,b')
(x, b)

sage: integrate(x^(3/2)*(b*x+2)^(1/2),x,algorithm="giac")
---------------------------------------------------------------------------
SyntaxError                               Traceback (most recent call last)
~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/interfaces/giac.py in _sage_(self, locals)
   1138             try:
-> 1139                 return symbolic_expression_from_string(result, lsymbols,
   1140                     accept_sequence=True, parser=SR_parser_giac)

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/calculus/calculus.py in symbolic_expression_from_string(s, syms, accept_sequence, parser)
   2568                                               if _is_function(v)})
-> 2569     return parse_func(s)
   2570

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/misc/parser.pyx in sage.misc.parser.Parser.parse_sequence (build/cythonized/sage/misc/parser.c:6025)()
    574
--> 575     cpdef parse_sequence(self, s):
    576         """

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/misc/parser.pyx in sage.misc.parser.Parser.parse_sequence (build/cythonized/sage/misc/parser.c:5912)()
    592         if tokens.next() != EOS:
--> 593             self.parse_error(tokens)
    594         if len(all) == 1 and isinstance(all, list):

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/misc/parser.pyx in sage.misc.parser.Parser.parse_error (build/cythonized/sage/misc/parser.c:10396)()
   1043     cdef parse_error(self, Tokenizer tokens, msg="Malformed expression"):
-> 1044         raise SyntaxError(msg, tokens.s, tokens.pos)
   1045

SyntaxError: Malformed expression

During handling of the above exception, another exception occurred:

NotImplementedError                       Traceback (most recent call last)
<ipython-input-6-2f599f779b32> in <module>
----> 1 integrate(x**(Integer(3)/Integer(2))*(b*x+Integer(2))**(Integer(1)/Integer(2)),x,algorithm="giac")

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/misc/functional.py in integral(x, *args, **kwds)
    762     """
    763     if hasattr(x, 'integral'):
--> 764         return x.integral(*args, **kwds)
    765     else:
    766         from sage.symbolic.ring import SR

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/symbolic/expression.pyx in sage.symbolic.expression.Expression.integral (build/cythonized/sage/symbolic/expression.cpp:95445)()
  13192                     R = SR
  13193             return R(integral(f, v, a, b, **kwds))
> 13194         return integral(self, *args, **kwds)
  13195
  13196     integrate = integral

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/symbolic/integration/integral.py in integrate(expression, v, a, b, algorithm, hold)
   1045         if not integrator:
   1046             raise ValueError("Unknown algorithm: %s" % algorithm)
-> 1047         return integrator(expression, v, a, b)
   1048     if a is None:
   1049         return indefinite_integral(expression, v, hold=hold)

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/symbolic/integration/external.py in giac_integrator(expression, v, a, b)
    256         return expression.integrate(v, a, b, hold=True)
    257     else:
--> 258         return result._sage_()
    259
    260 def libgiac_integrator(expression, v, a=None, b=None):

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/interfaces/giac.py in _sage_(self, locals)
   1141
   1142             except Exception:
-> 1143                 raise NotImplementedError("Unable to parse Giac output: %s" % result)
   1144         else:
   1145             return [entry.sage() for entry in self]

NotImplementedError: Unable to parse Giac output: Warning, choosing root of [1,0,%%%{-4,[1,1]%%%}+%%%{-4,[1,0]%%%}+%%%{-4,[0,1]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%{4,[1,3]%%%}+%%%{20,[1,2]%%%}+%%%{-128,[1,1]%%%}+%%%{16,[1,0]%%%}+%%%{-4,[0,3]%%%}+%%%{8,[0,2]%%%}+%%%{16,[0,1]%%%}+%%%{-32,[0,0]%%%},0,%%%{1,[4,4]%%%}+%%%{-4,[4,3]%%%}+%%%{6,[4,2]%%%}+%%%{-4,[4,1]%%%}+%%%{1,[4,0]%%%}+%%%{-4,[3,4]%%%}+%%%{12,[3,3]%%%}+%%%{-20,[3,2]%%%}+%%%{20,[3,1]%%%}+%%%{-8,[3,0]%%%}+%%%{6,[2,4]%%%}+%%%{-20,[2,3]%%%}+%%%{46,[2,2]%%%}+%%%{-40,[2,1]%%%}+%%%{24,[2,0]%%%}+%%%{-4,[1,4]%%%}+%%%{20,[1,3]%%%}+%%%{-40,[1,2]%%%}+%%%{48,[1,1]%%%}+%%%{-32,[1,0]%%%}+%%%{1,[0,4]%%%}+%%%{-8,[0,3]%%%}+%%%{24,[0,2]%%%}+%%%{-32,[0,1]%%%}+%%%{16,[0,0]%%%}] at parameters values [18.4052062202,51.6443148847]

1/sageVARb*(2*sageVARb*abs(sageVARb)/sageVARb^2*(2*((12*sageVARb^5/144/sageVARb^7*sqrt(sageVARb*sageVARx+2)*sqrt(sageVARb*sageVARx+2)-78*sageVARb^5/144/sageVARb^7)*sqrt(sageVARb*sageVARx+2)*sqrt(sageVARb*sageVARx+2)+198*sageVARb^5/144/sageVARb^7)*sqrt(sageVARb*sageVARx+2)*sqrt(sageVARb*(sageVARb*sageVARx+2)-2*sageVARb)+5/2/sageVARb/sqrt(sageVARb)*ln(abs(sqrt(sageVARb*(sageVARb*sageVARx+2)-2*sageVARb)-sqrt(sageVARb)*sqrt(sageVARb*sageVARx+2))))+4*abs(sageVARb)/sageVARb^2/sageVARb*(2*(1/8*sqrt(sageVARb*sageVARx+2)*sqrt(sageVARb*sageVARx+2)-5/8)*sqrt(sageVARb*sageVARx+2)*sqrt(sageVARb*(sageVARb*sageVARx+2)-2*sageVARb)-6*sageVARb/4/sqrt(sageVARb)*ln(abs(sqrt(sageVARb*(sageVARb*sageVARx+2)-2*sageVARb)-sqrt(sageVARb)*sqrt(sageVARb*sageVARx+2)))))
sage:

But when using giac directly, it works with no errors

>giac
// Using locale /usr/local/share/locale/
// C.UTF-8
// /usr/local/share/locale/
// giac
// UTF-8
// Maximum number of parallel threads 24
Added 0 synonyms
Welcome to giac readline interface, version 1.9.0
(c) 2001,2021 B. Parisse & others
Homepage http://www-fourier.ujf-grenoble.fr/~parisse/giac.html
Released under the GPL license 3.0 or above
See http://www.gnu.org for license details
May contain BSD licensed software parts (lapack, atlas, tinymt)
-------------------------------------------------
Press CTRL and D simultaneously to finish session
Type ?commandname for help
0>> integrate( x^(3/2)*(b*x+2)^(1/2),x)
2*(2*((12*b^4*1/144/b^4*sqrt(x)*sqrt(x)+6*b^3*1/144/b^4)*sqrt(x)*sqrt(x)-18*b^2*1/144/b^4)*sqrt(x)*sqrt(b*x+2)-1/2/b^2/sqrt(b)*ln(sqrt(b*x+2)-sqrt(b)*sqrt(x)))
// Time 0.01
1>>

Here are more information

>which sage
/home/me/DATA/sage-9.6/sage
>sage --version
SageMath version 9.6, Release Date: 2022-05-15
>which giac
/usr/local/bin/giac
>giac --version
// Using locale /usr/local/share/locale/
// C.UTF-8
// /usr/local/share/locale/
// giac
// UTF-8
// Maximum number of parallel threads 24
// (c) 2001, 2021 B. Parisse & others
1.9.0

>cat /etc/*-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=22.04
DISTRIB_CODENAME=jammy
DISTRIB_DESCRIPTION="Ubuntu 22.04 LTS"
PRETTY_NAME="Ubuntu 22.04 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04 LTS (Jammy Jellyfish)"
VERSION_CODENAME=jammy


>$SAGE_ROOT/sage --version
 SageMath version 9.6, Release Date: 2022-05-15

>cd $SAGE_ROOT/local/bin

>ls -l giac
lrwxrwxrwx 1 me me 19 May 16 17:02 giac -> /usr/local/bin/giac
>

I see many integrals that fail the same way using giac. I was hoping this will be fixed in sage 9.6

Where is choosing root of message coming from? As Because when calling giac directly, I see no such message displayed. This looks like a message that giac would have generated.

Is sagemath reading additionl additional output from giac giac somehow that do not show up on the terminal when using giac directly?directly? As you can see from above, giac printed no such message. (unless it is hidden somehow?)

Any idea what is going on?

still getting Malform expression using giac in 9.6

I am using sagemath 9.6 with latest giac 1.9.0-7

I am not using giac that comes with sagemath 9.6 since that is old. So I points it to use the latest giac outside of sagemath.

Here is an example of such problem

>sage
┌────────────────────────────────────────────────────────────────────┐
│ SageMath version 9.6, Release Date: 2022-05-15                     │
│ Using Python 3.10.4. Type "help()" for help.                       │
└────────────────────────────────────────────────────────────────────┘
sage: var('x,b')
(x, b)

sage: integrate(x^(3/2)*(b*x+2)^(1/2),x,algorithm="giac")
---------------------------------------------------------------------------
SyntaxError                               Traceback (most recent call last)
~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/interfaces/giac.py in _sage_(self, locals)
   1138             try:
-> 1139                 return symbolic_expression_from_string(result, lsymbols,
   1140                     accept_sequence=True, parser=SR_parser_giac)

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/calculus/calculus.py in symbolic_expression_from_string(s, syms, accept_sequence, parser)
   2568                                               if _is_function(v)})
-> 2569     return parse_func(s)
   2570

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/misc/parser.pyx in sage.misc.parser.Parser.parse_sequence (build/cythonized/sage/misc/parser.c:6025)()
    574
--> 575     cpdef parse_sequence(self, s):
    576         """

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/misc/parser.pyx in sage.misc.parser.Parser.parse_sequence (build/cythonized/sage/misc/parser.c:5912)()
    592         if tokens.next() != EOS:
--> 593             self.parse_error(tokens)
    594         if len(all) == 1 and isinstance(all, list):

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/misc/parser.pyx in sage.misc.parser.Parser.parse_error (build/cythonized/sage/misc/parser.c:10396)()
   1043     cdef parse_error(self, Tokenizer tokens, msg="Malformed expression"):
-> 1044         raise SyntaxError(msg, tokens.s, tokens.pos)
   1045

SyntaxError: Malformed expression

During handling of the above exception, another exception occurred:

NotImplementedError                       Traceback (most recent call last)
<ipython-input-6-2f599f779b32> in <module>
----> 1 integrate(x**(Integer(3)/Integer(2))*(b*x+Integer(2))**(Integer(1)/Integer(2)),x,algorithm="giac")

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/misc/functional.py in integral(x, *args, **kwds)
    762     """
    763     if hasattr(x, 'integral'):
--> 764         return x.integral(*args, **kwds)
    765     else:
    766         from sage.symbolic.ring import SR

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/symbolic/expression.pyx in sage.symbolic.expression.Expression.integral (build/cythonized/sage/symbolic/expression.cpp:95445)()
  13192                     R = SR
  13193             return R(integral(f, v, a, b, **kwds))
> 13194         return integral(self, *args, **kwds)
  13195
  13196     integrate = integral

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/symbolic/integration/integral.py in integrate(expression, v, a, b, algorithm, hold)
   1045         if not integrator:
   1046             raise ValueError("Unknown algorithm: %s" % algorithm)
-> 1047         return integrator(expression, v, a, b)
   1048     if a is None:
   1049         return indefinite_integral(expression, v, hold=hold)

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/symbolic/integration/external.py in giac_integrator(expression, v, a, b)
    256         return expression.integrate(v, a, b, hold=True)
    257     else:
--> 258         return result._sage_()
    259
    260 def libgiac_integrator(expression, v, a=None, b=None):

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/interfaces/giac.py in _sage_(self, locals)
   1141
   1142             except Exception:
-> 1143                 raise NotImplementedError("Unable to parse Giac output: %s" % result)
   1144         else:
   1145             return [entry.sage() for entry in self]

NotImplementedError: Unable to parse Giac output: Warning, choosing root of [1,0,%%%{-4,[1,1]%%%}+%%%{-4,[1,0]%%%}+%%%{-4,[0,1]%%%}+%%%{-8,[0,0]%%%},0,%%%{6,[2,2]%%%}+%%%{4,[2,1]%%%}+%%%{6,[2,0]%%%}+%%%{4,[1,2]%%%}+%%%{28,[1,1]%%%}+%%%{8,[1,0]%%%}+%%%{6,[0,2]%%%}+%%%{8,[0,1]%%%}+%%%{24,[0,0]%%%},0,%%%{-4,[3,3]%%%}+%%%{4,[3,2]%%%}+%%%{4,[3,1]%%%}+%%%{-4,[3,0]%%%}+%%%{4,[2,3]%%%}+%%%{-64,[2,2]%%%}+%%%{20,[2,1]%%%}+%%%{8,[2,0]%%%}+%%%{4,[1,3]%%%}+%%%{20,[1,2]%%%}+%%%{-128,[1,1]%%%}+%%%{16,[1,0]%%%}+%%%{-4,[0,3]%%%}+%%%{8,[0,2]%%%}+%%%{16,[0,1]%%%}+%%%{-32,[0,0]%%%},0,%%%{1,[4,4]%%%}+%%%{-4,[4,3]%%%}+%%%{6,[4,2]%%%}+%%%{-4,[4,1]%%%}+%%%{1,[4,0]%%%}+%%%{-4,[3,4]%%%}+%%%{12,[3,3]%%%}+%%%{-20,[3,2]%%%}+%%%{20,[3,1]%%%}+%%%{-8,[3,0]%%%}+%%%{6,[2,4]%%%}+%%%{-20,[2,3]%%%}+%%%{46,[2,2]%%%}+%%%{-40,[2,1]%%%}+%%%{24,[2,0]%%%}+%%%{-4,[1,4]%%%}+%%%{20,[1,3]%%%}+%%%{-40,[1,2]%%%}+%%%{48,[1,1]%%%}+%%%{-32,[1,0]%%%}+%%%{1,[0,4]%%%}+%%%{-8,[0,3]%%%}+%%%{24,[0,2]%%%}+%%%{-32,[0,1]%%%}+%%%{16,[0,0]%%%}] at parameters values [59.8656459874,25.8388736797]
Warning, choosing root of [1,0,%%%{-4,[1,1]%%%}+%%%{-4,[1,0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}+%%%{4,[3,2]%%%}+%%%{4,[3,1]%%%}+%%%{-4,[3,0]%%%}+%%%{4,[2,3]%%%}+%%%{-64,[2,2]%%%}+%%%{20,[2,1]%%%}+%%%{8,[2,0]%%%}+%%%{4,[1,3]%%%}+%%%{20,[1,2]%%%}+%%%{-128,[1,1]%%%}+%%%{16,[1,0]%%%}+%%%{-4,[0,3]%%%}+%%%{8,[0,2]%%%}+%%%{16,[0,1]%%%}+%%%{-32,[0,0]%%%},0,%%%{1,[4,4]%%%}+%%%{-4,[4,3]%%%}+%%%{6,[4,2]%%%}+%%%{-4,[4,1]%%%}+%%%{1,[4,0]%%%}+%%%{-4,[3,4]%%%}+%%%{12,[3,3]%%%}+%%%{-20,[3,2]%%%}+%%%{20,[3,1]%%%}+%%%{-8,[3,0]%%%}+%%%{6,[2,4]%%%}+%%%{-20,[2,3]%%%}+%%%{46,[2,2]%%%}+%%%{-40,[2,1]%%%}+%%%{24,[2,0]%%%}+%%%{-4,[1,4]%%%}+%%%{20,[1,3]%%%}+%%%{-40,[1,2]%%%}+%%%{48,[1,1]%%%}+%%%{-32,[1,0]%%%}+%%%{1,[0,4]%%%}+%%%{-8,[0,3]%%%}+%%%{24,[0,2]%%%}+%%%{-32,[0,1]%%%}+%%%{16,[0,0]%%%}] at parameters values [18.4052062202,51.6443148847]

1/sageVARb*(2*sageVARb*abs(sageVARb)/sageVARb^2*(2*((12*sageVARb^5/144/sageVARb^7*sqrt(sageVARb*sageVARx+2)*sqrt(sageVARb*sageVARx+2)-78*sageVARb^5/144/sageVARb^7)*sqrt(sageVARb*sageVARx+2)*sqrt(sageVARb*sageVARx+2)+198*sageVARb^5/144/sageVARb^7)*sqrt(sageVARb*sageVARx+2)*sqrt(sageVARb*(sageVARb*sageVARx+2)-2*sageVARb)+5/2/sageVARb/sqrt(sageVARb)*ln(abs(sqrt(sageVARb*(sageVARb*sageVARx+2)-2*sageVARb)-sqrt(sageVARb)*sqrt(sageVARb*sageVARx+2))))+4*abs(sageVARb)/sageVARb^2/sageVARb*(2*(1/8*sqrt(sageVARb*sageVARx+2)*sqrt(sageVARb*sageVARx+2)-5/8)*sqrt(sageVARb*sageVARx+2)*sqrt(sageVARb*(sageVARb*sageVARx+2)-2*sageVARb)-6*sageVARb/4/sqrt(sageVARb)*ln(abs(sqrt(sageVARb*(sageVARb*sageVARx+2)-2*sageVARb)-sqrt(sageVARb)*sqrt(sageVARb*sageVARx+2)))))
sage:

But when using giac directly, it works with no errors

>giac
// Using locale /usr/local/share/locale/
// C.UTF-8
// /usr/local/share/locale/
// giac
// UTF-8
// Maximum number of parallel threads 24
Added 0 synonyms
Welcome to giac readline interface, version 1.9.0
(c) 2001,2021 B. Parisse & others
Homepage http://www-fourier.ujf-grenoble.fr/~parisse/giac.html
Released under the GPL license 3.0 or above
See http://www.gnu.org for license details
May contain BSD licensed software parts (lapack, atlas, tinymt)
-------------------------------------------------
Press CTRL and D simultaneously to finish session
Type ?commandname for help
0>> integrate( x^(3/2)*(b*x+2)^(1/2),x)
2*(2*((12*b^4*1/144/b^4*sqrt(x)*sqrt(x)+6*b^3*1/144/b^4)*sqrt(x)*sqrt(x)-18*b^2*1/144/b^4)*sqrt(x)*sqrt(b*x+2)-1/2/b^2/sqrt(b)*ln(sqrt(b*x+2)-sqrt(b)*sqrt(x)))
// Time 0.01
1>>

Here are more information

>which sage
/home/me/DATA/sage-9.6/sage
>sage --version
SageMath version 9.6, Release Date: 2022-05-15
>which giac
/usr/local/bin/giac
>giac --version
// Using locale /usr/local/share/locale/
// C.UTF-8
// /usr/local/share/locale/
// giac
// UTF-8
// Maximum number of parallel threads 24
// (c) 2001, 2021 B. Parisse & others
1.9.0

>cat /etc/*-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=22.04
DISTRIB_CODENAME=jammy
DISTRIB_DESCRIPTION="Ubuntu 22.04 LTS"
PRETTY_NAME="Ubuntu 22.04 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04 LTS (Jammy Jellyfish)"
VERSION_CODENAME=jammy


>$SAGE_ROOT/sage --version
 SageMath version 9.6, Release Date: 2022-05-15

>cd $SAGE_ROOT/local/bin

>ls -l giac
lrwxrwxrwx 1 me me 19 May 16 17:02 giac -> /usr/local/bin/giac
>

I see many integrals that fail the same way using giac. I was hoping this will be fixed in sage 9.6

Where is choosing root of message coming from? Because when calling giac directly, I see no such message displayed. This looks like a message that giac would have generated.

Is sagemath reading additional output from giac somehow that do not show up on the terminal when using giac directly? As you can see from above, giac printed no such message. (unless it is hidden somehow?)

Any idea what is going on?

Update

It appears that sagemath is using old giac version it build. it must be a library of giac, since I deleted the binary in $SAGE_ROOT/local/bin

My question now is: How to tell sagemath NOT to build giac itself? I tried

  ./configure --with-system-python=no --with-system-giac=yes

And also

 ./configure --with-system-python=no --with-system-giac=no

And in both cases (each time starting from a fresh sagemath installation) I see it is still building old giac [giac-1.6.0.47p3.p0] by looing at the output of make

Could someone please give simple and clear instruction what should one to do to tell sagemath to use the system giac located in /usr/local/bin and NOT build the old giac version that comes with giac?

It is a nightmere just to get sagemath to use the correct version of CAS I want. I now have no idea what version of external CAS I am using when running sagemath any more. I also using newer maxima installed in /usr/local/bin and now I am not sure sagemath is using that or using its own older version of maxima.

There should be an easy and clear way to do these things.

still getting Malform expression using giac in 9.6

I am using sagemath 9.6 with latest giac 1.9.0-7

I am not using giac that comes with sagemath 9.6 since that is old. So I points it to use the latest giac outside of sagemath.

Here is an example of such problem

>sage
┌────────────────────────────────────────────────────────────────────┐
│ SageMath version 9.6, Release Date: 2022-05-15                     │
│ Using Python 3.10.4. Type "help()" for help.                       │
└────────────────────────────────────────────────────────────────────┘
sage: var('x,b')
(x, b)

sage: integrate(x^(3/2)*(b*x+2)^(1/2),x,algorithm="giac")
---------------------------------------------------------------------------
SyntaxError                               Traceback (most recent call last)
~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/interfaces/giac.py in _sage_(self, locals)
   1138             try:
-> 1139                 return symbolic_expression_from_string(result, lsymbols,
   1140                     accept_sequence=True, parser=SR_parser_giac)

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/calculus/calculus.py in symbolic_expression_from_string(s, syms, accept_sequence, parser)
   2568                                               if _is_function(v)})
-> 2569     return parse_func(s)
   2570

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/misc/parser.pyx in sage.misc.parser.Parser.parse_sequence (build/cythonized/sage/misc/parser.c:6025)()
    574
--> 575     cpdef parse_sequence(self, s):
    576         """

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/misc/parser.pyx in sage.misc.parser.Parser.parse_sequence (build/cythonized/sage/misc/parser.c:5912)()
    592         if tokens.next() != EOS:
--> 593             self.parse_error(tokens)
    594         if len(all) == 1 and isinstance(all, list):

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/misc/parser.pyx in sage.misc.parser.Parser.parse_error (build/cythonized/sage/misc/parser.c:10396)()
   1043     cdef parse_error(self, Tokenizer tokens, msg="Malformed expression"):
-> 1044         raise SyntaxError(msg, tokens.s, tokens.pos)
   1045

SyntaxError: Malformed expression

During handling of the above exception, another exception occurred:

NotImplementedError                       Traceback (most recent call last)
<ipython-input-6-2f599f779b32> in <module>
----> 1 integrate(x**(Integer(3)/Integer(2))*(b*x+Integer(2))**(Integer(1)/Integer(2)),x,algorithm="giac")

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/misc/functional.py in integral(x, *args, **kwds)
    762     """
    763     if hasattr(x, 'integral'):
--> 764         return x.integral(*args, **kwds)
    765     else:
    766         from sage.symbolic.ring import SR

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/symbolic/expression.pyx in sage.symbolic.expression.Expression.integral (build/cythonized/sage/symbolic/expression.cpp:95445)()
  13192                     R = SR
  13193             return R(integral(f, v, a, b, **kwds))
> 13194         return integral(self, *args, **kwds)
  13195
  13196     integrate = integral

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/symbolic/integration/integral.py in integrate(expression, v, a, b, algorithm, hold)
   1045         if not integrator:
   1046             raise ValueError("Unknown algorithm: %s" % algorithm)
-> 1047         return integrator(expression, v, a, b)
   1048     if a is None:
   1049         return indefinite_integral(expression, v, hold=hold)

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/symbolic/integration/external.py in giac_integrator(expression, v, a, b)
    256         return expression.integrate(v, a, b, hold=True)
    257     else:
--> 258         return result._sage_()
    259
    260 def libgiac_integrator(expression, v, a=None, b=None):

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/interfaces/giac.py in _sage_(self, locals)
   1141
   1142             except Exception:
-> 1143                 raise NotImplementedError("Unable to parse Giac output: %s" % result)
   1144         else:
   1145             return [entry.sage() for entry in self]

NotImplementedError: Unable to parse Giac output: Warning, choosing root of [1,0,%%%{-4,[1,1]%%%}+%%%{-4,[1,0]%%%}+%%%{-4,[0,1]%%%}+%%%{-8,[0,0]%%%},0,%%%{6,[2,2]%%%}+%%%{4,[2,1]%%%}+%%%{6,[2,0]%%%}+%%%{4,[1,2]%%%}+%%%{28,[1,1]%%%}+%%%{8,[1,0]%%%}+%%%{6,[0,2]%%%}+%%%{8,[0,1]%%%}+%%%{24,[0,0]%%%},0,%%%{-4,[3,3]%%%}+%%%{4,[3,2]%%%}+%%%{4,[3,1]%%%}+%%%{-4,[3,0]%%%}+%%%{4,[2,3]%%%}+%%%{-64,[2,2]%%%}+%%%{20,[2,1]%%%}+%%%{8,[2,0]%%%}+%%%{4,[1,3]%%%}+%%%{20,[1,2]%%%}+%%%{-128,[1,1]%%%}+%%%{16,[1,0]%%%}+%%%{-4,[0,3]%%%}+%%%{8,[0,2]%%%}+%%%{16,[0,1]%%%}+%%%{-32,[0,0]%%%},0,%%%{1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1]%%%}+%%%{-32,[1,0]%%%}+%%%{1,[0,4]%%%}+%%%{-8,[0,3]%%%}+%%%{24,[0,2]%%%}+%%%{-32,[0,1]%%%}+%%%{16,[0,0]%%%}] at parameters values [18.4052062202,51.6443148847]

1/sageVARb*(2*sageVARb*abs(sageVARb)/sageVARb^2*(2*((12*sageVARb^5/144/sageVARb^7*sqrt(sageVARb*sageVARx+2)*sqrt(sageVARb*sageVARx+2)-78*sageVARb^5/144/sageVARb^7)*sqrt(sageVARb*sageVARx+2)*sqrt(sageVARb*sageVARx+2)+198*sageVARb^5/144/sageVARb^7)*sqrt(sageVARb*sageVARx+2)*sqrt(sageVARb*(sageVARb*sageVARx+2)-2*sageVARb)+5/2/sageVARb/sqrt(sageVARb)*ln(abs(sqrt(sageVARb*(sageVARb*sageVARx+2)-2*sageVARb)-sqrt(sageVARb)*sqrt(sageVARb*sageVARx+2))))+4*abs(sageVARb)/sageVARb^2/sageVARb*(2*(1/8*sqrt(sageVARb*sageVARx+2)*sqrt(sageVARb*sageVARx+2)-5/8)*sqrt(sageVARb*sageVARx+2)*sqrt(sageVARb*(sageVARb*sageVARx+2)-2*sageVARb)-6*sageVARb/4/sqrt(sageVARb)*ln(abs(sqrt(sageVARb*(sageVARb*sageVARx+2)-2*sageVARb)-sqrt(sageVARb)*sqrt(sageVARb*sageVARx+2)))))
sage:

But when using giac directly, it works with no errors

>giac
// Using locale /usr/local/share/locale/
// C.UTF-8
// /usr/local/share/locale/
// giac
// UTF-8
// Maximum number of parallel threads 24
Added 0 synonyms
Welcome to giac readline interface, version 1.9.0
(c) 2001,2021 B. Parisse & others
Homepage http://www-fourier.ujf-grenoble.fr/~parisse/giac.html
Released under the GPL license 3.0 or above
See http://www.gnu.org for license details
May contain BSD licensed software parts (lapack, atlas, tinymt)
-------------------------------------------------
Press CTRL and D simultaneously to finish session
Type ?commandname for help
0>> integrate( x^(3/2)*(b*x+2)^(1/2),x)
2*(2*((12*b^4*1/144/b^4*sqrt(x)*sqrt(x)+6*b^3*1/144/b^4)*sqrt(x)*sqrt(x)-18*b^2*1/144/b^4)*sqrt(x)*sqrt(b*x+2)-1/2/b^2/sqrt(b)*ln(sqrt(b*x+2)-sqrt(b)*sqrt(x)))
// Time 0.01
1>>

Here are more information

>which sage
/home/me/DATA/sage-9.6/sage
>sage --version
SageMath version 9.6, Release Date: 2022-05-15
>which giac
/usr/local/bin/giac
>giac --version
// Using locale /usr/local/share/locale/
// C.UTF-8
// /usr/local/share/locale/
// giac
// UTF-8
// Maximum number of parallel threads 24
// (c) 2001, 2021 B. Parisse & others
1.9.0

>cat /etc/*-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=22.04
DISTRIB_CODENAME=jammy
DISTRIB_DESCRIPTION="Ubuntu 22.04 LTS"
PRETTY_NAME="Ubuntu 22.04 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04 LTS (Jammy Jellyfish)"
VERSION_CODENAME=jammy


>$SAGE_ROOT/sage --version
 SageMath version 9.6, Release Date: 2022-05-15

>cd $SAGE_ROOT/local/bin

>ls -l giac
lrwxrwxrwx 1 me me 19 May 16 17:02 giac -> /usr/local/bin/giac
>

I see many integrals that fail the same way using giac. I was hoping this will be fixed in sage 9.6

Where is choosing root of message coming from? Because when calling giac directly, I see no such message displayed. This looks like a message that giac would have generated.

Is sagemath reading additional output from giac somehow that do not show up on the terminal when using giac directly? As you can see from above, giac printed no such message. (unless it is hidden somehow?)

Any idea what is going on?

Update

It appears that sagemath is using old giac version it build. it must be a library of giac, since I deleted the binary in $SAGE_ROOT/local/bin

My question now is: How to tell sagemath NOT to build giac itself? I tried

  ./configure --with-system-python=no --with-system-giac=yes

And also

 ./configure --with-system-python=no --with-system-giac=no

And in both cases (each time starting from a fresh sagemath installation) I see it is still building old giac [giac-1.6.0.47p3.p0] by looing looking at the output of make

Could someone please give simple and clear instruction what should one to do to tell sagemath to use the system giac located in /usr/local/bin and NOT NOT build the old giac version that comes with giac?sagemath tar file?

It is a nightmere just to get sagemath to use the correct version of CAS I want. I now have no idea what version of external CAS I am using when running sagemath any more. I also using newer maxima installed in /usr/local/bin and now I am not sure sagemath is using that or using its own older version of maxima.

There should be an easy and clear way to do these things.

still getting Malform expression using giac in 9.6

I am using sagemath 9.6 with latest giac 1.9.0-7

I am not using giac that comes with sagemath 9.6 since that is old. So I points it to use the latest giac outside of sagemath.

Here is an example of such problem

>sage
┌────────────────────────────────────────────────────────────────────┐
│ SageMath version 9.6, Release Date: 2022-05-15                     │
│ Using Python 3.10.4. Type "help()" for help.                       │
└────────────────────────────────────────────────────────────────────┘
sage: var('x,b')
(x, b)

sage: integrate(x^(3/2)*(b*x+2)^(1/2),x,algorithm="giac")
---------------------------------------------------------------------------
SyntaxError                               Traceback (most recent call last)
~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/interfaces/giac.py in _sage_(self, locals)
   1138             try:
-> 1139                 return symbolic_expression_from_string(result, lsymbols,
   1140                     accept_sequence=True, parser=SR_parser_giac)

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/calculus/calculus.py in symbolic_expression_from_string(s, syms, accept_sequence, parser)
   2568                                               if _is_function(v)})
-> 2569     return parse_func(s)
   2570

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/misc/parser.pyx in sage.misc.parser.Parser.parse_sequence (build/cythonized/sage/misc/parser.c:6025)()
    574
--> 575     cpdef parse_sequence(self, s):
    576         """

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/misc/parser.pyx in sage.misc.parser.Parser.parse_sequence (build/cythonized/sage/misc/parser.c:5912)()
    592         if tokens.next() != EOS:
--> 593             self.parse_error(tokens)
    594         if len(all) == 1 and isinstance(all, list):

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/misc/parser.pyx in sage.misc.parser.Parser.parse_error (build/cythonized/sage/misc/parser.c:10396)()
   1043     cdef parse_error(self, Tokenizer tokens, msg="Malformed expression"):
-> 1044         raise SyntaxError(msg, tokens.s, tokens.pos)
   1045

SyntaxError: Malformed expression

During handling of the above exception, another exception occurred:

NotImplementedError                       Traceback (most recent call last)
<ipython-input-6-2f599f779b32> in <module>
----> 1 integrate(x**(Integer(3)/Integer(2))*(b*x+Integer(2))**(Integer(1)/Integer(2)),x,algorithm="giac")

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/misc/functional.py in integral(x, *args, **kwds)
    762     """
    763     if hasattr(x, 'integral'):
--> 764         return x.integral(*args, **kwds)
    765     else:
    766         from sage.symbolic.ring import SR

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/symbolic/expression.pyx in sage.symbolic.expression.Expression.integral (build/cythonized/sage/symbolic/expression.cpp:95445)()
  13192                     R = SR
  13193             return R(integral(f, v, a, b, **kwds))
> 13194         return integral(self, *args, **kwds)
  13195
  13196     integrate = integral

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/symbolic/integration/integral.py in integrate(expression, v, a, b, algorithm, hold)
   1045         if not integrator:
   1046             raise ValueError("Unknown algorithm: %s" % algorithm)
-> 1047         return integrator(expression, v, a, b)
   1048     if a is None:
   1049         return indefinite_integral(expression, v, hold=hold)

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/symbolic/integration/external.py in giac_integrator(expression, v, a, b)
    256         return expression.integrate(v, a, b, hold=True)
    257     else:
--> 258         return result._sage_()
    259
    260 def libgiac_integrator(expression, v, a=None, b=None):

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/interfaces/giac.py in _sage_(self, locals)
   1141
   1142             except Exception:
-> 1143                 raise NotImplementedError("Unable to parse Giac output: %s" % result)
   1144         else:
   1145             return [entry.sage() for entry in self]

NotImplementedError: Unable to parse Giac output: Warning, choosing root of [1,0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-64,[2,2]%%%}+%%%{20,[2,1]%%%}+%%%{8,[2,0]%%%}+%%%{4,[1,3]%%%}+%%%{20,[1,2]%%%}+%%%{-128,[1,1]%%%}+%%%{16,[1,0]%%%}+%%%{-4,[0,3]%%%}+%%%{8,[0,2]%%%}+%%%{16,[0,1]%%%}+%%%{-32,[0,0]%%%},0,%%%{1,[4,4]%%%}+%%%{-4,[4,3]%%%}+%%%{6,[4,2]%%%}+%%%{-4,[4,1]%%%}+%%%{1,[4,0]%%%}+%%%{-4,[3,4]%%%}+%%%{12,[3,3]%%%}+%%%{-20,[3,2]%%%}+%%%{20,[3,1]%%%}+%%%{-8,[3,0]%%%}+%%%{6,[2,4]%%%}+%%%{-20,[2,3]%%%}+%%%{46,[2,2]%%%}+%%%{-40,[2,1]%%%}+%%%{24,[2,0]%%%}+%%%{-4,[1,4]%%%}+%%%{20,[1,3]%%%}+%%%{-40,[1,2]%%%}+%%%{48,[1,1]%%%}+%%%{-32,[1,0]%%%}+%%%{1,[0,4]%%%}+%%%{-8,[0,3]%%%}+%%%{24,[0,2]%%%}+%%%{-32,[0,1]%%%}+%%%{16,[0,0]%%%}] at parameters values [18.4052062202,51.6443148847]

1/sageVARb*(2*sageVARb*abs(sageVARb)/sageVARb^2*(2*((12*sageVARb^5/144/sageVARb^7*sqrt(sageVARb*sageVARx+2)*sqrt(sageVARb*sageVARx+2)-78*sageVARb^5/144/sageVARb^7)*sqrt(sageVARb*sageVARx+2)*sqrt(sageVARb*sageVARx+2)+198*sageVARb^5/144/sageVARb^7)*sqrt(sageVARb*sageVARx+2)*sqrt(sageVARb*(sageVARb*sageVARx+2)-2*sageVARb)+5/2/sageVARb/sqrt(sageVARb)*ln(abs(sqrt(sageVARb*(sageVARb*sageVARx+2)-2*sageVARb)-sqrt(sageVARb)*sqrt(sageVARb*sageVARx+2))))+4*abs(sageVARb)/sageVARb^2/sageVARb*(2*(1/8*sqrt(sageVARb*sageVARx+2)*sqrt(sageVARb*sageVARx+2)-5/8)*sqrt(sageVARb*sageVARx+2)*sqrt(sageVARb*(sageVARb*sageVARx+2)-2*sageVARb)-6*sageVARb/4/sqrt(sageVARb)*ln(abs(sqrt(sageVARb*(sageVARb*sageVARx+2)-2*sageVARb)-sqrt(sageVARb)*sqrt(sageVARb*sageVARx+2)))))
sage:

But when using giac directly, it works with no errors

>giac
// Using locale /usr/local/share/locale/
// C.UTF-8
// /usr/local/share/locale/
// giac
// UTF-8
// Maximum number of parallel threads 24
Added 0 synonyms
Welcome to giac readline interface, version 1.9.0
(c) 2001,2021 B. Parisse & others
Homepage http://www-fourier.ujf-grenoble.fr/~parisse/giac.html
Released under the GPL license 3.0 or above
See http://www.gnu.org for license details
May contain BSD licensed software parts (lapack, atlas, tinymt)
-------------------------------------------------
Press CTRL and D simultaneously to finish session
Type ?commandname for help
0>> integrate( x^(3/2)*(b*x+2)^(1/2),x)
2*(2*((12*b^4*1/144/b^4*sqrt(x)*sqrt(x)+6*b^3*1/144/b^4)*sqrt(x)*sqrt(x)-18*b^2*1/144/b^4)*sqrt(x)*sqrt(b*x+2)-1/2/b^2/sqrt(b)*ln(sqrt(b*x+2)-sqrt(b)*sqrt(x)))
// Time 0.01
1>>

Here are more information

>which sage
/home/me/DATA/sage-9.6/sage
>sage --version
SageMath version 9.6, Release Date: 2022-05-15
>which giac
/usr/local/bin/giac
>giac --version
// Using locale /usr/local/share/locale/
// C.UTF-8
// /usr/local/share/locale/
// giac
// UTF-8
// Maximum number of parallel threads 24
// (c) 2001, 2021 B. Parisse & others
1.9.0

>cat /etc/*-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=22.04
DISTRIB_CODENAME=jammy
DISTRIB_DESCRIPTION="Ubuntu 22.04 LTS"
PRETTY_NAME="Ubuntu 22.04 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04 LTS (Jammy Jellyfish)"
VERSION_CODENAME=jammy


>$SAGE_ROOT/sage --version
 SageMath version 9.6, Release Date: 2022-05-15

>cd $SAGE_ROOT/local/bin

>ls -l giac
lrwxrwxrwx 1 me me 19 May 16 17:02 giac -> /usr/local/bin/giac
>

I see many integrals that fail the same way using giac. I was hoping this will be fixed in sage 9.6

Where is choosing root of message coming from? Because when calling giac directly, I see no such message displayed. This looks like a message that giac would have generated.

Is sagemath reading additional output from giac somehow that do not show up on the terminal when using giac directly? As you can see from above, giac printed no such message. (unless it is hidden somehow?)

Any idea what is going on?

Update

It appears that sagemath is using old giac version it build. it must be a library of giac, since I deleted the binary in $SAGE_ROOT/local/bin

My question now is: How to tell sagemath NOT to build giac itself? I tried

  ./configure --with-system-python=no --with-system-giac=yes

And also

 ./configure --with-system-python=no --with-system-giac=no

And in both cases (each time starting from a fresh sagemath installation) I see it is still building old giac [giac-1.6.0.47p3.p0] by looking at the output of make

Could someone please give simple and clear instruction what should one to do to tell sagemath to use the system giac located in /usr/local/bin and NOT build the old giac version that comes with sagemath tar file?

It is a nightmere just to get sagemath to use the correct version of CAS I want. I now have no idea what version of external CAS I am using when running sagemath any more. I also using installed newer maxima installed maxima in /usr/local/bin and now I am not sure that sagemath is using that one or is using its own older version of maxima.

There should be an easy and clear way to do these things.

still getting Malform expression using giac in 9.6

I am using sagemath 9.6 with latest giac 1.9.0-7

I am not using giac that comes with sagemath 9.6 since that is old. So I points it to use the latest giac outside of sagemath.

Here is an example of such problem

>sage
┌────────────────────────────────────────────────────────────────────┐
│ SageMath version 9.6, Release Date: 2022-05-15                     │
│ Using Python 3.10.4. Type "help()" for help.                       │
└────────────────────────────────────────────────────────────────────┘
sage: var('x,b')
(x, b)

sage: integrate(x^(3/2)*(b*x+2)^(1/2),x,algorithm="giac")
---------------------------------------------------------------------------
SyntaxError                               Traceback (most recent call last)
~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/interfaces/giac.py in _sage_(self, locals)
   1138             try:
-> 1139                 return symbolic_expression_from_string(result, lsymbols,
   1140                     accept_sequence=True, parser=SR_parser_giac)

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/calculus/calculus.py in symbolic_expression_from_string(s, syms, accept_sequence, parser)
   2568                                               if _is_function(v)})
-> 2569     return parse_func(s)
   2570

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/misc/parser.pyx in sage.misc.parser.Parser.parse_sequence (build/cythonized/sage/misc/parser.c:6025)()
    574
--> 575     cpdef parse_sequence(self, s):
    576         """

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/misc/parser.pyx in sage.misc.parser.Parser.parse_sequence (build/cythonized/sage/misc/parser.c:5912)()
    592         if tokens.next() != EOS:
--> 593             self.parse_error(tokens)
    594         if len(all) == 1 and isinstance(all, list):

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/misc/parser.pyx in sage.misc.parser.Parser.parse_error (build/cythonized/sage/misc/parser.c:10396)()
   1043     cdef parse_error(self, Tokenizer tokens, msg="Malformed expression"):
-> 1044         raise SyntaxError(msg, tokens.s, tokens.pos)
   1045

SyntaxError: Malformed expression

During handling of the above exception, another exception occurred:

NotImplementedError                       Traceback (most recent call last)
<ipython-input-6-2f599f779b32> in <module>
----> 1 integrate(x**(Integer(3)/Integer(2))*(b*x+Integer(2))**(Integer(1)/Integer(2)),x,algorithm="giac")

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/misc/functional.py in integral(x, *args, **kwds)
    762     """
    763     if hasattr(x, 'integral'):
--> 764         return x.integral(*args, **kwds)
    765     else:
    766         from sage.symbolic.ring import SR

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/symbolic/expression.pyx in sage.symbolic.expression.Expression.integral (build/cythonized/sage/symbolic/expression.cpp:95445)()
  13192                     R = SR
  13193             return R(integral(f, v, a, b, **kwds))
> 13194         return integral(self, *args, **kwds)
  13195
  13196     integrate = integral

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/symbolic/integration/integral.py in integrate(expression, v, a, b, algorithm, hold)
   1045         if not integrator:
   1046             raise ValueError("Unknown algorithm: %s" % algorithm)
-> 1047         return integrator(expression, v, a, b)
   1048     if a is None:
   1049         return indefinite_integral(expression, v, hold=hold)

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/symbolic/integration/external.py in giac_integrator(expression, v, a, b)
    256         return expression.integrate(v, a, b, hold=True)
    257     else:
--> 258         return result._sage_()
    259
    260 def libgiac_integrator(expression, v, a=None, b=None):

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/interfaces/giac.py in _sage_(self, locals)
   1141
   1142             except Exception:
-> 1143                 raise NotImplementedError("Unable to parse Giac output: %s" % result)
   1144         else:
   1145             return [entry.sage() for entry in self]

NotImplementedError: Unable to parse Giac output: Warning, choosing root of [1,0,%%%{-4,[1,1]%%%}+%%%{-4,[1,0]%%%}+%%%{-4,[0,1]%%%}+%%%{-8,[0,0]%%%},0,%%%{6,[2,2]%%%}+%%%{4,[2,1]%%%}+%%%{6,[2,0]%%%}+%%%{4,[1,2]%%%}+%%%{28,[1,1]%%%}+%%%{8,[1,0]%%%}+%%%{6,[0,2]%%%}+%%%{8,[0,1]%%%}+%%%{24,[0,0]%%%},0,%%%{-4,[3,3]%%%}+%%%{4,[3,2]%%%}+%%%{4,[3,1]%%%}+%%%{-4,[3,0]%%%}+%%%{4,[2,3]%%%}+%%%{-64,[2,2]%%%}+%%%{20,[2,1]%%%}+%%%{8,[2,0]%%%}+%%%{4,[1,3]%%%}+%%%{20,[1,2]%%%}+%%%{-128,[1,1]%%%}+%%%{16,[1,0]%%%}+%%%{-4,[0,3]%%%}+%%%{8,[0,2]%%%}+%%%{16,[0,1]%%%}+%%%{-32,[0,0]%%%},0,%%%{1,[4,4]%%%}+%%%{-4,[4,3]%%%}+%%%{6,[4,2]%%%}+%%%{-4,[4,1]%%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%%{24,[0,2]%%%}+%%%{-32,[0,1]%%%}+%%%{16,[0,0]%%%}] at parameters values [18.4052062202,51.6443148847]

1/sageVARb*(2*sageVARb*abs(sageVARb)/sageVARb^2*(2*((12*sageVARb^5/144/sageVARb^7*sqrt(sageVARb*sageVARx+2)*sqrt(sageVARb*sageVARx+2)-78*sageVARb^5/144/sageVARb^7)*sqrt(sageVARb*sageVARx+2)*sqrt(sageVARb*sageVARx+2)+198*sageVARb^5/144/sageVARb^7)*sqrt(sageVARb*sageVARx+2)*sqrt(sageVARb*(sageVARb*sageVARx+2)-2*sageVARb)+5/2/sageVARb/sqrt(sageVARb)*ln(abs(sqrt(sageVARb*(sageVARb*sageVARx+2)-2*sageVARb)-sqrt(sageVARb)*sqrt(sageVARb*sageVARx+2))))+4*abs(sageVARb)/sageVARb^2/sageVARb*(2*(1/8*sqrt(sageVARb*sageVARx+2)*sqrt(sageVARb*sageVARx+2)-5/8)*sqrt(sageVARb*sageVARx+2)*sqrt(sageVARb*(sageVARb*sageVARx+2)-2*sageVARb)-6*sageVARb/4/sqrt(sageVARb)*ln(abs(sqrt(sageVARb*(sageVARb*sageVARx+2)-2*sageVARb)-sqrt(sageVARb)*sqrt(sageVARb*sageVARx+2)))))
sage:

But when using giac directly, it works with no errors

>giac
// Using locale /usr/local/share/locale/
// C.UTF-8
// /usr/local/share/locale/
// giac
// UTF-8
// Maximum number of parallel threads 24
Added 0 synonyms
Welcome to giac readline interface, version 1.9.0
(c) 2001,2021 B. Parisse & others
Homepage http://www-fourier.ujf-grenoble.fr/~parisse/giac.html
Released under the GPL license 3.0 or above
See http://www.gnu.org for license details
May contain BSD licensed software parts (lapack, atlas, tinymt)
-------------------------------------------------
Press CTRL and D simultaneously to finish session
Type ?commandname for help
0>> integrate( x^(3/2)*(b*x+2)^(1/2),x)
2*(2*((12*b^4*1/144/b^4*sqrt(x)*sqrt(x)+6*b^3*1/144/b^4)*sqrt(x)*sqrt(x)-18*b^2*1/144/b^4)*sqrt(x)*sqrt(b*x+2)-1/2/b^2/sqrt(b)*ln(sqrt(b*x+2)-sqrt(b)*sqrt(x)))
// Time 0.01
1>>

Here are more information

>which sage
/home/me/DATA/sage-9.6/sage
>sage --version
SageMath version 9.6, Release Date: 2022-05-15
>which giac
/usr/local/bin/giac
>giac --version
// Using locale /usr/local/share/locale/
// C.UTF-8
// /usr/local/share/locale/
// giac
// UTF-8
// Maximum number of parallel threads 24
// (c) 2001, 2021 B. Parisse & others
1.9.0

>cat /etc/*-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=22.04
DISTRIB_CODENAME=jammy
DISTRIB_DESCRIPTION="Ubuntu 22.04 LTS"
PRETTY_NAME="Ubuntu 22.04 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04 LTS (Jammy Jellyfish)"
VERSION_CODENAME=jammy


>$SAGE_ROOT/sage --version
 SageMath version 9.6, Release Date: 2022-05-15

>cd $SAGE_ROOT/local/bin

>ls -l giac
lrwxrwxrwx 1 me me 19 May 16 17:02 giac -> /usr/local/bin/giac
>

I see many integrals that fail the same way using giac. I was hoping this will be fixed in sage 9.6

Where is choosing root of message coming from? Because when calling giac directly, I see no such message displayed. This looks like a message that giac would have generated.

Is sagemath reading additional output from giac somehow that do not show up on the terminal when using giac directly? As you can see from above, giac printed no such message. (unless it is hidden somehow?)

Any idea what is going on?

Update

It appears that sagemath is using old giac version it build. it must be a library of giac, since I deleted the binary in $SAGE_ROOT/local/bin

My question now is: How to tell sagemath NOT to build giac itself? I tried

  ./configure --with-system-python=no --with-system-giac=yes

And also

 ./configure --with-system-python=no --with-system-giac=no

And in both cases (each time starting from a fresh sagemath installation) I see it is still building old giac [giac-1.6.0.47p3.p0] by looking at the output of make. I want sagemath to use newer giac version 1.9 in /usr/local/bin.

Could someone please give simple and clear instruction what should one to do to tell sagemath to use the system giac located in /usr/local/bin and NOT build the old giac version that comes with sagemath tar file?

I made sure LD_LIBRARY_PATH has /usr/local/lib as first entry. I also have /usr/local/lib as first line in /etc/ld.so.conf and also did ldconfig as root.

It is a nightmere just to get sagemath to use the correct version of CAS I want. I now have no idea what version of external CAS I am using when running sagemath any more. I also installed newer maxima in /usr/local/bin and now I am not sure that sagemath is using that one or is using its own older version of maxima.

There should be an easy and clear way to do these things.

still getting Malform expression using giac in 9.6

I am using sagemath 9.6 with latest giac 1.9.0-7

I am not using giac that comes with sagemath 9.6 since that is old. So I points it to use the latest giac outside of sagemath.

Here is an example of such problem

>sage
┌────────────────────────────────────────────────────────────────────┐
│ SageMath version 9.6, Release Date: 2022-05-15                     │
│ Using Python 3.10.4. Type "help()" for help.                       │
└────────────────────────────────────────────────────────────────────┘
sage: var('x,b')
(x, b)

sage: integrate(x^(3/2)*(b*x+2)^(1/2),x,algorithm="giac")
---------------------------------------------------------------------------
SyntaxError                               Traceback (most recent call last)
~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/interfaces/giac.py in _sage_(self, locals)
   1138             try:
-> 1139                 return symbolic_expression_from_string(result, lsymbols,
   1140                     accept_sequence=True, parser=SR_parser_giac)

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/calculus/calculus.py in symbolic_expression_from_string(s, syms, accept_sequence, parser)
   2568                                               if _is_function(v)})
-> 2569     return parse_func(s)
   2570

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/misc/parser.pyx in sage.misc.parser.Parser.parse_sequence (build/cythonized/sage/misc/parser.c:6025)()
    574
--> 575     cpdef parse_sequence(self, s):
    576         """

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/misc/parser.pyx in sage.misc.parser.Parser.parse_sequence (build/cythonized/sage/misc/parser.c:5912)()
    592         if tokens.next() != EOS:
--> 593             self.parse_error(tokens)
    594         if len(all) == 1 and isinstance(all, list):

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/misc/parser.pyx in sage.misc.parser.Parser.parse_error (build/cythonized/sage/misc/parser.c:10396)()
   1043     cdef parse_error(self, Tokenizer tokens, msg="Malformed expression"):
-> 1044         raise SyntaxError(msg, tokens.s, tokens.pos)
   1045

SyntaxError: Malformed expression

During handling of the above exception, another exception occurred:

NotImplementedError                       Traceback (most recent call last)
<ipython-input-6-2f599f779b32> in <module>
----> 1 integrate(x**(Integer(3)/Integer(2))*(b*x+Integer(2))**(Integer(1)/Integer(2)),x,algorithm="giac")

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/misc/functional.py in integral(x, *args, **kwds)
    762     """
    763     if hasattr(x, 'integral'):
--> 764         return x.integral(*args, **kwds)
    765     else:
    766         from sage.symbolic.ring import SR

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/symbolic/expression.pyx in sage.symbolic.expression.Expression.integral (build/cythonized/sage/symbolic/expression.cpp:95445)()
  13192                     R = SR
  13193             return R(integral(f, v, a, b, **kwds))
> 13194         return integral(self, *args, **kwds)
  13195
  13196     integrate = integral

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/symbolic/integration/integral.py in integrate(expression, v, a, b, algorithm, hold)
   1045         if not integrator:
   1046             raise ValueError("Unknown algorithm: %s" % algorithm)
-> 1047         return integrator(expression, v, a, b)
   1048     if a is None:
   1049         return indefinite_integral(expression, v, hold=hold)

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/symbolic/integration/external.py in giac_integrator(expression, v, a, b)
    256         return expression.integrate(v, a, b, hold=True)
    257     else:
--> 258         return result._sage_()
    259
    260 def libgiac_integrator(expression, v, a=None, b=None):

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/interfaces/giac.py in _sage_(self, locals)
   1141
   1142             except Exception:
-> 1143                 raise NotImplementedError("Unable to parse Giac output: %s" % result)
   1144         else:
   1145             return [entry.sage() for entry in self]

NotImplementedError: Unable to parse Giac output: Warning, choosing root of [1,0,%%%{-4,[1,1]%%%}+%%%{-4,[1,0]%%%}+%%%{-4,[0,1]%%%}+%%%{-8,[0,0]%%%},0,%%%{6,[2,2]%%%}+%%%{4,[2,1]%%%}+%%%{6,[2,0]%%%}+%%%{4,[1,2]%%%}+%%%{28,[1,1]%%%}+%%%{8,[1,0]%%%}+%%%{6,[0,2]%%%}+%%%{8,[0,1]%%%}+%%%{24,[0,0]%%%},0,%%%{-4,[3,3]%%%}+%%%{4,[3,2]%%%}+%%%{4,[3,1]%%%}+%%%{-4,[3,0]%%%}+%%%{4,[2,3]%%%}+%%%{-64,[2,2]%%%}+%%%{20,[2,1]%%%}+%%%{8,[2,0]%%%}+%%%{4,[1,3]%%%}+%%%{20,[1,2]%%%}+%%%{-128,[1,1]%%%}+%%%{16,[1,0]%%%}+%%%{-4,[0,3]%%%}+%%%{8,[0,2]%%%}+%%%{16,[0,1]%%%}+%%%{-32,[0,0]%%%},0,%%%{1,[4,4]%%%}+%%%{-4,[4,3]%%%}+%%%{6,[4,2]%%%}+%%%{-4,[4,1]%%%}+%%%{1,[4,0]%%%}+%%%{-4,[3,4]%%%}+%%%{12,[3,3]%%%}+%%%{-20,[3,2]%%%}+%%%{20,[3,1]%%%}+%%%{-8,[3,0]%%%}+%%%{6,[2,4]%%%}+%%%{-20,[2,3]%%%}+%%%{46,[2,2]%%%}+%%%{-40,[2,1]%%%}+%%%{24,[2,0]%%%}+%%%{-4,[1,4]%%%}+%%%{20,[1,3]%%%}+%%%{-40,[1,2]%%%}+%%%{48,[1,1]%%%}+%%%{-32,[1,0]%%%}+%%%{1,[0,4]%%%}+%%%{-8,[0,3]%%%}+%%%{24,[0,2]%%%}+%%%{-32,[0,1]%%%}+%%%{16,[0,0]%%%}] at parameters values [59.8656459874,25.8388736797]
Warning, choosing root of [1,0,%%%{-4,[1,1]%%%}+%%%{-4,[1,0]%%%}+%%%{-4,[0,1]%%%}+%%%{-8,[0,0]%%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{-4,[3,0]%%%}+%%%{4,[2,3]%%%}+%%%{-64,[2,2]%%%}+%%%{20,[2,1]%%%}+%%%{8,[2,0]%%%}+%%%{4,[1,3]%%%}+%%%{20,[1,2]%%%}+%%%{-128,[1,1]%%%}+%%%{16,[1,0]%%%}+%%%{-4,[0,3]%%%}+%%%{8,[0,2]%%%}+%%%{16,[0,1]%%%}+%%%{-32,[0,0]%%%},0,%%%{1,[4,4]%%%}+%%%{-4,[4,3]%%%}+%%%{6,[4,2]%%%}+%%%{-4,[4,1]%%%}+%%%{1,[4,0]%%%}+%%%{-4,[3,4]%%%}+%%%{12,[3,3]%%%}+%%%{-20,[3,2]%%%}+%%%{20,[3,1]%%%}+%%%{-8,[3,0]%%%}+%%%{6,[2,4]%%%}+%%%{-20,[2,3]%%%}+%%%{46,[2,2]%%%}+%%%{-40,[2,1]%%%}+%%%{24,[2,0]%%%}+%%%{-4,[1,4]%%%}+%%%{20,[1,3]%%%}+%%%{-40,[1,2]%%%}+%%%{48,[1,1]%%%}+%%%{-32,[1,0]%%%}+%%%{1,[0,4]%%%}+%%%{-8,[0,3]%%%}+%%%{24,[0,2]%%%}+%%%{-32,[0,1]%%%}+%%%{16,[0,0]%%%}] at parameters values [18.4052062202,51.6443148847]

1/sageVARb*(2*sageVARb*abs(sageVARb)/sageVARb^2*(2*((12*sageVARb^5/144/sageVARb^7*sqrt(sageVARb*sageVARx+2)*sqrt(sageVARb*sageVARx+2)-78*sageVARb^5/144/sageVARb^7)*sqrt(sageVARb*sageVARx+2)*sqrt(sageVARb*sageVARx+2)+198*sageVARb^5/144/sageVARb^7)*sqrt(sageVARb*sageVARx+2)*sqrt(sageVARb*(sageVARb*sageVARx+2)-2*sageVARb)+5/2/sageVARb/sqrt(sageVARb)*ln(abs(sqrt(sageVARb*(sageVARb*sageVARx+2)-2*sageVARb)-sqrt(sageVARb)*sqrt(sageVARb*sageVARx+2))))+4*abs(sageVARb)/sageVARb^2/sageVARb*(2*(1/8*sqrt(sageVARb*sageVARx+2)*sqrt(sageVARb*sageVARx+2)-5/8)*sqrt(sageVARb*sageVARx+2)*sqrt(sageVARb*(sageVARb*sageVARx+2)-2*sageVARb)-6*sageVARb/4/sqrt(sageVARb)*ln(abs(sqrt(sageVARb*(sageVARb*sageVARx+2)-2*sageVARb)-sqrt(sageVARb)*sqrt(sageVARb*sageVARx+2)))))
sage:

But when using giac directly, it works with no errors

>giac
// Using locale /usr/local/share/locale/
// C.UTF-8
// /usr/local/share/locale/
// giac
// UTF-8
// Maximum number of parallel threads 24
Added 0 synonyms
Welcome to giac readline interface, version 1.9.0
(c) 2001,2021 B. Parisse & others
Homepage http://www-fourier.ujf-grenoble.fr/~parisse/giac.html
Released under the GPL license 3.0 or above
See http://www.gnu.org for license details
May contain BSD licensed software parts (lapack, atlas, tinymt)
-------------------------------------------------
Press CTRL and D simultaneously to finish session
Type ?commandname for help
0>> integrate( x^(3/2)*(b*x+2)^(1/2),x)
2*(2*((12*b^4*1/144/b^4*sqrt(x)*sqrt(x)+6*b^3*1/144/b^4)*sqrt(x)*sqrt(x)-18*b^2*1/144/b^4)*sqrt(x)*sqrt(b*x+2)-1/2/b^2/sqrt(b)*ln(sqrt(b*x+2)-sqrt(b)*sqrt(x)))
// Time 0.01
1>>

Here are more information

>which sage
/home/me/DATA/sage-9.6/sage
>sage --version
SageMath version 9.6, Release Date: 2022-05-15
>which giac
/usr/local/bin/giac
>giac --version
// Using locale /usr/local/share/locale/
// C.UTF-8
// /usr/local/share/locale/
// giac
// UTF-8
// Maximum number of parallel threads 24
// (c) 2001, 2021 B. Parisse & others
1.9.0

>cat /etc/*-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=22.04
DISTRIB_CODENAME=jammy
DISTRIB_DESCRIPTION="Ubuntu 22.04 LTS"
PRETTY_NAME="Ubuntu 22.04 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04 LTS (Jammy Jellyfish)"
VERSION_CODENAME=jammy


>$SAGE_ROOT/sage --version
 SageMath version 9.6, Release Date: 2022-05-15

>cd $SAGE_ROOT/local/bin

>ls -l giac
lrwxrwxrwx 1 me me 19 May 16 17:02 giac -> /usr/local/bin/giac
>

I see many integrals that fail the same way using giac. I was hoping this will be fixed in sage 9.6

Where is choosing root of message coming from? Because when calling giac directly, I see no such message displayed. This looks like a message that giac would have generated.

Is sagemath reading additional output from giac somehow that do not show up on the terminal when using giac directly? As you can see from above, giac printed no such message. (unless it is hidden somehow?)

Any idea what is going on?

Update

It appears that sagemath is using old giac version it build. it must be a library of giac, since I deleted the binary in $SAGE_ROOT/local/bin

My question now is: How to tell sagemath NOT to build giac itself? I tried

  ./configure --with-system-python=no --with-system-giac=yes

And also

 ./configure --with-system-python=no --with-system-giac=no

And in both cases (each time starting from a fresh sagemath installation) I see it is still building old giac [giac-1.6.0.47p3.p0] by looking at the output of make. I want sagemath to use newer giac version 1.9 in /usr/local/bin.

Could someone please give simple and clear instruction what should one to do to tell sagemath to use the system giac located in /usr/local/bin and NOT build the old giac version that comes with sagemath tar file?

I made sure LD_LIBRARY_PATH has /usr/local/lib as first entry. I also have /usr/local/lib as first line in /etc/ld.so.conf and also did ldconfig as root.

It is a nightmere just to get sagemath to use the correct version of CAS I want. I now have no idea what version of external CAS I am using when running sagemath any more. I also installed newer maxima in /usr/local/bin and now I am not sure that sagemath is using that one or is using its own older version of maxima.

There should be an easy and clear way to do these things.

Update 2

I found how to tell sagemath NOT to build giac. But after all of this, it is still not using the system giac.

To be able to tell sagemath to use the currently system installed giac and to also tell sagemath NOT to build the giac that comes with it since that version is old, this is what I did.

After extracting the sagemath 9.6 tar file, then

    cd sage-9.6
    unset SAGE_ROOT
    unset SAGE_LOCAL
    export GIAC=/usr/local/bin/giac    #this is critical. 
    ./configure --with-system-giac=force

And now it says

  giac-1.6.0.47p3.p0: using system package; SPKG will not be installed

Finally!

The main trick was to set $GIAC environment variable before running ./configure. I found this out by looking the configure script code. It uses this environment variable to locate the system giac.

This was not documented anywhere.

But after make is completed, I started sage and found it is still using some build in giac library! I have no idea where that is hiding.

>sage
┌────────────────────────────────────────────────────────────────────┐
│ SageMath version 9.6, Release Date: 2022-05-15                     │
│ Using Python 3.10.4. Type "help()" for help.                       │
└────────────────────────────────────────────────────────────────────┘
sage: var('x b')
(x, b)
sage: integrate(x^(3/2)*(b*x+2)^(1/2),x,algorithm="giac")
.....
NotImplementedError: Unable to parse Giac output: Warning, choosing root of

Same error as before.

sage: ver = installed_packages()
sage:  ver['giac']
---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
<ipython-input-4-1a56169f01e6> in <module>
----> 1 ver['giac']

KeyError: 'giac'
sage: print(giac.version())
"giac 1.9.0, (c) B. Parisse and R. De Graeve, Institut Fourier, Universite de Grenoble I"
sage:

You can see, that giac is not installed by sage. I looked at make output, and it did NOT build giac. But the above error message indicates it is using an OLD giac version. Where is it loading that from?

>cd /usr/local/lib
>ls -lrt *giac*
-rwxr-xr-x 1 root root 174377296 May 16 17:01 libgiac.so.0.0.0
lrwxrwxrwx 1 root root        16 May 16 17:01 libgiac.so.0 -> libgiac.so.0.0.0
lrwxrwxrwx 1 root root        16 May 16 17:01 libgiac.so -> libgiac.so.0.0.0
-rwxr-xr-x 1 root root      1154 May 16 17:01 libgiac.la
-rw-r--r-- 1 root root 398468174 May 16 17:01 libgiac.a

 echo $LD_LIBRARY_PATH
  :/usr/local/lib

>cat /etc/ld.so.conf
/usr/local/lib
include /etc/ld.so.conf.d/*.conf

Any one has any idea where is sagemath finding/using old giac library code from??

still getting Malform expression using giac in 9.6

I am using sagemath 9.6 with latest giac 1.9.0-7

I am not using giac that comes with sagemath 9.6 since that is old. So I points it to use the latest giac outside of sagemath.

Here is an example of such problem

>sage
┌────────────────────────────────────────────────────────────────────┐
│ SageMath version 9.6, Release Date: 2022-05-15                     │
│ Using Python 3.10.4. Type "help()" for help.                       │
└────────────────────────────────────────────────────────────────────┘
sage: var('x,b')
(x, b)

sage: integrate(x^(3/2)*(b*x+2)^(1/2),x,algorithm="giac")
---------------------------------------------------------------------------
SyntaxError                               Traceback (most recent call last)
~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/interfaces/giac.py in _sage_(self, locals)
   1138             try:
-> 1139                 return symbolic_expression_from_string(result, lsymbols,
   1140                     accept_sequence=True, parser=SR_parser_giac)

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/calculus/calculus.py in symbolic_expression_from_string(s, syms, accept_sequence, parser)
   2568                                               if _is_function(v)})
-> 2569     return parse_func(s)
   2570

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/misc/parser.pyx in sage.misc.parser.Parser.parse_sequence (build/cythonized/sage/misc/parser.c:6025)()
    574
--> 575     cpdef parse_sequence(self, s):
    576         """

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/misc/parser.pyx in sage.misc.parser.Parser.parse_sequence (build/cythonized/sage/misc/parser.c:5912)()
    592         if tokens.next() != EOS:
--> 593             self.parse_error(tokens)
    594         if len(all) == 1 and isinstance(all, list):

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/misc/parser.pyx in sage.misc.parser.Parser.parse_error (build/cythonized/sage/misc/parser.c:10396)()
   1043     cdef parse_error(self, Tokenizer tokens, msg="Malformed expression"):
-> 1044         raise SyntaxError(msg, tokens.s, tokens.pos)
   1045

SyntaxError: Malformed expression

During handling of the above exception, another exception occurred:

NotImplementedError                       Traceback (most recent call last)
<ipython-input-6-2f599f779b32> in <module>
----> 1 integrate(x**(Integer(3)/Integer(2))*(b*x+Integer(2))**(Integer(1)/Integer(2)),x,algorithm="giac")

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/misc/functional.py in integral(x, *args, **kwds)
    762     """
    763     if hasattr(x, 'integral'):
--> 764         return x.integral(*args, **kwds)
    765     else:
    766         from sage.symbolic.ring import SR

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/symbolic/expression.pyx in sage.symbolic.expression.Expression.integral (build/cythonized/sage/symbolic/expression.cpp:95445)()
  13192                     R = SR
  13193             return R(integral(f, v, a, b, **kwds))
> 13194         return integral(self, *args, **kwds)
  13195
  13196     integrate = integral

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/symbolic/integration/integral.py in integrate(expression, v, a, b, algorithm, hold)
   1045         if not integrator:
   1046             raise ValueError("Unknown algorithm: %s" % algorithm)
-> 1047         return integrator(expression, v, a, b)
   1048     if a is None:
   1049         return indefinite_integral(expression, v, hold=hold)

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/symbolic/integration/external.py in giac_integrator(expression, v, a, b)
    256         return expression.integrate(v, a, b, hold=True)
    257     else:
--> 258         return result._sage_()
    259
    260 def libgiac_integrator(expression, v, a=None, b=None):

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/interfaces/giac.py in _sage_(self, locals)
   1141
   1142             except Exception:
-> 1143                 raise NotImplementedError("Unable to parse Giac output: %s" % result)
   1144         else:
   1145             return [entry.sage() for entry in self]

NotImplementedError: Unable to parse Giac output: Warning, choosing root of [1,0,%%%{-4,[1,1]%%%}+%%%{-4,[1,0]%%%}+%%%{-4,[0,1]%%%}+%%%{-8,[0,0]%%%},0,%%%{6,[2,2]%%%}+%%%{4,[2,1]%%%}+%%%{6,[2,0]%%%}+%%%{4,[1,2]%%%}+%%%{28,[1,1]%%%}+%%%{8,[1,0]%%%}+%%%{6,[0,2]%%%}+%%%{8,[0,1]%%%}+%%%{24,[0,0]%%%},0,%%%{-4,[3,3]%%%}+%%%{4,[3,2]%%%}+%%%{4,[3,1]%%%}+%%%{-4,[3,0]%%%}+%%%{4,[2,3]%%%}+%%%{-64,[2,2]%%%}+%%%{20,[2,1]%%%}+%%%{8,[2,0]%%%}+%%%{4,[1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%%}+%%%{-20,[2,3]%%%}+%%%{46,[2,2]%%%}+%%%{-40,[2,1]%%%}+%%%{24,[2,0]%%%}+%%%{-4,[1,4]%%%}+%%%{20,[1,3]%%%}+%%%{-40,[1,2]%%%}+%%%{48,[1,1]%%%}+%%%{-32,[1,0]%%%}+%%%{1,[0,4]%%%}+%%%{-8,[0,3]%%%}+%%%{24,[0,2]%%%}+%%%{-32,[0,1]%%%}+%%%{16,[0,0]%%%}] at parameters values [18.4052062202,51.6443148847]

1/sageVARb*(2*sageVARb*abs(sageVARb)/sageVARb^2*(2*((12*sageVARb^5/144/sageVARb^7*sqrt(sageVARb*sageVARx+2)*sqrt(sageVARb*sageVARx+2)-78*sageVARb^5/144/sageVARb^7)*sqrt(sageVARb*sageVARx+2)*sqrt(sageVARb*sageVARx+2)+198*sageVARb^5/144/sageVARb^7)*sqrt(sageVARb*sageVARx+2)*sqrt(sageVARb*(sageVARb*sageVARx+2)-2*sageVARb)+5/2/sageVARb/sqrt(sageVARb)*ln(abs(sqrt(sageVARb*(sageVARb*sageVARx+2)-2*sageVARb)-sqrt(sageVARb)*sqrt(sageVARb*sageVARx+2))))+4*abs(sageVARb)/sageVARb^2/sageVARb*(2*(1/8*sqrt(sageVARb*sageVARx+2)*sqrt(sageVARb*sageVARx+2)-5/8)*sqrt(sageVARb*sageVARx+2)*sqrt(sageVARb*(sageVARb*sageVARx+2)-2*sageVARb)-6*sageVARb/4/sqrt(sageVARb)*ln(abs(sqrt(sageVARb*(sageVARb*sageVARx+2)-2*sageVARb)-sqrt(sageVARb)*sqrt(sageVARb*sageVARx+2)))))
sage:

But when using giac directly, it works with no errors

>giac
// Using locale /usr/local/share/locale/
// C.UTF-8
// /usr/local/share/locale/
// giac
// UTF-8
// Maximum number of parallel threads 24
Added 0 synonyms
Welcome to giac readline interface, version 1.9.0
(c) 2001,2021 B. Parisse & others
Homepage http://www-fourier.ujf-grenoble.fr/~parisse/giac.html
Released under the GPL license 3.0 or above
See http://www.gnu.org for license details
May contain BSD licensed software parts (lapack, atlas, tinymt)
-------------------------------------------------
Press CTRL and D simultaneously to finish session
Type ?commandname for help
0>> integrate( x^(3/2)*(b*x+2)^(1/2),x)
2*(2*((12*b^4*1/144/b^4*sqrt(x)*sqrt(x)+6*b^3*1/144/b^4)*sqrt(x)*sqrt(x)-18*b^2*1/144/b^4)*sqrt(x)*sqrt(b*x+2)-1/2/b^2/sqrt(b)*ln(sqrt(b*x+2)-sqrt(b)*sqrt(x)))
// Time 0.01
1>>

Here are more information

>which sage
/home/me/DATA/sage-9.6/sage
>sage --version
SageMath version 9.6, Release Date: 2022-05-15
>which giac
/usr/local/bin/giac
>giac --version
// Using locale /usr/local/share/locale/
// C.UTF-8
// /usr/local/share/locale/
// giac
// UTF-8
// Maximum number of parallel threads 24
// (c) 2001, 2021 B. Parisse & others
1.9.0

>cat /etc/*-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=22.04
DISTRIB_CODENAME=jammy
DISTRIB_DESCRIPTION="Ubuntu 22.04 LTS"
PRETTY_NAME="Ubuntu 22.04 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04 LTS (Jammy Jellyfish)"
VERSION_CODENAME=jammy


>$SAGE_ROOT/sage --version
 SageMath version 9.6, Release Date: 2022-05-15

>cd $SAGE_ROOT/local/bin

>ls -l giac
lrwxrwxrwx 1 me me 19 May 16 17:02 giac -> /usr/local/bin/giac
>

I see many integrals that fail the same way using giac. I was hoping this will be fixed in sage 9.6

Where is choosing root of message coming from? Because when calling giac directly, I see no such message displayed. This looks like a message that giac would have generated.

Is sagemath reading additional output from giac somehow that do not show up on the terminal when using giac directly? As you can see from above, giac printed no such message. (unless it is hidden somehow?)

Any idea what is going on?

Update

It appears that sagemath is using old giac version it build. it must be a library of giac, since I deleted the binary in $SAGE_ROOT/local/bin

My question now is: How to tell sagemath NOT to build giac itself? I tried

  ./configure --with-system-python=no --with-system-giac=yes

And also

 ./configure --with-system-python=no --with-system-giac=no

And in both cases (each time starting from a fresh sagemath installation) I see it is still building old giac [giac-1.6.0.47p3.p0] by looking at the output of make. I want sagemath to use newer giac version 1.9 in /usr/local/bin.

Could someone please give simple and clear instruction what should one to do to tell sagemath to use the system giac located in /usr/local/bin and NOT build the old giac version that comes with sagemath tar file?

I made sure LD_LIBRARY_PATH has /usr/local/lib as first entry. I also have /usr/local/lib as first line in /etc/ld.so.conf and also did ldconfig as root.

It is a nightmere just to get sagemath to use the correct version of CAS I want. I now have no idea what version of external CAS I am using when running sagemath any more. I also installed newer maxima in /usr/local/bin and now I am not sure that sagemath is using that one or is using its own older version of maxima.

There should be an easy and clear way to do these things.

Update 2

I found how to tell sagemath NOT to build giac. But after all of this, it is still not using the system giac.

To be able to tell sagemath to use the currently system installed giac and to also tell sagemath NOT to build the giac that comes with it since that version is old, this is what I did.

After extracting the sagemath 9.6 tar file, then

    cd sage-9.6
    unset SAGE_ROOT
    unset SAGE_LOCAL
    export GIAC=/usr/local/bin/giac    #this is critical. 
    ./configure --with-system-giac=force

And now it says

  giac-1.6.0.47p3.p0: using system package; SPKG will not be installed

Finally!

The main trick was to set $GIAC environment variable before running ./configure. I found this out by looking the configure script code. It uses this environment variable to locate the system giac.

This was not documented anywhere.

But after make is completed, I started sage and found it is still using some build in giac library! I have no idea where that is hiding.

>sage
┌────────────────────────────────────────────────────────────────────┐
│ SageMath version 9.6, Release Date: 2022-05-15                     │
│ Using Python 3.10.4. Type "help()" for help.                       │
└────────────────────────────────────────────────────────────────────┘
sage: var('x b')
(x, b)
sage: integrate(x^(3/2)*(b*x+2)^(1/2),x,algorithm="giac")
.....
NotImplementedError: Unable to parse Giac output: Warning, choosing root of

Same error as before.

sage: ver = installed_packages()
sage:  ver['giac']
---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
<ipython-input-4-1a56169f01e6> in <module>
----> 1 ver['giac']

KeyError: 'giac'
sage: print(giac.version())
"giac 1.9.0, (c) B. Parisse and R. De Graeve, Institut Fourier, Universite de Grenoble I"
sage:

You can see, that giac is not installed by sage. I looked at make output, and it did NOT build giac. But the above error message indicates it is using an OLD giac version. Where is it loading that from?

>cd /usr/local/lib
>ls -lrt *giac*
-rwxr-xr-x 1 root root 174377296 May 16 17:01 libgiac.so.0.0.0
lrwxrwxrwx 1 root root        16 May 16 17:01 libgiac.so.0 -> libgiac.so.0.0.0
lrwxrwxrwx 1 root root        16 May 16 17:01 libgiac.so -> libgiac.so.0.0.0
-rwxr-xr-x 1 root root      1154 May 16 17:01 libgiac.la
-rw-r--r-- 1 root root 398468174 May 16 17:01 libgiac.a

 echo $LD_LIBRARY_PATH
  :/usr/local/lib

>cat /etc/ld.so.conf
/usr/local/lib
include /etc/ld.so.conf.d/*.conf

Any one has any idea where is sagemath finding/using old giac library code from??

I found the following

>dpkg -l | grep libgiac
ii  libgiac-dev                               1.7.0.39+dfsg2-1build2                  amd64        Computer Algebra System C++ library - Development files
ii  libgiac0:amd64                            1.7.0.39+dfsg2-1build2                  amd64        Computer Algebra System C++ library

These are OLD giac 1.7 libraries! I have no idea why they show up and who installed them. I know I only build giac 1.9 from source.

I think that is the problem. I just need to figure why they say version 1.7, when my giac binary is 1.9.

still getting Malform expression using giac in 9.6

I am using sagemath 9.6 with latest giac 1.9.0-7

I am not using giac that comes with sagemath 9.6 since that is old. So I points it to use the latest giac outside of sagemath.

Here is an example of such problem

>sage
┌────────────────────────────────────────────────────────────────────┐
│ SageMath version 9.6, Release Date: 2022-05-15                     │
│ Using Python 3.10.4. Type "help()" for help.                       │
└────────────────────────────────────────────────────────────────────┘
sage: var('x,b')
(x, b)

sage: integrate(x^(3/2)*(b*x+2)^(1/2),x,algorithm="giac")
---------------------------------------------------------------------------
SyntaxError                               Traceback (most recent call last)
~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/interfaces/giac.py in _sage_(self, locals)
   1138             try:
-> 1139                 return symbolic_expression_from_string(result, lsymbols,
   1140                     accept_sequence=True, parser=SR_parser_giac)

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/calculus/calculus.py in symbolic_expression_from_string(s, syms, accept_sequence, parser)
   2568                                               if _is_function(v)})
-> 2569     return parse_func(s)
   2570

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/misc/parser.pyx in sage.misc.parser.Parser.parse_sequence (build/cythonized/sage/misc/parser.c:6025)()
    574
--> 575     cpdef parse_sequence(self, s):
    576         """

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/misc/parser.pyx in sage.misc.parser.Parser.parse_sequence (build/cythonized/sage/misc/parser.c:5912)()
    592         if tokens.next() != EOS:
--> 593             self.parse_error(tokens)
    594         if len(all) == 1 and isinstance(all, list):

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/misc/parser.pyx in sage.misc.parser.Parser.parse_error (build/cythonized/sage/misc/parser.c:10396)()
   1043     cdef parse_error(self, Tokenizer tokens, msg="Malformed expression"):
-> 1044         raise SyntaxError(msg, tokens.s, tokens.pos)
   1045

SyntaxError: Malformed expression

During handling of the above exception, another exception occurred:

NotImplementedError                       Traceback (most recent call last)
<ipython-input-6-2f599f779b32> in <module>
----> 1 integrate(x**(Integer(3)/Integer(2))*(b*x+Integer(2))**(Integer(1)/Integer(2)),x,algorithm="giac")

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/misc/functional.py in integral(x, *args, **kwds)
    762     """
    763     if hasattr(x, 'integral'):
--> 764         return x.integral(*args, **kwds)
    765     else:
    766         from sage.symbolic.ring import SR

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/symbolic/expression.pyx in sage.symbolic.expression.Expression.integral (build/cythonized/sage/symbolic/expression.cpp:95445)()
  13192                     R = SR
  13193             return R(integral(f, v, a, b, **kwds))
> 13194         return integral(self, *args, **kwds)
  13195
  13196     integrate = integral

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/symbolic/integration/integral.py in integrate(expression, v, a, b, algorithm, hold)
   1045         if not integrator:
   1046             raise ValueError("Unknown algorithm: %s" % algorithm)
-> 1047         return integrator(expression, v, a, b)
   1048     if a is None:
   1049         return indefinite_integral(expression, v, hold=hold)

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/symbolic/integration/external.py in giac_integrator(expression, v, a, b)
    256         return expression.integrate(v, a, b, hold=True)
    257     else:
--> 258         return result._sage_()
    259
    260 def libgiac_integrator(expression, v, a=None, b=None):

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/interfaces/giac.py in _sage_(self, locals)
   1141
   1142             except Exception:
-> 1143                 raise NotImplementedError("Unable to parse Giac output: %s" % result)
   1144         else:
   1145             return [entry.sage() for entry in self]

NotImplementedError: Unable to parse Giac output: Warning, choosing root of [1,0,%%%{-4,[1,1]%%%}+%%%{-4,[1,0]%%%}+%%%{-4,[0,1]%%%}+%%%{-8,[0,0]%%%},0,%%%{6,[2,2]%%%}+%%%{4,[2,1]%%%}+%%%{6,[2,0]%%%}+%%%{4,[1,2]%%%}+%%%{28,[1,1]%%%}+%%%{8,[1,0]%%%}+%%%{6,[0,2]%%%}+%%%{8,[0,1]%%%}+%%%{24,[0,0]%%%},0,%%%{-4,[3,3]%%%}+%%%{4,[3,2]%%%}+%%%{4,[3,1]%%%}+%%%{-4,[3,0]%%%}+%%%{4,[2,3]%%%}+%%%{-64,[2,2]%%%}+%%%{20,[2,1]%%%}+%%%{8,[2,0]%%%}+%%%{4,[1,3]%%%}+%%%{20,[1,2]%%%}+%%%{-128,[1,1]%%%}+%%%{16,[1,0]%%%}+%%%{-4,[0,3]%%%}+%%%{8,[0,2]%%%}+%%%{16,[0,1]%%%}+%%%{-32,[0,0]%%%},0,%%%{1,[4,4]%%%}+%%%{-4,[4,3]%%%}+%%%{6,[4,2]%%%}+%%%{-4,[4,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%}+%%%{24,[0,2]%%%}+%%%{-32,[0,1]%%%}+%%%{16,[0,0]%%%}] at parameters values [18.4052062202,51.6443148847]

1/sageVARb*(2*sageVARb*abs(sageVARb)/sageVARb^2*(2*((12*sageVARb^5/144/sageVARb^7*sqrt(sageVARb*sageVARx+2)*sqrt(sageVARb*sageVARx+2)-78*sageVARb^5/144/sageVARb^7)*sqrt(sageVARb*sageVARx+2)*sqrt(sageVARb*sageVARx+2)+198*sageVARb^5/144/sageVARb^7)*sqrt(sageVARb*sageVARx+2)*sqrt(sageVARb*(sageVARb*sageVARx+2)-2*sageVARb)+5/2/sageVARb/sqrt(sageVARb)*ln(abs(sqrt(sageVARb*(sageVARb*sageVARx+2)-2*sageVARb)-sqrt(sageVARb)*sqrt(sageVARb*sageVARx+2))))+4*abs(sageVARb)/sageVARb^2/sageVARb*(2*(1/8*sqrt(sageVARb*sageVARx+2)*sqrt(sageVARb*sageVARx+2)-5/8)*sqrt(sageVARb*sageVARx+2)*sqrt(sageVARb*(sageVARb*sageVARx+2)-2*sageVARb)-6*sageVARb/4/sqrt(sageVARb)*ln(abs(sqrt(sageVARb*(sageVARb*sageVARx+2)-2*sageVARb)-sqrt(sageVARb)*sqrt(sageVARb*sageVARx+2)))))
sage:

But when using giac directly, it works with no errors

>giac
// Using locale /usr/local/share/locale/
// C.UTF-8
// /usr/local/share/locale/
// giac
// UTF-8
// Maximum number of parallel threads 24
Added 0 synonyms
Welcome to giac readline interface, version 1.9.0
(c) 2001,2021 B. Parisse & others
Homepage http://www-fourier.ujf-grenoble.fr/~parisse/giac.html
Released under the GPL license 3.0 or above
See http://www.gnu.org for license details
May contain BSD licensed software parts (lapack, atlas, tinymt)
-------------------------------------------------
Press CTRL and D simultaneously to finish session
Type ?commandname for help
0>> integrate( x^(3/2)*(b*x+2)^(1/2),x)
2*(2*((12*b^4*1/144/b^4*sqrt(x)*sqrt(x)+6*b^3*1/144/b^4)*sqrt(x)*sqrt(x)-18*b^2*1/144/b^4)*sqrt(x)*sqrt(b*x+2)-1/2/b^2/sqrt(b)*ln(sqrt(b*x+2)-sqrt(b)*sqrt(x)))
// Time 0.01
1>>

Here are more information

>which sage
/home/me/DATA/sage-9.6/sage
>sage --version
SageMath version 9.6, Release Date: 2022-05-15
>which giac
/usr/local/bin/giac
>giac --version
// Using locale /usr/local/share/locale/
// C.UTF-8
// /usr/local/share/locale/
// giac
// UTF-8
// Maximum number of parallel threads 24
// (c) 2001, 2021 B. Parisse & others
1.9.0

>cat /etc/*-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=22.04
DISTRIB_CODENAME=jammy
DISTRIB_DESCRIPTION="Ubuntu 22.04 LTS"
PRETTY_NAME="Ubuntu 22.04 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04 LTS (Jammy Jellyfish)"
VERSION_CODENAME=jammy


>$SAGE_ROOT/sage --version
 SageMath version 9.6, Release Date: 2022-05-15

>cd $SAGE_ROOT/local/bin

>ls -l giac
lrwxrwxrwx 1 me me 19 May 16 17:02 giac -> /usr/local/bin/giac
>

I see many integrals that fail the same way using giac. I was hoping this will be fixed in sage 9.6

Where is choosing root of message coming from? Because when calling giac directly, I see no such message displayed. This looks like a message that giac would have generated.

Is sagemath reading additional output from giac somehow that do not show up on the terminal when using giac directly? As you can see from above, giac printed no such message. (unless it is hidden somehow?)

Any idea what is going on?

Update

It appears that sagemath is using old giac version it build. it must be a library of giac, since I deleted the binary in $SAGE_ROOT/local/bin

My question now is: How to tell sagemath NOT to build giac itself? I tried

  ./configure --with-system-python=no --with-system-giac=yes

And also

 ./configure --with-system-python=no --with-system-giac=no

And in both cases (each time starting from a fresh sagemath installation) I see it is still building old giac [giac-1.6.0.47p3.p0] by looking at the output of make. I want sagemath to use newer giac version 1.9 in /usr/local/bin.

Could someone please give simple and clear instruction what should one to do to tell sagemath to use the system giac located in /usr/local/bin and NOT build the old giac version that comes with sagemath tar file?

I made sure LD_LIBRARY_PATH has /usr/local/lib as first entry. I also have /usr/local/lib as first line in /etc/ld.so.conf and also did ldconfig as root.

It is a nightmere just to get sagemath to use the correct version of CAS I want. I now have no idea what version of external CAS I am using when running sagemath any more. I also installed newer maxima in /usr/local/bin and now I am not sure that sagemath is using that one or is using its own older version of maxima.

There should be an easy and clear way to do these things.

Update 2

I found how to tell sagemath NOT to build giac. But after all of this, it is still not using the system giac.

To be able to tell sagemath to use the currently system installed giac and to also tell sagemath NOT to build the giac that comes with it since that version is old, this is what I did.

After extracting the sagemath 9.6 tar file, then

    cd sage-9.6
    unset SAGE_ROOT
    unset SAGE_LOCAL
    export GIAC=/usr/local/bin/giac    #this is critical. 
    ./configure --with-system-giac=force

And now it says

  giac-1.6.0.47p3.p0: using system package; SPKG will not be installed

Finally!

The main trick was to set $GIAC environment variable before running ./configure. I found this out by looking the configure script code. It uses this environment variable to locate the system giac.

This was not documented anywhere.

But after make is completed, I started sage and found it is still using some build in giac library! I have no idea where that is hiding.

>sage
┌────────────────────────────────────────────────────────────────────┐
│ SageMath version 9.6, Release Date: 2022-05-15                     │
│ Using Python 3.10.4. Type "help()" for help.                       │
└────────────────────────────────────────────────────────────────────┘
sage: var('x b')
(x, b)
sage: integrate(x^(3/2)*(b*x+2)^(1/2),x,algorithm="giac")
.....
NotImplementedError: Unable to parse Giac output: Warning, choosing root of

Same error as before.

sage: ver = installed_packages()
sage:  ver['giac']
---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
<ipython-input-4-1a56169f01e6> in <module>
----> 1 ver['giac']

KeyError: 'giac'
sage: print(giac.version())
"giac 1.9.0, (c) B. Parisse and R. De Graeve, Institut Fourier, Universite de Grenoble I"
sage:

You can see, that giac is not installed by sage. I looked at make output, and it did NOT build giac. But the above error message indicates it is using an OLD giac version. Where is it loading that from?

>cd /usr/local/lib
>ls -lrt *giac*
-rwxr-xr-x 1 root root 174377296 May 16 17:01 libgiac.so.0.0.0
lrwxrwxrwx 1 root root        16 May 16 17:01 libgiac.so.0 -> libgiac.so.0.0.0
lrwxrwxrwx 1 root root        16 May 16 17:01 libgiac.so -> libgiac.so.0.0.0
-rwxr-xr-x 1 root root      1154 May 16 17:01 libgiac.la
-rw-r--r-- 1 root root 398468174 May 16 17:01 libgiac.a

 echo $LD_LIBRARY_PATH
  :/usr/local/lib

>cat /etc/ld.so.conf
/usr/local/lib
include /etc/ld.so.conf.d/*.conf

Any one has any idea where is sagemath finding/using old giac library code from??

I found the following

>dpkg -l | grep libgiac
ii  libgiac-dev                               1.7.0.39+dfsg2-1build2                  amd64        Computer Algebra System C++ library - Development files
ii  libgiac0:amd64                            1.7.0.39+dfsg2-1build2                  amd64        Computer Algebra System C++ library

These are OLD giac 1.7 libraries! I have no idea why they show up and who installed them. I know I only build giac 1.9 from source.

I think that is the problem. I just need to figure why they say version 1.7, when my giac binary is 1.9.

I removed the above two ubuntu packages. But still sagemath is using 1.7 giac library from somewhere:

  sudo apt remove libgiac-dev
  sudo apt remove libgiac0:amd64
  >dpkg -l | grep giac
  >

They are gone. But now I open sage and run the same command as above, and it is STILL giving me the same exact error which is generated from 1.7 giac code.

So there is still somewhere older giac 1.7 library being used by sagemath. I just have no idea how this is possible. Will keep looking.

still getting Malform expression using giac in 9.6

I am using sagemath 9.6 with latest giac 1.9.0-7

I am not using giac that comes with sagemath 9.6 since that is old. So I points it to use the latest giac outside of sagemath.

Here is an example of such problem

>sage
┌────────────────────────────────────────────────────────────────────┐
│ SageMath version 9.6, Release Date: 2022-05-15                     │
│ Using Python 3.10.4. Type "help()" for help.                       │
└────────────────────────────────────────────────────────────────────┘
sage: var('x,b')
(x, b)

sage: integrate(x^(3/2)*(b*x+2)^(1/2),x,algorithm="giac")
---------------------------------------------------------------------------
SyntaxError                               Traceback (most recent call last)
~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/interfaces/giac.py in _sage_(self, locals)
   1138             try:
-> 1139                 return symbolic_expression_from_string(result, lsymbols,
   1140                     accept_sequence=True, parser=SR_parser_giac)

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/calculus/calculus.py in symbolic_expression_from_string(s, syms, accept_sequence, parser)
   2568                                               if _is_function(v)})
-> 2569     return parse_func(s)
   2570

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/misc/parser.pyx in sage.misc.parser.Parser.parse_sequence (build/cythonized/sage/misc/parser.c:6025)()
    574
--> 575     cpdef parse_sequence(self, s):
    576         """

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/misc/parser.pyx in sage.misc.parser.Parser.parse_sequence (build/cythonized/sage/misc/parser.c:5912)()
    592         if tokens.next() != EOS:
--> 593             self.parse_error(tokens)
    594         if len(all) == 1 and isinstance(all, list):

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/misc/parser.pyx in sage.misc.parser.Parser.parse_error (build/cythonized/sage/misc/parser.c:10396)()
   1043     cdef parse_error(self, Tokenizer tokens, msg="Malformed expression"):
-> 1044         raise SyntaxError(msg, tokens.s, tokens.pos)
   1045

SyntaxError: Malformed expression

During handling of the above exception, another exception occurred:

NotImplementedError                       Traceback (most recent call last)
<ipython-input-6-2f599f779b32> in <module>
----> 1 integrate(x**(Integer(3)/Integer(2))*(b*x+Integer(2))**(Integer(1)/Integer(2)),x,algorithm="giac")

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/misc/functional.py in integral(x, *args, **kwds)
    762     """
    763     if hasattr(x, 'integral'):
--> 764         return x.integral(*args, **kwds)
    765     else:
    766         from sage.symbolic.ring import SR

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/symbolic/expression.pyx in sage.symbolic.expression.Expression.integral (build/cythonized/sage/symbolic/expression.cpp:95445)()
  13192                     R = SR
  13193             return R(integral(f, v, a, b, **kwds))
> 13194         return integral(self, *args, **kwds)
  13195
  13196     integrate = integral

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/symbolic/integration/integral.py in integrate(expression, v, a, b, algorithm, hold)
   1045         if not integrator:
   1046             raise ValueError("Unknown algorithm: %s" % algorithm)
-> 1047         return integrator(expression, v, a, b)
   1048     if a is None:
   1049         return indefinite_integral(expression, v, hold=hold)

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/symbolic/integration/external.py in giac_integrator(expression, v, a, b)
    256         return expression.integrate(v, a, b, hold=True)
    257     else:
--> 258         return result._sage_()
    259
    260 def libgiac_integrator(expression, v, a=None, b=None):

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/interfaces/giac.py in _sage_(self, locals)
   1141
   1142             except Exception:
-> 1143                 raise NotImplementedError("Unable to parse Giac output: %s" % result)
   1144         else:
   1145             return [entry.sage() for entry in self]

NotImplementedError: Unable to parse Giac output: Warning, choosing root of [1,0,%%%{-4,[1,1]%%%}+%%%{-4,[1,0]%%%}+%%%{-4,[0,1]%%%}+%%%{-8,[0,0]%%%},0,%%%{6,[2,2]%%%}+%%%{4,[2,1]%%%}+%%%{6,[2,0]%%%}+%%%{4,[1,2]%%%}+%%%{28,[1,1]%%%}+%%%{8,[1,0]%%%}+%%%{6,[0,2]%%%}+%%%{8,[0,1]%%%}+%%%{24,[0,0]%%%},0,%%%{-4,[3,3]%%%}+%%%{4,[3,2]%%%}+%%%{4,[3,1]%%%}+%%%{-4,[3,0]%%%}+%%%{4,[2,3]%%%}+%%%{-64,[2,2]%%%}+%%%{20,[2,1]%%%}+%%%{8,[2,0]%%%}+%%%{4,[1,3]%%%}+%%%{20,[1,2]%%%}+%%%{-128,[1,1]%%%}+%%%{16,[1,0]%%%}+%%%{-4,[0,3]%%%}+%%%{8,[0,2]%%%}+%%%{16,[0,1]%%%}+%%%{-32,[0,0]%%%},0,%%%{1,[4,4]%%%}+%%%{-4,[4,3]%%%}+%%%{6,[4,2]%%%}+%%%{-4,[4,1]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+%%%{24,[0,2]%%%}+%%%{-32,[0,1]%%%}+%%%{16,[0,0]%%%}] at parameters values [18.4052062202,51.6443148847]

1/sageVARb*(2*sageVARb*abs(sageVARb)/sageVARb^2*(2*((12*sageVARb^5/144/sageVARb^7*sqrt(sageVARb*sageVARx+2)*sqrt(sageVARb*sageVARx+2)-78*sageVARb^5/144/sageVARb^7)*sqrt(sageVARb*sageVARx+2)*sqrt(sageVARb*sageVARx+2)+198*sageVARb^5/144/sageVARb^7)*sqrt(sageVARb*sageVARx+2)*sqrt(sageVARb*(sageVARb*sageVARx+2)-2*sageVARb)+5/2/sageVARb/sqrt(sageVARb)*ln(abs(sqrt(sageVARb*(sageVARb*sageVARx+2)-2*sageVARb)-sqrt(sageVARb)*sqrt(sageVARb*sageVARx+2))))+4*abs(sageVARb)/sageVARb^2/sageVARb*(2*(1/8*sqrt(sageVARb*sageVARx+2)*sqrt(sageVARb*sageVARx+2)-5/8)*sqrt(sageVARb*sageVARx+2)*sqrt(sageVARb*(sageVARb*sageVARx+2)-2*sageVARb)-6*sageVARb/4/sqrt(sageVARb)*ln(abs(sqrt(sageVARb*(sageVARb*sageVARx+2)-2*sageVARb)-sqrt(sageVARb)*sqrt(sageVARb*sageVARx+2)))))
sage:

But when using giac directly, it works with no errors

>giac
// Using locale /usr/local/share/locale/
// C.UTF-8
// /usr/local/share/locale/
// giac
// UTF-8
// Maximum number of parallel threads 24
Added 0 synonyms
Welcome to giac readline interface, version 1.9.0
(c) 2001,2021 B. Parisse & others
Homepage http://www-fourier.ujf-grenoble.fr/~parisse/giac.html
Released under the GPL license 3.0 or above
See http://www.gnu.org for license details
May contain BSD licensed software parts (lapack, atlas, tinymt)
-------------------------------------------------
Press CTRL and D simultaneously to finish session
Type ?commandname for help
0>> integrate( x^(3/2)*(b*x+2)^(1/2),x)
2*(2*((12*b^4*1/144/b^4*sqrt(x)*sqrt(x)+6*b^3*1/144/b^4)*sqrt(x)*sqrt(x)-18*b^2*1/144/b^4)*sqrt(x)*sqrt(b*x+2)-1/2/b^2/sqrt(b)*ln(sqrt(b*x+2)-sqrt(b)*sqrt(x)))
// Time 0.01
1>>

Here are more information

>which sage
/home/me/DATA/sage-9.6/sage
>sage --version
SageMath version 9.6, Release Date: 2022-05-15
>which giac
/usr/local/bin/giac
>giac --version
// Using locale /usr/local/share/locale/
// C.UTF-8
// /usr/local/share/locale/
// giac
// UTF-8
// Maximum number of parallel threads 24
// (c) 2001, 2021 B. Parisse & others
1.9.0

>cat /etc/*-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=22.04
DISTRIB_CODENAME=jammy
DISTRIB_DESCRIPTION="Ubuntu 22.04 LTS"
PRETTY_NAME="Ubuntu 22.04 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04 LTS (Jammy Jellyfish)"
VERSION_CODENAME=jammy


>$SAGE_ROOT/sage --version
 SageMath version 9.6, Release Date: 2022-05-15

>cd $SAGE_ROOT/local/bin

>ls -l giac
lrwxrwxrwx 1 me me 19 May 16 17:02 giac -> /usr/local/bin/giac
>

I see many integrals that fail the same way using giac. I was hoping this will be fixed in sage 9.6

Where is choosing root of message coming from? Because when calling giac directly, I see no such message displayed. This looks like a message that giac would have generated.

Is sagemath reading additional output from giac somehow that do not show up on the terminal when using giac directly? As you can see from above, giac printed no such message. (unless it is hidden somehow?)

Any idea what is going on?

Update

It appears that sagemath is using old giac version it build. it must be a library of giac, since I deleted the binary in $SAGE_ROOT/local/bin

My question now is: How to tell sagemath NOT to build giac itself? I tried

  ./configure --with-system-python=no --with-system-giac=yes

And also

 ./configure --with-system-python=no --with-system-giac=no

And in both cases (each time starting from a fresh sagemath installation) I see it is still building old giac [giac-1.6.0.47p3.p0] by looking at the output of make. I want sagemath to use newer giac version 1.9 in /usr/local/bin.

Could someone please give simple and clear instruction what should one to do to tell sagemath to use the system giac located in /usr/local/bin and NOT build the old giac version that comes with sagemath tar file?

I made sure LD_LIBRARY_PATH has /usr/local/lib as first entry. I also have /usr/local/lib as first line in /etc/ld.so.conf and also did ldconfig as root.

It is a nightmere just to get sagemath to use the correct version of CAS I want. I now have no idea what version of external CAS I am using when running sagemath any more. I also installed newer maxima in /usr/local/bin and now I am not sure that sagemath is using that one or is using its own older version of maxima.

There should be an easy and clear way to do these things.

Update 2

I found how to tell sagemath NOT to build giac. But after all of this, it is still not using the system giac.

To be able to tell sagemath to use the currently system installed giac and to also tell sagemath NOT to build the giac that comes with it since that version is old, this is what I did.

After extracting the sagemath 9.6 tar file, then

    cd sage-9.6
    unset SAGE_ROOT
    unset SAGE_LOCAL
    export GIAC=/usr/local/bin/giac    #this is critical. 
    ./configure --with-system-giac=force

And now it says

  giac-1.6.0.47p3.p0: using system package; SPKG will not be installed

Finally!

The main trick was to set $GIAC environment variable before running ./configure. I found this out by looking the configure script code. It uses this environment variable to locate the system giac.

This was not documented anywhere.

But after make is completed, I started sage and found it is still using some build in giac library! I have no idea where that is hiding.

>sage
┌────────────────────────────────────────────────────────────────────┐
│ SageMath version 9.6, Release Date: 2022-05-15                     │
│ Using Python 3.10.4. Type "help()" for help.                       │
└────────────────────────────────────────────────────────────────────┘
sage: var('x b')
(x, b)
sage: integrate(x^(3/2)*(b*x+2)^(1/2),x,algorithm="giac")
.....
NotImplementedError: Unable to parse Giac output: Warning, choosing root of

Same error as before.

sage: ver = installed_packages()
sage:  ver['giac']
---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
<ipython-input-4-1a56169f01e6> in <module>
----> 1 ver['giac']

KeyError: 'giac'
sage: print(giac.version())
"giac 1.9.0, (c) B. Parisse and R. De Graeve, Institut Fourier, Universite de Grenoble I"
sage:

You can see, that giac is not installed by sage. I looked at make output, and it did NOT build giac. But the above error message indicates it is using an OLD giac version. Where is it loading that from?

>cd /usr/local/lib
>ls -lrt *giac*
-rwxr-xr-x 1 root root 174377296 May 16 17:01 libgiac.so.0.0.0
lrwxrwxrwx 1 root root        16 May 16 17:01 libgiac.so.0 -> libgiac.so.0.0.0
lrwxrwxrwx 1 root root        16 May 16 17:01 libgiac.so -> libgiac.so.0.0.0
-rwxr-xr-x 1 root root      1154 May 16 17:01 libgiac.la
-rw-r--r-- 1 root root 398468174 May 16 17:01 libgiac.a

 echo $LD_LIBRARY_PATH
  :/usr/local/lib

>cat /etc/ld.so.conf
/usr/local/lib
include /etc/ld.so.conf.d/*.conf

Any one has any idea where is sagemath finding/using old giac library code from??

I found the following

>dpkg -l | grep libgiac
ii  libgiac-dev                               1.7.0.39+dfsg2-1build2                  amd64        Computer Algebra System C++ library - Development files
ii  libgiac0:amd64                            1.7.0.39+dfsg2-1build2                  amd64        Computer Algebra System C++ library

These are OLD giac 1.7 libraries! I have no idea why they show up and who installed them. I know I only build giac 1.9 from source.

I think that is the problem. I just need to figure why they say version 1.7, when my giac binary is 1.9.

I removed the above two ubuntu packages. But still sagemath is using 1.7 giac library from somewhere:

  sudo apt remove libgiac-dev
  sudo apt remove libgiac0:amd64
  >dpkg -l | grep giac
  >

They are gone. But now I open sage and run the same command as above, and it is STILL giving me the same exact error which is generated from 1.7 giac code.

So there is still somewhere older giac 1.7 library being used by sagemath. I just have no idea how this is possible. Will keep looking.

I did

>sudo updatedb
>locate libgiac
/usr/local/lib/libgiac.a
/usr/local/lib/libgiac.la
/usr/local/lib/libgiac.so
/usr/local/lib/libgiac.so.0
/usr/local/lib/libgiac.so.0.0.0
>

But it is only libgiac in LD_LIBRARY_PATH that will be used if any. So even if there was an old giac library on my disk, if it is not in LD_LIBRARY_PATH then it will not affect anything.

Unless giac 1.9 is shipping with older libgiac itself? But how come when I use the same command in giac itself, I do not get this error?

still getting Malform expression using giac in 9.6

I am using sagemath 9.6 with latest giac 1.9.0-7

I am not using giac that comes with sagemath 9.6 since that is old. So I points it to use the latest giac outside of sagemath.

Here is an example of such problem

>sage
┌────────────────────────────────────────────────────────────────────┐
│ SageMath version 9.6, Release Date: 2022-05-15                     │
│ Using Python 3.10.4. Type "help()" for help.                       │
└────────────────────────────────────────────────────────────────────┘
sage: var('x,b')
(x, b)

sage: integrate(x^(3/2)*(b*x+2)^(1/2),x,algorithm="giac")
---------------------------------------------------------------------------
SyntaxError                               Traceback (most recent call last)
~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/interfaces/giac.py in _sage_(self, locals)
   1138             try:
-> 1139                 return symbolic_expression_from_string(result, lsymbols,
   1140                     accept_sequence=True, parser=SR_parser_giac)

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/calculus/calculus.py in symbolic_expression_from_string(s, syms, accept_sequence, parser)
   2568                                               if _is_function(v)})
-> 2569     return parse_func(s)
   2570

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/misc/parser.pyx in sage.misc.parser.Parser.parse_sequence (build/cythonized/sage/misc/parser.c:6025)()
    574
--> 575     cpdef parse_sequence(self, s):
    576         """

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/misc/parser.pyx in sage.misc.parser.Parser.parse_sequence (build/cythonized/sage/misc/parser.c:5912)()
    592         if tokens.next() != EOS:
--> 593             self.parse_error(tokens)
    594         if len(all) == 1 and isinstance(all, list):

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/misc/parser.pyx in sage.misc.parser.Parser.parse_error (build/cythonized/sage/misc/parser.c:10396)()
   1043     cdef parse_error(self, Tokenizer tokens, msg="Malformed expression"):
-> 1044         raise SyntaxError(msg, tokens.s, tokens.pos)
   1045

SyntaxError: Malformed expression

During handling of the above exception, another exception occurred:

NotImplementedError                       Traceback (most recent call last)
<ipython-input-6-2f599f779b32> in <module>
----> 1 integrate(x**(Integer(3)/Integer(2))*(b*x+Integer(2))**(Integer(1)/Integer(2)),x,algorithm="giac")

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/misc/functional.py in integral(x, *args, **kwds)
    762     """
    763     if hasattr(x, 'integral'):
--> 764         return x.integral(*args, **kwds)
    765     else:
    766         from sage.symbolic.ring import SR

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/symbolic/expression.pyx in sage.symbolic.expression.Expression.integral (build/cythonized/sage/symbolic/expression.cpp:95445)()
  13192                     R = SR
  13193             return R(integral(f, v, a, b, **kwds))
> 13194         return integral(self, *args, **kwds)
  13195
  13196     integrate = integral

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/symbolic/integration/integral.py in integrate(expression, v, a, b, algorithm, hold)
   1045         if not integrator:
   1046             raise ValueError("Unknown algorithm: %s" % algorithm)
-> 1047         return integrator(expression, v, a, b)
   1048     if a is None:
   1049         return indefinite_integral(expression, v, hold=hold)

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/symbolic/integration/external.py in giac_integrator(expression, v, a, b)
    256         return expression.integrate(v, a, b, hold=True)
    257     else:
--> 258         return result._sage_()
    259
    260 def libgiac_integrator(expression, v, a=None, b=None):

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/interfaces/giac.py in _sage_(self, locals)
   1141
   1142             except Exception:
-> 1143                 raise NotImplementedError("Unable to parse Giac output: %s" % result)
   1144         else:
   1145             return [entry.sage() for entry in self]

NotImplementedError: Unable to parse Giac output: Warning, choosing root of [1,0,%%%{-4,[1,1]%%%}+%%%{-4,[1,0]%%%}+%%%{-4,[0,1]%%%}+%%%{-8,[0,0]%%%},0,%%%{6,[2,2]%%%}+%%%{4,[2,1]%%%}+%%%{6,[2,0]%%%}+%%%{4,[1,2]%%%}+%%%{28,[1,1]%%%}+%%%{8,[1,0]%%%}+%%%{6,[0,2]%%%}+%%%{8,[0,1]%%%}+%%%{24,[0,0]%%%},0,%%%{-4,[3,3]%%%}+%%%{4,[3,2]%%%}+%%%{4,[3,1]%%%}+%%%{-4,[3,0]%%%}+%%%{4,[2,3]%%%}+%%%{-64,[2,2]%%%}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20,[3,1]%%%}+%%%{-8,[3,0]%%%}+%%%{6,[2,4]%%%}+%%%{-20,[2,3]%%%}+%%%{46,[2,2]%%%}+%%%{-40,[2,1]%%%}+%%%{24,[2,0]%%%}+%%%{-4,[1,4]%%%}+%%%{20,[1,3]%%%}+%%%{-40,[1,2]%%%}+%%%{48,[1,1]%%%}+%%%{-32,[1,0]%%%}+%%%{1,[0,4]%%%}+%%%{-8,[0,3]%%%}+%%%{24,[0,2]%%%}+%%%{-32,[0,1]%%%}+%%%{16,[0,0]%%%}] at parameters values [18.4052062202,51.6443148847]

1/sageVARb*(2*sageVARb*abs(sageVARb)/sageVARb^2*(2*((12*sageVARb^5/144/sageVARb^7*sqrt(sageVARb*sageVARx+2)*sqrt(sageVARb*sageVARx+2)-78*sageVARb^5/144/sageVARb^7)*sqrt(sageVARb*sageVARx+2)*sqrt(sageVARb*sageVARx+2)+198*sageVARb^5/144/sageVARb^7)*sqrt(sageVARb*sageVARx+2)*sqrt(sageVARb*(sageVARb*sageVARx+2)-2*sageVARb)+5/2/sageVARb/sqrt(sageVARb)*ln(abs(sqrt(sageVARb*(sageVARb*sageVARx+2)-2*sageVARb)-sqrt(sageVARb)*sqrt(sageVARb*sageVARx+2))))+4*abs(sageVARb)/sageVARb^2/sageVARb*(2*(1/8*sqrt(sageVARb*sageVARx+2)*sqrt(sageVARb*sageVARx+2)-5/8)*sqrt(sageVARb*sageVARx+2)*sqrt(sageVARb*(sageVARb*sageVARx+2)-2*sageVARb)-6*sageVARb/4/sqrt(sageVARb)*ln(abs(sqrt(sageVARb*(sageVARb*sageVARx+2)-2*sageVARb)-sqrt(sageVARb)*sqrt(sageVARb*sageVARx+2)))))
sage:

But when using giac directly, it works with no errors

>giac
// Using locale /usr/local/share/locale/
// C.UTF-8
// /usr/local/share/locale/
// giac
// UTF-8
// Maximum number of parallel threads 24
Added 0 synonyms
Welcome to giac readline interface, version 1.9.0
(c) 2001,2021 B. Parisse & others
Homepage http://www-fourier.ujf-grenoble.fr/~parisse/giac.html
Released under the GPL license 3.0 or above
See http://www.gnu.org for license details
May contain BSD licensed software parts (lapack, atlas, tinymt)
-------------------------------------------------
Press CTRL and D simultaneously to finish session
Type ?commandname for help
0>> integrate( x^(3/2)*(b*x+2)^(1/2),x)
2*(2*((12*b^4*1/144/b^4*sqrt(x)*sqrt(x)+6*b^3*1/144/b^4)*sqrt(x)*sqrt(x)-18*b^2*1/144/b^4)*sqrt(x)*sqrt(b*x+2)-1/2/b^2/sqrt(b)*ln(sqrt(b*x+2)-sqrt(b)*sqrt(x)))
// Time 0.01
1>>

Here are more information

>which sage
/home/me/DATA/sage-9.6/sage
>sage --version
SageMath version 9.6, Release Date: 2022-05-15
>which giac
/usr/local/bin/giac
>giac --version
// Using locale /usr/local/share/locale/
// C.UTF-8
// /usr/local/share/locale/
// giac
// UTF-8
// Maximum number of parallel threads 24
// (c) 2001, 2021 B. Parisse & others
1.9.0

>cat /etc/*-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=22.04
DISTRIB_CODENAME=jammy
DISTRIB_DESCRIPTION="Ubuntu 22.04 LTS"
PRETTY_NAME="Ubuntu 22.04 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04 LTS (Jammy Jellyfish)"
VERSION_CODENAME=jammy


>$SAGE_ROOT/sage --version
 SageMath version 9.6, Release Date: 2022-05-15

>cd $SAGE_ROOT/local/bin

>ls -l giac
lrwxrwxrwx 1 me me 19 May 16 17:02 giac -> /usr/local/bin/giac
>

I see many integrals that fail the same way using giac. I was hoping this will be fixed in sage 9.6

Where is choosing root of message coming from? Because when calling giac directly, I see no such message displayed. This looks like a message that giac would have generated.

Is sagemath reading additional output from giac somehow that do not show up on the terminal when using giac directly? As you can see from above, giac printed no such message. (unless it is hidden somehow?)

Any idea what is going on?

Update

It appears that sagemath is using old giac version it build. it must be a library of giac, since I deleted the binary in $SAGE_ROOT/local/bin

My question now is: How to tell sagemath NOT to build giac itself? I tried

  ./configure --with-system-python=no --with-system-giac=yes

And also

 ./configure --with-system-python=no --with-system-giac=no

And in both cases (each time starting from a fresh sagemath installation) I see it is still building old giac [giac-1.6.0.47p3.p0] by looking at the output of make. I want sagemath to use newer giac version 1.9 in /usr/local/bin.

Could someone please give simple and clear instruction what should one to do to tell sagemath to use the system giac located in /usr/local/bin and NOT build the old giac version that comes with sagemath tar file?

I made sure LD_LIBRARY_PATH has /usr/local/lib as first entry. I also have /usr/local/lib as first line in /etc/ld.so.conf and also did ldconfig as root.

It is a nightmere just to get sagemath to use the correct version of CAS I want. I now have no idea what version of external CAS I am using when running sagemath any more. I also installed newer maxima in /usr/local/bin and now I am not sure that sagemath is using that one or is using its own older version of maxima.

There should be an easy and clear way to do these things.

Update 2

I found how to tell sagemath NOT to build giac. But after all of this, it is still not using the system giac.

To be able to tell sagemath to use the currently system installed giac and to also tell sagemath NOT to build the giac that comes with it since that version is old, this is what I did.

After extracting the sagemath 9.6 tar file, then

    cd sage-9.6
    unset SAGE_ROOT
    unset SAGE_LOCAL
    export GIAC=/usr/local/bin/giac    #this is critical. 
    ./configure --with-system-giac=force

And now it says

  giac-1.6.0.47p3.p0: using system package; SPKG will not be installed

Finally!

The main trick was to set $GIAC environment variable before running ./configure. I found this out by looking the configure script code. It uses this environment variable to locate the system giac.

This was not documented anywhere.

But after make is completed, I started sage and found it is still using some build in giac library! I have no idea where that is hiding.

>sage
┌────────────────────────────────────────────────────────────────────┐
│ SageMath version 9.6, Release Date: 2022-05-15                     │
│ Using Python 3.10.4. Type "help()" for help.                       │
└────────────────────────────────────────────────────────────────────┘
sage: var('x b')
(x, b)
sage: integrate(x^(3/2)*(b*x+2)^(1/2),x,algorithm="giac")
.....
NotImplementedError: Unable to parse Giac output: Warning, choosing root of

Same error as before.

sage: ver = installed_packages()
sage:  ver['giac']
---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
<ipython-input-4-1a56169f01e6> in <module>
----> 1 ver['giac']

KeyError: 'giac'
sage: print(giac.version())
"giac 1.9.0, (c) B. Parisse and R. De Graeve, Institut Fourier, Universite de Grenoble I"
sage:

You can see, that giac is not installed by sage. I looked at make output, and it did NOT build giac. But the above error message indicates it is using an OLD giac version. Where is it loading that from?

>cd /usr/local/lib
>ls -lrt *giac*
-rwxr-xr-x 1 root root 174377296 May 16 17:01 libgiac.so.0.0.0
lrwxrwxrwx 1 root root        16 May 16 17:01 libgiac.so.0 -> libgiac.so.0.0.0
lrwxrwxrwx 1 root root        16 May 16 17:01 libgiac.so -> libgiac.so.0.0.0
-rwxr-xr-x 1 root root      1154 May 16 17:01 libgiac.la
-rw-r--r-- 1 root root 398468174 May 16 17:01 libgiac.a

 echo $LD_LIBRARY_PATH
  :/usr/local/lib

>cat /etc/ld.so.conf
/usr/local/lib
include /etc/ld.so.conf.d/*.conf

Any one has any idea where is sagemath finding/using old giac library code from??

I found the following

>dpkg -l | grep libgiac
ii  libgiac-dev                               1.7.0.39+dfsg2-1build2                  amd64        Computer Algebra System C++ library - Development files
ii  libgiac0:amd64                            1.7.0.39+dfsg2-1build2                  amd64        Computer Algebra System C++ library

These are OLD giac 1.7 libraries! I have no idea why they show up and who installed them. I know I only build giac 1.9 from source.

I think that is the problem. I just need to figure why they say version 1.7, when my giac binary is 1.9.

I removed the above two ubuntu packages. But still sagemath is using 1.7 giac library from somewhere:

  sudo apt remove libgiac-dev
  sudo apt remove libgiac0:amd64
  >dpkg -l | grep giac
  >

They are gone. But now I open sage and run the same command as above, and it is STILL giving me the same exact error which is generated from 1.7 giac code.

So there is still somewhere older giac 1.7 library being used by sagemath. I just have no idea how this is possible. Will keep looking.

I did

>sudo updatedb
>locate libgiac
/usr/local/lib/libgiac.a
/usr/local/lib/libgiac.la
/usr/local/lib/libgiac.so
/usr/local/lib/libgiac.so.0
/usr/local/lib/libgiac.so.0.0.0
>

But it is only libgiac in LD_LIBRARY_PATH that will be used if any. So even if there was an old giac library on my disk, if it is not in LD_LIBRARY_PATH then it will not affect anything.

Unless giac 1.9 is shipping with older libgiac itself? Update

I found additional information. After building sagemath to use external giac, then I noticed this when issuing the integrate command, using ps -eaf

me       23771 23695 99 02:14 pts/8    00:00:15 /usr/local/bin/giac --sage

Then after about 1-2 seconds, I see

me       23771 23695 99 02:14 pts/8    00:00:15 /usr/local/bin/giac --sage
me       23772 23695  0 02:14 pts/6    00:00:00 [sage-python] <defunct>

So I think what happens is that sagemath does call system giac at first, then something wrong happens, and that is why [sage-python] <defunct> shows up soon after that?

But how come when I I still do not know where sagemath is finding giac 1.7. Since the error message is one that giac 1.7 would have generated. But I asked sagemath NOT to build old giac and only use the same command in giac itself, I do not get this error?system giac which is 1.9.

I will just have to wait for sagemath 9.7 and try again.

still getting Malform expression using giac in 9.6

I am using sagemath 9.6 with latest How to use giac 1.9.0-7

I am not using giac that comes 1.9 with sagemath 9.6 since that is old. So I points it to use the latest giac outside of sagemath.

Here is an example of such problem

>sage
┌────────────────────────────────────────────────────────────────────┐
│ SageMath version 9.6, Release Date: 2022-05-15                     │
│ Using Python 3.10.4. Type "help()" for help.                       │
└────────────────────────────────────────────────────────────────────┘
sage: var('x,b')
(x, b)

sage: integrate(x^(3/2)*(b*x+2)^(1/2),x,algorithm="giac")
---------------------------------------------------------------------------
SyntaxError                               Traceback (most recent call last)
~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/interfaces/giac.py in _sage_(self, locals)
   1138             try:
-> 1139                 return symbolic_expression_from_string(result, lsymbols,
   1140                     accept_sequence=True, parser=SR_parser_giac)

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/calculus/calculus.py in symbolic_expression_from_string(s, syms, accept_sequence, parser)
   2568                                               if _is_function(v)})
-> 2569     return parse_func(s)
   2570

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/misc/parser.pyx in sage.misc.parser.Parser.parse_sequence (build/cythonized/sage/misc/parser.c:6025)()
    574
--> 575     cpdef parse_sequence(self, s):
    576         """

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/misc/parser.pyx in sage.misc.parser.Parser.parse_sequence (build/cythonized/sage/misc/parser.c:5912)()
    592         if tokens.next() != EOS:
--> 593             self.parse_error(tokens)
    594         if len(all) == 1 and isinstance(all, list):

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/misc/parser.pyx in sage.misc.parser.Parser.parse_error (build/cythonized/sage/misc/parser.c:10396)()
   1043     cdef parse_error(self, Tokenizer tokens, msg="Malformed expression"):
-> 1044         raise SyntaxError(msg, tokens.s, tokens.pos)
   1045

SyntaxError: Malformed expression

During handling of the above exception, another exception occurred:

NotImplementedError                       Traceback (most recent call last)
<ipython-input-6-2f599f779b32> in <module>
----> 1 integrate(x**(Integer(3)/Integer(2))*(b*x+Integer(2))**(Integer(1)/Integer(2)),x,algorithm="giac")

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/misc/functional.py in integral(x, *args, **kwds)
    762     """
    763     if hasattr(x, 'integral'):
--> 764         return x.integral(*args, **kwds)
    765     else:
    766         from sage.symbolic.ring import SR

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/symbolic/expression.pyx in sage.symbolic.expression.Expression.integral (build/cythonized/sage/symbolic/expression.cpp:95445)()
  13192                     R = SR
  13193             return R(integral(f, v, a, b, **kwds))
> 13194         return integral(self, *args, **kwds)
  13195
  13196     integrate = integral

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/symbolic/integration/integral.py in integrate(expression, v, a, b, algorithm, hold)
   1045         if not integrator:
   1046             raise ValueError("Unknown algorithm: %s" % algorithm)
-> 1047         return integrator(expression, v, a, b)
   1048     if a is None:
   1049         return indefinite_integral(expression, v, hold=hold)

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/symbolic/integration/external.py in giac_integrator(expression, v, a, b)
    256         return expression.integrate(v, a, b, hold=True)
    257     else:
--> 258         return result._sage_()
    259
    260 def libgiac_integrator(expression, v, a=None, b=None):

~/DATA/sage-9.6/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/interfaces/giac.py in _sage_(self, locals)
   1141
   1142             except Exception:
-> 1143                 raise NotImplementedError("Unable to parse Giac output: %s" % result)
   1144         else:
   1145             return [entry.sage() for entry in self]

NotImplementedError: Unable to parse Giac output: Warning, choosing root of [1,0,%%%{-4,[1,1]%%%}+%%%{-4,[1,0]%%%}+%%%{-4,[0,1]%%%}+%%%{-8,[0,0]%%%},0,%%%{6,[2,2]%%%}+%%%{4,[2,1]%%%}+%%%{6,[2,0]%%%}+%%%{4,[1,2]%%%}+%%%{28,[1,1]%%%}+%%%{8,[1,0]%%%}+%%%{6,[0,2]%%%}+%%%{8,[0,1]%%%}+%%%{24,[0,0]%%%},0,%%%{-4,[3,3]%%%}+%%%{4,[3,2]%%%}+%%%{4,[3,1]%%%}+%%%{-4,[3,0]%%%}+%%%{4,[2,3]%%%}+%%%{-64,[2,2]%%%}+%%%{20,[2,1]%%%}+%%%{8,[2,0]%%%}+%%%{4,[1,3]%%%}+%%%{20,[1,2]%%%}+%%%{-128,[1,1]%%%}+%%%{16,[1,0]%%%}+%%%{-4,[0,3]%%%}+%%%{8,[0,2]%%%}+%%%{16,[0,1]%%%}+%%%{-32,[0,0]%%%},0,%%%{1,[4,4]%%%}+%%%{-4,[4,3]%%%}+%%%{6,[4,2]%%%}+%%%{-4,[4,1]%%%}+%%%{1,[4,0]%%%}+%%%{-4,[3,4]%%%}+%%%{12,[3,3]%%%}+%%%{-20,[3,2]%%%}+%%%{20,[3,1]%%%}+%%%{-8,[3,0]%%%}+%%%{6,[2,4]%%%}+%%%{-20,[2,3]%%%}+%%%{46,[2,2]%%%}+%%%{-40,[2,1]%%%}+%%%{24,[2,0]%%%}+%%%{-4,[1,4]%%%}+%%%{20,[1,3]%%%}+%%%{-40,[1,2]%%%}+%%%{48,[1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0]%%%}] at parameters values [33.9285577983,15.451549686]
Warning, choosing root of [1,0,%%%{-4,[1,1]%%%}+%%%{-4,[1,0]%%%}+%%%{-4,[0,1]%%%}+%%%{-8,[0,0]%%%},0,%%%{6,[2,2]%%%}+%%%{4,[2,1]%%%}+%%%{6,[2,0]%%%}+%%%{4,[1,2]%%%}+%%%{28,[1,1]%%%}+%%%{8,[1,0]%%%}+%%%{6,[0,2]%%%}+%%%{8,[0,1]%%%}+%%%{24,[0,0]%%%},0,%%%{-4,[3,3]%%%}+%%%{4,[3,2]%%%}+%%%{4,[3,1]%%%}+%%%{-4,[3,0]%%%}+%%%{4,[2,3]%%%}+%%%{-64,[2,2]%%%}+%%%{20,[2,1]%%%}+%%%{8,[2,0]%%%}+%%%{4,[1,3]%%%}+%%%{20,[1,2]%%%}+%%%{-128,[1,1]%%%}+%%%{16,[1,0]%%%}+%%%{-4,[0,3]%%%}+%%%{8,[0,2]%%%}+%%%{16,[0,1]%%%}+%%%{-32,[0,0]%%%},0,%%%{1,[4,4]%%%}+%%%{-4,[4,3]%%%}+%%%{6,[4,2]%%%}+%%%{-4,[4,1]%%%}+%%%{1,[4,0]%%%}+%%%{-4,[3,4]%%%}+%%%{12,[3,3]%%%}+%%%{-20,[3,2]%%%}+%%%{20,[3,1]%%%}+%%%{-8,[3,0]%%%}+%%%{6,[2,4]%%%}+%%%{-20,[2,3]%%%}+%%%{46,[2,2]%%%}+%%%{-40,[2,1]%%%}+%%%{24,[2,0]%%%}+%%%{-4,[1,4]%%%}+%%%{20,[1,3]%%%}+%%%{-40,[1,2]%%%}+%%%{48,[1,1]%%%}+%%%{-32,[1,0]%%%}+%%%{1,[0,4]%%%}+%%%{-8,[0,3]%%%}+%%%{24,[0,2]%%%}+%%%{-32,[0,1]%%%}+%%%{16,[0,0]%%%}] at parameters values [54.7579903365,81.9516051291]
Warning, choosing root of [1,0,%%%{-4,[1,1]%%%}+%%%{-4,[1,0]%%%}+%%%{-4,[0,1]%%%}+%%%{-8,[0,0]%%%},0,%%%{6,[2,2]%%%}+%%%{4,[2,1]%%%}+%%%{6,[2,0]%%%}+%%%{4,[1,2]%%%}+%%%{28,[1,1]%%%}+%%%{8,[1,0]%%%}+%%%{6,[0,2]%%%}+%%%{8,[0,1]%%%}+%%%{24,[0,0]%%%},0,%%%{-4,[3,3]%%%}+%%%{4,[3,2]%%%}+%%%{4,[3,1]%%%}+%%%{-4,[3,0]%%%}+%%%{4,[2,3]%%%}+%%%{-64,[2,2]%%%}+%%%{20,[2,1]%%%}+%%%{8,[2,0]%%%}+%%%{4,[1,3]%%%}+%%%{20,[1,2]%%%}+%%%{-128,[1,1]%%%}+%%%{16,[1,0]%%%}+%%%{-4,[0,3]%%%}+%%%{8,[0,2]%%%}+%%%{16,[0,1]%%%}+%%%{-32,[0,0]%%%},0,%%%{1,[4,4]%%%}+%%%{-4,[4,3]%%%}+%%%{6,[4,2]%%%}+%%%{-4,[4,1]%%%}+%%%{1,[4,0]%%%}+%%%{-4,[3,4]%%%}+%%%{12,[3,3]%%%}+%%%{-20,[3,2]%%%}+%%%{20,[3,1]%%%}+%%%{-8,[3,0]%%%}+%%%{6,[2,4]%%%}+%%%{-20,[2,3]%%%}+%%%{46,[2,2]%%%}+%%%{-40,[2,1]%%%}+%%%{24,[2,0]%%%}+%%%{-4,[1,4]%%%}+%%%{20,[1,3]%%%}+%%%{-40,[1,2]%%%}+%%%{48,[1,1]%%%}+%%%{-32,[1,0]%%%}+%%%{1,[0,4]%%%}+%%%{-8,[0,3]%%%}+%%%{24,[0,2]%%%}+%%%{-32,[0,1]%%%}+%%%{16,[0,0]%%%}] at parameters values [18.4052062202,51.6443148847]

1/sageVARb*(2*sageVARb*abs(sageVARb)/sageVARb^2*(2*((12*sageVARb^5/144/sageVARb^7*sqrt(sageVARb*sageVARx+2)*sqrt(sageVARb*sageVARx+2)-78*sageVARb^5/144/sageVARb^7)*sqrt(sageVARb*sageVARx+2)*sqrt(sageVARb*sageVARx+2)+198*sageVARb^5/144/sageVARb^7)*sqrt(sageVARb*sageVARx+2)*sqrt(sageVARb*(sageVARb*sageVARx+2)-2*sageVARb)+5/2/sageVARb/sqrt(sageVARb)*ln(abs(sqrt(sageVARb*(sageVARb*sageVARx+2)-2*sageVARb)-sqrt(sageVARb)*sqrt(sageVARb*sageVARx+2))))+4*abs(sageVARb)/sageVARb^2/sageVARb*(2*(1/8*sqrt(sageVARb*sageVARx+2)*sqrt(sageVARb*sageVARx+2)-5/8)*sqrt(sageVARb*sageVARx+2)*sqrt(sageVARb*(sageVARb*sageVARx+2)-2*sageVARb)-6*sageVARb/4/sqrt(sageVARb)*ln(abs(sqrt(sageVARb*(sageVARb*sageVARx+2)-2*sageVARb)-sqrt(sageVARb)*sqrt(sageVARb*sageVARx+2)))))
sage:

But when using giac directly, it works with no errors

>giac
// Using locale /usr/local/share/locale/
// C.UTF-8
// /usr/local/share/locale/
// giac
// UTF-8
// Maximum number of parallel threads 24
Added 0 synonyms
Welcome to giac readline interface, version 1.9.0
(c) 2001,2021 B. Parisse & others
Homepage http://www-fourier.ujf-grenoble.fr/~parisse/giac.html
Released under the GPL license 3.0 or above
See http://www.gnu.org for license details
May contain BSD licensed software parts (lapack, atlas, tinymt)
-------------------------------------------------
Press CTRL and D simultaneously to finish session
Type ?commandname for help
0>> integrate( x^(3/2)*(b*x+2)^(1/2),x)
2*(2*((12*b^4*1/144/b^4*sqrt(x)*sqrt(x)+6*b^3*1/144/b^4)*sqrt(x)*sqrt(x)-18*b^2*1/144/b^4)*sqrt(x)*sqrt(b*x+2)-1/2/b^2/sqrt(b)*ln(sqrt(b*x+2)-sqrt(b)*sqrt(x)))
// Time 0.01
1>>

Here are more information

>which sage
/home/me/DATA/sage-9.6/sage
>sage --version
SageMath version 9.6, Release Date: 2022-05-15
>which giac
/usr/local/bin/giac
>giac --version
// Using locale /usr/local/share/locale/
// C.UTF-8
// /usr/local/share/locale/
// giac
// UTF-8
// Maximum number of parallel threads 24
// (c) 2001, 2021 B. Parisse & others
1.9.0

>cat /etc/*-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=22.04
DISTRIB_CODENAME=jammy
DISTRIB_DESCRIPTION="Ubuntu 22.04 LTS"
PRETTY_NAME="Ubuntu 22.04 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04 LTS (Jammy Jellyfish)"
VERSION_CODENAME=jammy


>$SAGE_ROOT/sage --version
 SageMath version 9.6, Release Date: 2022-05-15

>cd $SAGE_ROOT/local/bin

>ls -l giac
lrwxrwxrwx 1 me me 19 May 16 17:02 giac -> /usr/local/bin/giac
>

I see many integrals that fail the same way using giac. I was hoping this will be fixed in sage 9.6

Where is choosing root of message coming from? Because when calling giac directly, I see no such message displayed. This looks like a message that giac would have generated.

Is sagemath reading additional output from giac somehow that do not show up on the terminal when using giac directly? As you can see from above, giac printed no such message. (unless it is hidden somehow?)

Any idea what is going on?

Update

It appears that sagemath is using old giac version it build. it must be a library of giac, since I deleted the binary in $SAGE_ROOT/local/bin

My question now is: How to tell sagemath NOT to build giac itself? I tried

  ./configure --with-system-python=no --with-system-giac=yes

And also

 ./configure --with-system-python=no --with-system-giac=no

And in both cases (each time starting from a fresh sagemath installation) I see it is still building old giac [giac-1.6.0.47p3.p0] by looking at the output of make. I want sagemath to use newer giac version 1.9 in /usr/local/bin.

Could someone please give simple and clear instruction what should one to do to tell sagemath to use the system giac located in /usr/local/bin and NOT build the old giac version that comes with sagemath tar file?

I made sure LD_LIBRARY_PATH has /usr/local/lib as first entry. I also have /usr/local/lib as first line in /etc/ld.so.conf and also did ldconfig as root.

It is a nightmere just to get sagemath to use the correct version of CAS I want. I now have no idea what version of external CAS I am using when running sagemath any more. I also installed newer maxima in /usr/local/bin and now I am not sure that sagemath is using that one or is using its own older version of maxima.

There should be an easy and clear way to do these things.

Update 2

I found how to tell sagemath NOT to build giac. But after all of this, it is still not using the system giac.

To be able to tell sagemath to use the currently system installed giac and to also tell sagemath NOT to build the giac that comes with it since that version is old, this is what I did.

After extracting the sagemath 9.6 tar file, then

    cd sage-9.6
    unset SAGE_ROOT
    unset SAGE_LOCAL
    export GIAC=/usr/local/bin/giac    #this is critical. 
    ./configure --with-system-giac=force

And now it says

  giac-1.6.0.47p3.p0: using system package; SPKG will not be installed

Finally!

The main trick was to set $GIAC environment variable before running ./configure. I found this out by looking the configure script code. It uses this environment variable to locate the system giac.

This was not documented anywhere.

But after make is completed, I started sage and found it is still using some build in giac library! I have no idea where that is hiding.

>sage
┌────────────────────────────────────────────────────────────────────┐
│ SageMath version 9.6, Release Date: 2022-05-15                     │
│ Using Python 3.10.4. Type "help()" for help.                       │
└────────────────────────────────────────────────────────────────────┘
sage: var('x b')
(x, b)
sage: integrate(x^(3/2)*(b*x+2)^(1/2),x,algorithm="giac")
.....
NotImplementedError: Unable to parse Giac output: Warning, choosing root of

Same error as before.

sage: ver = installed_packages()
sage:  ver['giac']
---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
<ipython-input-4-1a56169f01e6> in <module>
----> 1 ver['giac']

KeyError: 'giac'
sage: print(giac.version())
"giac 1.9.0, (c) B. Parisse and R. De Graeve, Institut Fourier, Universite de Grenoble I"
sage:

You can see, that giac is not installed by sage. I looked at make output, and it did NOT build giac. But the above error message indicates it is using an OLD giac version. Where is it loading that from?

>cd /usr/local/lib
>ls -lrt *giac*
-rwxr-xr-x 1 root root 174377296 May 16 17:01 libgiac.so.0.0.0
lrwxrwxrwx 1 root root        16 May 16 17:01 libgiac.so.0 -> libgiac.so.0.0.0
lrwxrwxrwx 1 root root        16 May 16 17:01 libgiac.so -> libgiac.so.0.0.0
-rwxr-xr-x 1 root root      1154 May 16 17:01 libgiac.la
-rw-r--r-- 1 root root 398468174 May 16 17:01 libgiac.a

 echo $LD_LIBRARY_PATH
  :/usr/local/lib

>cat /etc/ld.so.conf
/usr/local/lib
include /etc/ld.so.conf.d/*.conf

Any one has any idea where is sagemath finding/using old giac library code from??

I found the following

>dpkg -l | grep libgiac
ii  libgiac-dev                               1.7.0.39+dfsg2-1build2                  amd64        Computer Algebra System C++ library - Development files
ii  libgiac0:amd64                            1.7.0.39+dfsg2-1build2                  amd64        Computer Algebra System C++ library

These are OLD giac 1.7 libraries! I have no idea why they show up and who installed them. I know I only build giac 1.9 from source.

I think that is the problem. I just need to figure why they say version 1.7, when my giac binary is 1.9.

I removed the above two ubuntu packages. But still sagemath is using 1.7 giac library from somewhere:

  sudo apt remove libgiac-dev
  sudo apt remove libgiac0:amd64
  >dpkg -l | grep giac
  >

They are gone. But now I open sage and run the same command as above, and it is STILL giving me the same exact error which is generated from 1.7 giac code.

So there is still somewhere older giac 1.7 library being used by sagemath. I just have no idea how this is possible. Will keep looking.

I did

>sudo updatedb
>locate libgiac
/usr/local/lib/libgiac.a
/usr/local/lib/libgiac.la
/usr/local/lib/libgiac.so
/usr/local/lib/libgiac.so.0
/usr/local/lib/libgiac.so.0.0.0
>

But it is only libgiac in LD_LIBRARY_PATH that will be used if any. So even if there was an old giac library on my disk, if it is not in LD_LIBRARY_PATH then it will not affect anything.

Update

I found additional information. After building sagemath to use external giac, then I noticed this when issuing the integrate command, using ps -eaf

me       23771 23695 99 02:14 pts/8    00:00:15 /usr/local/bin/giac --sage

Then after about 1-2 seconds, I see

me       23771 23695 99 02:14 pts/8    00:00:15 /usr/local/bin/giac --sage
me       23772 23695  0 02:14 pts/6    00:00:00 [sage-python] <defunct>

So I think what happens is that sagemath does call system giac at first, then something wrong happens, and that is why [sage-python] <defunct> shows up soon after that?

But I still do not know where sagemath is finding giac 1.7. Since the error message is one that giac 1.7 would have generated. But I asked sagemath NOT to build old giac and only use the system giac which is 1.9.

I will just have to wait for sagemath 9.7 and try again.9.6?