Sage 9.4 Reference Manual: Interpreter Interfaces Release 9.4

Sage 9.4 Reference Manual: Interpreter Interfaces Release 9.4

Sage 9.4 Reference Manual: Interpreter Interfaces Release 9.4 The Sage Development Team Aug 24, 2021 CONTENTS 1 Common Interface Functionality3 2 Common Interface Functionality through Pexpect9 3 Sage wrapper around pexpect’s spawn class and 13 4 Interface to Axiom 15 5 The Elliptic Curve Factorization Method 21 6 Interface to 4ti2 27 7 Interface to FriCAS 33 8 Interface to Frobby for fast computations on monomial ideals. 45 9 Interface to GAP 49 9.1 First Examples.............................................. 49 9.2 GAP and Singular............................................ 49 9.3 Saving and loading objects........................................ 51 9.4 Long Input................................................ 51 9.5 Changing which GAP is used...................................... 51 10 Interface to GAP3 61 10.1 Obtaining GAP3............................................. 61 10.2 Changing which GAP3 is used...................................... 61 10.3 Functionality and Examples....................................... 62 10.4 Common Pitfalls............................................. 63 10.5 Examples................................................. 64 11 Interface to Groebner Fan 69 12 Pexpect Interface to Giac 71 12.1 Tutorial.................................................. 72 13 Interface to the Gnuplot interpreter 81 14 Interface to the GP calculator of PARI/GP 83 15 Interface for extracting data and generating images from Jmol readable files. 93 i 16 Interface to KASH 95 16.1 Issues................................................... 95 16.2 Tutorial.................................................. 95 16.3 Long Input................................................ 101 17 Library interface to Kenzo 105 18 Interface to LattE integrale programs 133 19 Interface to LiE 137 19.1 Tutorial.................................................. 138 20 Lisp Interface 145 21 Interface to Macaulay2 149 22 Interface to Magma 163 22.1 Parameters................................................ 163 22.2 Multiple Return Values.......................................... 164 22.3 Long Input................................................ 164 22.4 Garbage Collection............................................ 164 22.5 Other Examples............................................. 165 23 Interface to the free online MAGMA calculator 183 24 Interface to Maple 185 24.1 Tutorial.................................................. 185 25 Interface to Mathematica 193 25.1 Tutorial.................................................. 194 25.2 Long Input................................................ 197 25.3 Loading and saving............................................ 197 25.4 Complicated translations......................................... 197 26 Interface to MATLAB 203 26.1 Tutorial.................................................. 203 27 Pexpect interface to Maxima 209 27.1 Tutorial.................................................. 210 27.2 Examples involving matrices....................................... 212 27.3 Laplace Transforms........................................... 213 27.4 Continued Fractions........................................... 214 27.5 Special examples............................................. 214 27.6 Miscellaneous.............................................. 215 27.7 Interactivity................................................ 215 27.8 Latex Output............................................... 215 27.9 Long Input................................................ 215 28 Abstract interface to Maxima 219 29 Library interface to Maxima 237 30 Interface to MuPAD 247 31 Interface to mwrank 251 ii 32 Interface to GNU Octave 255 32.1 Computation of Special Functions.................................... 255 32.2 Tutorial.................................................. 256 33 Interface to PHC. 261 34 Interface to polymake 269 35 POV-Ray, The Persistence of Vision Ray Tracer 285 36 Parallel Interface to the Sage interpreter 287 37 Interface to QEPCAD 289 38 Interface to Bill Hart’s Quadratic Sieve 315 39 Interfaces to R 319 40 Interface to several Rubik’s cube solvers. 333 41 Interface to Sage 337 42 Interface to Scilab 343 43 Interface to Singular 349 43.1 Introduction............................................... 349 43.2 Tutorial.................................................. 350 43.3 Computing the Genus.......................................... 352 43.4 An Important Concept.......................................... 353 43.5 Long Input................................................ 354 44 SymPy –> Sage conversion 371 45 The Tachyon Ray Tracer 373 46 Interface to TIDES 375 47 Interface to the Sage cleaner 379 48 Quitting interfaces 381 49 An interface to read data files 383 50 Indices and Tables 385 Python Module Index 387 Index 389 iii iv Sage 9.4 Reference Manual: Interpreter Interfaces, Release 9.4 Sage provides a unified interface to the best computational software. This is accomplished using both C-libraries (see C/C++ Library Interfaces) and interpreter interfaces, which are implemented using pseudo-tty’s, system files, etc. This chapter is about these interpreter interfaces. Note: Each interface requires that the corresponding software is installed on your computer. Sage includes GAP, PARI, Singular, and Maxima, but does not include Octave (very easy to install), MAGMA (non-free), Maple (non-free), or Mathematica (non-free). There is overhead associated with each call to one of these systems. For example, computing 2+2 thousands of times using the GAP interface will be slower than doing it directly in Sage. In contrast, the C-library interfaces of C/C++ Library Interfaces incur less overhead. In addition to the commands described for each of the interfaces below, you can also type e.g., %gap, %magma, etc., to directly interact with a given interface in its state. Alternatively, if X is an interface object, typing X.interact() allows you to interact with it. This is completely different than X.console() which starts a complete new copy of whatever program X interacts with. Note that the input for X.interact() is handled by Sage, so the history buffer is the same as for Sage, tab completion is as for Sage (unfortunately!), and input that spans multiple lines must be indicated using a backslash at the end of each line. You can pull data into an interactive session with X using sage(expression). The console and interact methods of an interface do very different things. For example, using gap as an example: 1. gap.console(): You are completely using another program, e.g., gap/magma/gp Here Sage is serving as noth- ing more than a convenient program launcher, similar to bash. 2. gap.interact(): This is a convenient way to interact with a running gap instance that may be “full of” Sage objects. You can import Sage objects into this gap (even from the interactive interface), etc. The console function is very useful on occasion, since you get the exact actual program available (especially useful for tab completion and testing to make sure nothing funny is going on). CONTENTS 1 Sage 9.4 Reference Manual: Interpreter Interfaces, Release 9.4 2 CONTENTS CHAPTER ONE COMMON INTERFACE FUNCTIONALITY See the examples in the other sections for how to use specific interfaces. The interface classes all derive from the generic interface that is described in this section. AUTHORS: • William Stein (2005): initial version • William Stein (2006-03-01): got rid of infinite loop on startup if client system missing • Felix Lawrence (2009-08-21): edited ._sage_() to support lists and float exponents in foreign notation. • Simon King (2010-09-25): Expect._local_tmpfile() depends on Expect.pid() and is cached; Expect.quit() clears that cache, which is important for forking. • Jean-Pierre Flori (2010,2011): Split non Pexpect stuff into a parent class. • Simon King (2015): Improve pickling for InterfaceElement class sage.interfaces.interface.AsciiArtString Bases: str class sage.interfaces.interface.Interface(name) Bases: sage.misc.fast_methods.WithEqualityById, sage.structure.parent_base. ParentWithBase Interface interface object. Note: Two interfaces compare equal if and only if they are identical objects (this is a critical constraint so that caching of representations of objects in interfaces works correctly). Otherwise they are never equal. call(function_name, *args, **kwds) clear(var) Clear the variable named var. console() cputime() CPU time since this process started running. eval(code, **kwds) Evaluate code in an interface. This method needs to be implemented in sub-classes. Note that it is not always to be expected that it returns a non-empty string. In contrast, get() is supposed to return the result of applying a print command to the object so that the output is easier to parse. 3 Sage 9.4 Reference Manual: Interpreter Interfaces, Release 9.4 Likewise, the method _eval_line() for evaluation of a single line, often makes sense to be overridden. execute(*args, **kwds) function_call(function, args=None, kwds=None) EXAMPLES: sage: maxima.quad_qags(x, x,0,1, epsrel=1e-4) [0.5,5.5511151231257...e-15,21,0] sage: maxima.function_call('quad_qags', [x, x,0,1], { 'epsrel':'1e-4'}) [0.5,5.5511151231257...e-15,21,0] get(var) Get the value of the variable var. Note that this needs to be overridden in some interfaces, namely when getting the string representation of an object requires an explicit print command. get_seed() Return the seed used to set the random number generator in this interface. The seed is initialized as None but should be set when

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    410 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us