 |
Using TeXmacs as an interface |
 |
An important feature of TeXmacs is it's ability to communicate with
extern systems in shell-like sessions. Typically, it is possible to
evaluate commands of an extern computer algebra system inside such a
session and display the results in a nice, graphical way. It is also
possible to evaluate shell commands and Scheme
programs inside such sessions.
1.Creating sessions
A session can be started from the Insert→Session menu. A session consists of a
sequence of input and output fields and possible text between them.
When pressing return inside an input field of a
session, the text inside the environment is evaluated and the result
is displayed in an output field.
When entering a command in a session, the application attempts to
execute it. Several commands may be launched concurrently in the same
document, but the output will only be active in the session where the
cursor is and at the place of the cursor. Therefore, we recommend to
use different buffers for parallel executions.
For each type of extern application, one may choose between sharing a
single process by different sessions, or launching a separate process
for each different session. More precisely, when inserting a session
using Insert→Session→Other, you may specify both a “session
type” (Shell, Pari, Maxima, etc.) and a
“session name” (the default name is
“default”). Sessions with different names correspond to
different processes and sessions with the same name share a common
process.
In order to finish the process which underlies a given session, you
may use Session→Close
session. When pressing return in
the input of a non-connected system, the system will be restarted
automatically. You may also use Session→Interrupt execution in order to interrupt
the execution of a command. However, several applications do not
support this feature.
2.Editing sessions
Inside input fields of sessions, the cursor keys have a special
meaning: when moving upwards or downwards, you will move to previous
or subsequent input fields. When moving to the left or to the right,
you will never leave the input field; you should rather use the mouse
for this.
Some facilities for editing input, output and text fields are
available in the Session→Insert
fields and Session→Remove fields menus. Most operations
directly apply to matching input/output fields. Optionally, an
additional explanatory text field can be associated to an input field
using Session→Insert
fields→Insert text field.
Keyboard shortcuts for inserting fields are A-up
(insert above) and A-down. Keyboard shortcuts for
removing matching text/input/output fields are
A-backspace (remove backwards) and
A-delete (remove current fields).
It is possible to create “subsessions” using Session→Insert fields→Fold input
field or A-right. In that case, the
current text/input/output field becomes the body of an unfolded
subsession. Such a subsession consists of an explanatory text together
with a sequence of text/input/output fields. Subsessions can be folded
and unfolded using M-A-up resp.
M-A-down. Subsessions have a nice rendering on the
screen when using the varsession
package in Document→Use
package→Program.
Other useful editing operations for text/input/output fields are
Session→Remove
fields→Remove all output fields, which is useful for creating a demo sessions which will be
executed later on, and Session→Split session, which can be used for
splitting a session into parts for inclusion into a paper.
3.Selecting the input method
By default, TeXmacs will attempt to evaluate the input field when
pressing return. Multiline input can be created using
S-return. Alternatively, when selecting the multiline
input mode using Session→Input
mode→Multiline input,
the return key will behave as usual and
S-return may be used in order to evaluate the input
field. Notice finally that certain systems admit built-in heuristics
for testing whether the input has been completed; if not, then the
return may behave as usual.
Certain applications allow you to type the mathematical input in a
graphical, two dimensional form. This feature can be used by selecting
Session→Input
mode→Mathematical input.
If this feature is available, then it is usually also possible to copy
and paste output back into the input. However, it depends on the
particular application how well this works.
4.Supported systems
When taking a look at the Insert→Session menu, only those systems which are
actually installed on your system will show up. The only exceptions
are shell sessions and scheme sessions, which are always available.
Below, you find a short list of free computer algebra systems which
have been interfaced with TeXmacs. There also exist interfaces with
several proprietary interfaces, but you should look at the
documentation of those systems for more information.
4.1.Shell sessions and scheme
sessions
In a “shell session” it is possible to evaluate shell
commands. All input and output is verbatim. No particular command-line
utilities (such as completion mechanisms) have been implemented yet.
The output of the shell command is displayed gradually as the program
executes.
In a “Scheme session” you can
evaluate Guile/Scheme
programs. The input should be verbatim text. The input is evaluated
and the result is displayed. No gradual output mechanism has been
implemented yet for Scheme session.
4.2.Giac
Giac Is A Computer algebra system, which can be
downloaded from
http://www-fourier.ujf-grenoble.fr/~parisse/english.html
4.3.GTybalt
GTybalt is a free computer algebra system which
is built on top of GiNaC, CLN
and a program to interpret C and C++
commands. For more information, see
http://www.fis.unipr.it/~stefanw/gtybalt.html
4.4.Macaulay 2
Macaulay 2 is a new software system devoted to
supporting research in algebraic geometry and commutative algebra. The
software is available now in source code for porting, and in compiled
form for Linux, Sun OS,
Solaris, Windows, and a
few other unix machines. You can get it from
http://www.math.uiuc.edu/Macaulay2
4.5.Maxima
Maxima is not alone one of the oldest and best
computer algebra systems around, it is also one of the only general
purpose systems for which there is a free implementation. You can get
it from
http://www.ma.utexas.edu/users/wfs/maxima.html
The supported version is GCL-based Maxima
5.6. For CLisp-based Maxima
5.6, edit your tm_maxima and replace -load
by -i. For Maxima 5.9-pre,
replace -load by -p. Known problems:
-
If you press return when a statement is not complete
(typically, terminated by ; or $),
the interface will hang.
-
If you cause the Lisp break prompt to appear, the interface will
hang.
-
The command info is not supported (it is defined in
the underlying Lisp, and difficult to support portably).
-
Some commands in the debugger work, but some (including :c)
don't work, nobody knows why.
-
The command load sometimes behaves mysteriously.
4.6.Pari
Pari is a software package for computer-aided
number theory. It consists of a C library, libpari (with optional assembler cores for some popular
architectures), and of the programmable interactive gp
calculator. You can download Pari from
ftp://megrez.math.u-bordeaux.fr/pub/pari
You will need a version newer than Pari-2.1.0
for use from inside TeXmacs (for an already installed Pari-system,
type gp –version).
4.7.Qcl
QCL is a high level, architecture independent
programming language for quantum computers, with a syntax derived from
classical procedural languages like C or Pascal. This allows for the complete implementation and
simulation of quantum algorithms (including classical components) in
one consistent formalism. The TeXmacs interface is mainly useful for
displaying quantum states in a readable way. For more information, see
http://tph.tuwien.ac.at/~oemer/qcl.html
Starting from 1.0.0.8, TeXmacs supports QCL
0.4.3 or newer. Users of older versions should upgrade.
4.8.Yacas
Yacas is, as it's name suggest, yet another
computer algebra system. Things implemented include: arbitrary
precision, rational numeric, vector, complex, and matrix computations
(including inverses and determinants and solving matrix equations),
derivatives, solving, Taylor series, numerical solving (Newtons
method), and a lot more non-mathematical algorithms. The language
natively supports variables and user-defined functions. There is basic
support for univariate polynomials, integrating functions and tensor
calculations. You can get Yacas at
http://www.xs4all.nl/~apinkus/yacas.html
© 1999–2003 Joris van der Hoeven
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.1 or
any later version published by the Free Software Foundation; with no
Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
Texts. A copy of the license is included in the section entitled
"GNU Free Documentation License".