Ask Your Question
1

why unable to call giac as integrate method in version 9.4?

asked 2021-09-15 23:12:03 +0100

Nasser gravatar image

updated 2021-09-15 23:33:00 +0100

I just installed sagemath binary, latest stable version 9.4 on my Linux VBox. I normally install sagemath using the Linux Manjaro package manager, but it only see 9.3 now. That is why I downloaded the binary from https://www.sagemath.org/download-lin... (downloaded the 64 bit version).

Uninstalled 9.3 from my box.

Now I started to use sage 9.4 binary, and set the path, and started it. Everything looks OK. I am able to use fricas and maxima integrate, but can no longer use giac. Even though all of these are installed on same Linux I am using, and I was able to use giac from 9.3. But not from 9.4. Here is a MWE

I noticed the binary sagemath is using its own version of giac, in /home/me/SageMath/local/bin/giac and not the one I have already installed in my Linux which is in /bin/giac and these are different versions. The one in /bin/giac is 1.7 and the one shipped with sagemath binary is older, 1.6.

How to tell sagemath to use my own version of giac on /bin/giac and not the one that comes with sagemath binary? May be this will fix this problem:

>which giac
/bin/giac
>giac --version
// Using locale /usr/share/locale/
// en_US.utf8
// /usr/share/locale/
// giac
// UTF-8
// Maximum number of parallel threads 2
// (c) 2001, 2021 B. Parisse & others
1.7.0
>
>
>sage 
┌────────────────────────────────────────────────────────────────────┐
│ SageMath version 9.4, Release Date: 2021-08-22                     │
│ Using Python 3.9.5. Type "help()" for help.                        │
└────────────────────────────────────────────────────────────────────┘

sage: var('x')                                                                                                                                              
x

sage: integrate(x,x, algorithm="fricas")                                                                                                                    
1/2*x^2

sage: integrate(x,x, algorithm="maxima")                                                                                                                    
1/2*x^2

sage: integrate(x,x, algorithm="giac")                                                                                                                      
---------------------------------------------------------------------------
EOF                                       Traceback (most recent call last)
~/SageMath/local/lib/python3.9/site-packages/sage/interfaces/expect.py in _start(self, alt_message, block_during_init)
    515         try:
--> 516             self._expect.expect(self._prompt)
    517         except (pexpect.TIMEOUT, pexpect.EOF) as msg:

~/SageMath/local/lib/python3.9/site-packages/pexpect/spawnbase.py in expect(self, pattern, timeout, searchwindowsize, async_, **kw)
    342         compiled_pattern_list = self.compile_pattern_list(pattern)
--> 343         return self.expect_list(compiled_pattern_list,
    344                 timeout, searchwindowsize, async_)

~/SageMath/local/lib/python3.9/site-packages/pexpect/spawnbase.py in expect_list(self, pattern_list, timeout, searchwindowsize, async_, **kw)
    371         else:
--> 372             return exp.expect_loop(timeout)
    373 

~/SageMath/local/lib/python3.9/site-packages/pexpect/expect.py in expect_loop(self, timeout)
    178         except EOF as e:
--> 179             return self.eof(e)
    180         except TIMEOUT as e:

~/SageMath/local/lib/python3.9/site-packages/pexpect/expect.py in eof(self, err)
    121             exc.__cause__ = None # in Python 3.x we can use "raise exc from None"
--> 122             raise exc
    123 

EOF: End Of File (EOF). Exception style platform.
Giac with PID 2855 running /home/me/SageMath/local/bin/giac --sage
command: /home/me/SageMath/local/bin/giac
args: ['/home/me/SageMath/local/bin/giac', '--sage']
buffer (last 100 chars): b''
before (last 100 chars): b'// Maximum number of parallel threads 2\r\nWarning adding 1 ) at end of input\r\n'
after: <class 'pexpect.exceptions.EOF'>
match: None
match_index: None
exitstatus: None
flag_eof: True
pid: 2855
child_fd: 18
closed: False
timeout: None
delimiter: <class 'pexpect.exceptions.EOF'>
logfile: None
logfile_read: None
logfile_send: None
maxread: 4194304
ignorecase: False
searchwindowsize: None
delaybeforesend: None
delayafterclose: 0.1
delayafterterminate: 0.1
searcher: searcher_re:
    0: re.compile(b'[0-9]*>> ')

During handling of the above exception, another exception occurred:

RuntimeError                              Traceback (most recent call last)
~/SageMath/local/lib/python3.9/site-packages/sage/interfaces/expect.py in __init__(self, parent, value, is_name, name)
   1468             try:
-> 1469                 self._name = parent._create(value, name=name)
   1470             # Convert ValueError and RuntimeError to TypeError for

~/SageMath/local/lib/python3.9/site-packages/sage/interfaces/interface.py in _create(self, value, name)
    512         name = self._next_var_name() if name is None else name
--> 513         self.set(name, value)
    514         return name

~/SageMath/local/lib/python3.9/site-packages/sage/interfaces/giac.py in set(self, var, value)
    665         cmd = '%s:=%s:;'%(var,value)   #if giac is not in maple mode ( maple_mode(0))
--> 666         out = self.eval(cmd)
    667         if out.find("error") != -1:

~/SageMath/local/lib/python3.9/site-packages/sage/interfaces/giac.py in eval(self, code, strip, **kwds)
    649              code = code.replace("\n","").strip()
--> 650         ans = Expect.eval(self, code, strip=strip, **kwds).strip()
    651         return ans

~/SageMath/local/lib/python3.9/site-packages/sage/interfaces/expect.py in eval(self, code, strip, synchronize, locals, allow_use_file, split_lines, **kwds)
   1380                 elif split_lines:
-> 1381                     return '\n'.join([self._eval_line(L, allow_use_file=allow_use_file, **kwds)
   1382                                         for L in code.split('\n') if L != ''])

~/SageMath/local/lib/python3.9/site-packages/sage/interfaces/expect.py in <listcomp>(.0)
   1380                 elif split_lines:
-> 1381                     return '\n'.join([self._eval_line(L, allow_use_file=allow_use_file, **kwds)
   1382                                         for L in code.split('\n') if L != ''])

~/SageMath/local/lib/python3.9/site-packages/sage/interfaces/giac.py in _eval_line(self, line, allow_use_file, wait_for_prompt, restart_if_needed)
    615         with gc_disabled():
--> 616             z = Expect._eval_line(self, line, allow_use_file=allow_use_file,
    617                     wait_for_prompt=wait_for_prompt)

~/SageMath/local/lib/python3.9/site-packages/sage/interfaces/expect.py in _eval_line(self, line, allow_use_file, wait_for_prompt, restart_if_needed)
    946             if self._expect is None:
--> 947                 self._start()
    948             E = self._expect

~/SageMath/local/lib/python3.9/site-packages/sage/interfaces/expect.py in _start(self, alt_message, block_during_init)
    519             self._session_number = BAD_SESSION
--> 520             raise RuntimeError("unable to start %s: %s" % (self.name(), msg))
    521         self._expect.timeout = None

RuntimeError: unable to start giac: End Of File (EOF). Exception style platform.
Giac with PID 2855 running /home/me/SageMath/local/bin/giac --sage
command: /home/me/SageMath/local/bin/giac
args: ['/home/me/SageMath/local/bin/giac', '--sage']
buffer (last 100 chars): b''
before (last 100 chars): b'// Maximum number of parallel threads 2\r\nWarning adding 1 ) at end of input\r\n'
after: <class 'pexpect.exceptions.EOF'>
match: None
match_index: None
exitstatus: None
flag_eof: True
pid: 2855
child_fd: 18
closed: False
timeout: None
delimiter: <class 'pexpect.exceptions.EOF'>
logfile: None
logfile_read: None
logfile_send: None
maxread: 4194304
ignorecase: False
searchwindowsize: None
delaybeforesend: None
delayafterclose: 0.1
delayafterterminate: 0.1
searcher: searcher_re:
    0: re.compile(b'[0-9]*>> ')

During handling of the above exception, another exception occurred:

TypeError                                 Traceback (most recent call last)
<ipython-input-6-a1b9d44d17fa> in <module>
----> 1 integrate(x,x, algorithm="giac")

~/SageMath/local/lib/python3.9/site-packages/sage/misc/functional.py in integral(x, *args, **kwds)
    757     """
    758     if hasattr(x, 'integral'):
--> 759         return x.integral(*args, **kwds)
    760     else:
    761         from sage.symbolic.ring import SR

~/SageMath/local/lib/python3.9/site-packages/sage/symbolic/expression.pyx in sage.symbolic.expression.Expression.integral (build/cythonized/sage/symbolic/expression.cpp:67294)()
  12749                     R = SR
  12750             return R(integral(f, v, a, b, **kwds))
> 12751         return integral(self, *args, **kwds)
  12752 
  12753     integrate = integral

~/SageMath/local/lib/python3.9/site-packages/sage/symbolic/integration/integral.py in integrate(expression, v, a, b, algorithm, hold)
   1008         if not integrator:
   1009             raise ValueError("Unknown algorithm: %s" % algorithm)
-> 1010         return integrator(expression, v, a, b)
   1011     if a is None:
   1012         return indefinite_integral(expression, v, hold=hold)

~/SageMath/local/lib/python3.9/site-packages/sage/symbolic/integration/external.py in giac_integrator(expression, v, a, b)
    243         sin(π)
    244     """
--> 245     ex = expression._giac_()
    246     if a is None:
    247         result = ex.integrate(v._giac_())

~/SageMath/local/lib/python3.9/site-packages/sage/structure/sage_object.pyx in sage.structure.sage_object.SageObject._giac_ (build/cythonized/sage/structure/sage_object.c:7913)()
    778             import sage.interfaces.giac
    779             G = sage.interfaces.giac.giac
--> 780         return self._interface_(G)
    781 
    782     def _giac_init_(self):

~/SageMath/local/lib/python3.9/site-packages/sage/symbolic/expression.pyx in sage.symbolic.expression.Expression._interface_ (build/cythonized/sage/symbolic/expression.cpp:7985)()
   1018         if is_a_constant(self._gobj):
   1019             return self.pyobject()._interface_(I)
-> 1020         return super(Expression, self)._interface_(I)
   1021 
   1022     def _maxima_(self, session=None):

~/SageMath/local/lib/python3.9/site-packages/sage/structure/sage_object.pyx in sage.structure.sage_object.SageObject._interface_ (build/cythonized/sage/structure/sage_object.c:5759)()
    690             except Exception:
    691                 raise NotImplementedError("coercion of object %s to %s not implemented:\n%s\n%s" % (repr(self), I))
--> 692         X = I(s)
    693         if c:
    694             try:

~/SageMath/local/lib/python3.9/site-packages/sage/interfaces/interface.py in __call__(self, x, name)
    293 
    294         if isinstance(x, str):
--> 295             return cls(self, x, name=name)
    296         try:
    297             # Special methods do not and should not have an option to

~/SageMath/local/lib/python3.9/site-packages/sage/interfaces/expect.py in __init__(self, parent, value, is_name, name)
   1472             except (RuntimeError, ValueError) as x:
   1473                 self._session_number = -1
-> 1474                 raise TypeError(*x.args)
   1475             except BaseException:
   1476                 self._session_number = -1

TypeError: unable to start giac: End Of File (EOF). Exception style platform.
Giac with PID 2855 running /home/me/SageMath/local/bin/giac --sage
command: /home/me/SageMath/local/bin/giac
args: ['/home/me/SageMath/local/bin/giac', '--sage']
buffer (last 100 chars): b''
before (last 100 chars): b'// Maximum number of parallel threads 2\r\nWarning adding 1 ) at end of input\r\n'
after: <class 'pexpect.exceptions.EOF'>
match: None
match_index: None
exitstatus: None
flag_eof: True
pid: 2855
child_fd: 18
closed: False
timeout: None
delimiter: <class 'pexpect.exceptions.EOF'>
logfile: None
logfile_read: None
logfile_send: None
maxread: 4194304
ignorecase: False
searchwindowsize: None
delaybeforesend: None
delayafterclose: 0.1
delayafterterminate: 0.1
searcher: searcher_re:
    0: re.compile(b'[0-9]*>> ')
sage:

I can only use stable releases and 9.4 is the latest stable release.

My Linux us

>cat /etc/os-release
 NAME="Manjaro Linux"
 ID=manjaro
 ID_LIKE=arch
 BUILD_ID=rolling
 PRETTY_NAME="Manjaro Linux"
 ANSI_COLOR="32;1;24;144;200"
 HOME_URL="https://manjaro.org/"
 DOCUMENTATION_URL="https://wiki.manjaro.org/"
 SUPPORT_URL="https://manjaro.org/"
 BUG_REPORT_URL="https://bugs.manjaro.org/"
 LOGO=manjarolinux
 >lsb_release -a
 shell-init: error retrieving current directory: getcwd: cannot access
 parent directories: No such file or directory
 LSB Version:    n/a
 Distributor ID: ManjaroLinux
 Description:    Manjaro Linux
 Release:        21.0.4
 Codename:       Ornara

 }}}

Any one else see this problem and how to correct it?

edit retag flag offensive close merge delete

Comments

confirmed: giac doesn't work

Masacroso gravatar imageMasacroso ( 2021-09-16 02:05:09 +0100 )edit

UNconfirmed : works in sagecell...

EDIT : More UNconfirmatuion : on Debian testing :

sage: sage.version.version
'9.5.beta1'
sage: giac.version()
"giac 1.6.0, (c) B. Parisse and R. De Graeve, Institut Fourier, Universite de Grenoble I"
sage: integrate(x,x)
1/2*x^2
sage: integrate(x,x, algorithm="giac")
1/2*x^2

You might report this as an Ubuntu-specific problem (probably to the Ubuntu maintainers...).

Emmanuel Charpentier gravatar imageEmmanuel Charpentier ( 2021-09-16 09:54:24 +0100 )edit

1 Answer

Sort by » oldest newest most voted
2

answered 2021-09-15 23:40:57 +0100

Nasser gravatar image

OK, found a workaround.

The giac that comes with sagemath 9.4 binary is old. version 1.6. I changed the symbolic link in /home/me/SageMath/local/bin/giac to point to the newer version I had in /bin/giac and now the error went away:

>pwd
/home/me/SageMath/local/bin

>ls -l giac
lrwxrwxrwx 1 me me 6 Aug 22 08:00 giac -> ./icas

>ln -sfn /bin/giac giac

>ls -lrt giac
lrwxrwxrwx 1 me me 9 Sep 15 16:36 giac -> /bin/giac
>

And now from sagemath, it works. No error

sage: integrate(x,x, algorithm="giac")                                                                                                                      
1/2*x^2

Strange that sagemath binary 9.4 ships with older giac and one that for some reason does not work.

edit flag offensive delete link more

Comments

This works for me and in sagemathcell, so is a problem with your specific installs.

FrédéricC gravatar imageFrédéricC ( 2021-09-16 08:35:32 +0100 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2021-09-15 23:12:03 +0100

Seen: 450 times

Last updated: Sep 15 '21