#10940: giac interface
----------------------------+-----------------------------------------------
   Reporter:  Han Frederic  |          Owner:  kohel           
       Type:  enhancement   |         Status:  needs_work      
   Priority:  minor         |      Milestone:  sage-4.7.2      
  Component:  interfaces    |       Keywords:  giac, interfaces
Work_issues:                |       Upstream:  N/A             
   Reviewer:  David Kohel   |         Author:  Frederic Han    
     Merged:                |   Dependencies:                  
----------------------------+-----------------------------------------------
Changes (by newvalueoldvalue):

  * status:  needs_review => needs_work
  * reviewer:  => David Kohel
  * author:  => Frederic Han


Comment:

 This adds a new interface (based on maple.py) to the
 giac library:

 http://www-fourier.ujf-grenoble.fr/~parisse/giac.html

 This library, in the form of the graphical interface
 xcas, is widely used in the France competitive exams
 for high school teachers, hence widely tested.

 The new interface is fully documented, more examples
 of usage are found here:

 http://www.math.jussieu.fr/~han/exemples-giac%20--%20Sage.html

 I identified one error in preparing the patch: 'giac'
 needs to be added to interfaces at the end of all.py.

 A simple pre-parsing would improve the interface:

 sage: s = """
 my_mod(a,b) := {
     return irem(a,b)
 }
 """

 sage: giac(s)

 <error>

 However, reducing to one line works:

 sage: giac(s.replace("\n",""))
  (a,b)->{
   return(irem(a,b));
 }

 sage: giac("my_mod(103,101)")

 2

 or similarly one can insert \'s:

 sage: giac(s.replace("\n","\\"))
  (a,b)->{
   return(irem(a,b));
 }

 sage: giac("my_mod(103,101)")

 2

 Caution: I don't know if the giac
 parser always ignores "\n", and in
 the second replacement some more
 care is needed to avoid replacing
 "\\\n" with "\\\\".

 The example given on the above site is:

 %giac
 f:=(a,b)-> if (a<b)  \
              then  x[a,b];   \
              else    if (a>b) \
                       then  -x[b,a]; \
                       else   0;  \
                      fi;\
              fi;

 Given that giac uses ";" to terminate lines,
 a better pre-parsing would render the \'s
 unnecessary, as is the case for the xcas
 interpretter.

 It should be noted that conversions back to
 Sage are limited.  As far as I can tell only
 automatic string evaluations succeed (but
 errors are trapped and this is documented).

 Finally, the author notes that an interrupt
 in Sage can kill the giac session.

 Extending conversions to Sage and handling
 interrupts better are larger projects which
 could be done later.  Rebuilding the diff
 to recover the %giac magic feature and some
 slight pre-parsing would be desirable to
 complete this interface.

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/10940#comment:5>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sage-trac?hl=en.

Reply via email to