A preliminary Symbolic Toolbox for ScilabDecember 2006.
IntroductionThe proposed toolbox is an interface between Scilab and Maxima. The objective is to make available some Maxima routines directly in Scilab workspace using Scilab syntax. Warning: this is a preliminary version. There are probably a lot of bugs and many useful functions are still missing. The main trouble is that some operations are quite slow on account of the way both packages communicate. The function restartserver is a must to know in this preliminary version. In case of irrelevant replies to your commands (usually replies to former commands) type restartserver in order to re-initialize Maxima workspace and the Scilab / Maxima communication process. The symbolic object. Symbolic objects are Scilab mlists consisting of a string in Maxima syntax. Symbolic objects can be manipulated mostly like matrices (operations, concatenation, insertion, extraction). They are displayed without indentation permitting us in particular to distinguish between symbolic numbers and Scilab floating point numbers. The function typeof applied to a symbolic object returns the string 'sym'. Function overloading. Only some Scilab built-in functions can be applied to user-defined objects (e.g., abs(x) where x is a symbolic object). We have developed a module (OVLD, which must be installed independently of the Symbolic Toolbox) in order to make overloading feasible for most non built-in functions. This tutorial assumes that this module is installed, otherwise some functions must be invoked with the prefix %sym_ (e.g., %sym_factor instead of factor). Even if OVLD is installed, the prefix %sym_ can be useful in order to force the use of a function of the symbolic toolbox. For example, %sym_cos(1/3) is the cosine of the symbolic number 1/3 (result much more precise than using cos(1/3)), %sym_expand((3*%s+2)^4) or %sym_expand('(3*a+b)^5') expand a Scilab polynomial or a string and return a symbolic object. Comparison with the Matlab Symbolic Toolbox. Most functions have a syntax similar to the Matlab Symbolic Toolbox. Some functions of the Matlab Toolbox are not available because missing in Maxima (e.g., exponentials of matrices, z-transform,...) in addition some functions cannot be easily overloaded, so, have a different name (double -> dbl, int -> integ). Functions for plotting and functions related to numerical precision are not available (and will not be available unless written by someone else). Symbolic types are not similar in both toolboxes. List of supported types: even, odd, integer, rational, irrational, real, imaginary, complex (default). On-line help. There is an on-line "help" function (hlp). For displaying help of non-overloaded functions, type hlp followed by a function name, for example hlp numden. For overloaded functions use the prefix sym/ for example hlp sym/gcd. Global variables. Loading the Symbolic Toolbox defines global variables (MAX, PERL, SYMDIR). These variables are the paths to used external programs, so, must not be cleared.
If you want to contribute.The sym-object structure: it is a mlist with at that time only one field denoted str1. This field is the string which would be used in Maxima for generating the considered object. e.g., This object might be enriched if necessary. Server: The main step for improving the toolbox will consist of improving the communication between Maxima and Scilab. The server stuff is in the sub-directory server of the installation directory. It consists of three programs:
The function str2max2sym is the interface between Scilab and Maxima. It is this function which invokes the interface program via unix_g. It might be invoked many times even for simple operations inducing sometimes very slow computation. This function depends on
Improvements expected:
Maxima: A good knowledge of Maxima will improve several functions and help to define important missing functions. In particular, it might be wise to add to Maxima a module specialized in matrix manipulations (for example, there is no exponential of matrices at that time).
Installation.Tested on several Unix flavours and Windows. You must have Perl, Maxima and Scilab installed (maxima and perl should preferably be in the path variable). For checking that Maxima is in your path and that you have the right version, type maxima --version in some command tool. The version should be 5.9.3 or higher. Binaries of Maxima can be downloaded from here (note that Fedora Core rpm's work well on other rpm-based Linux distributions and can also be used on Debian-based distributions via alien). Perl is usually available on Unix platforms. For Windows, Perl binaries can be downloaded from here. Installation of the Symbolic Toolbox for a single user. It is assumed that the module OVLD and the Symbolic toolbox were unzipped in a directory where you have write access. Installation requires four steps.
In case of problems.Communication Scilab / Maxima. Scilab and Maxima communicate through a server which is launched by the loader.sce script. Maxima is also launched in client mode by this script. The proposed server is provisional, it must be shut down by editing the scilab.quit file (see above) or manually by invoking the function killserver from Scilab. In case of problem, you can re-initialize Maxima and the server by invoking the function restartserver. If Scilab freezes you should re-initialize by killing manually maxima and perl/serveur tasks. On Unixes you can identify PID's of tasks to be killed by invoking the function findpid. If it doesn't work. Known issues (assuming that invoking the function restartserver didn't solve the problem):
It is slow. The principle used for communication between Maxima and Scilab is not optimal. Obtaining faster responses is the main issue before further developments. It is however possible to accelerate responses by setting the Scilab global variable INTERFACE to
|