Getting started with Yacas off-line


Introduction

Yacas (Yet Another Computer Algebra System) is a small and highly flexible general-purpose computer algebra system and programming language. The language has a familiar, C-like infix-operator syntax. The distribution contains a small library of mathematical functions, but its real strength is in the language in which you can easily write your own symbolic manipulation algorithms. The core engine supports arbitrary precision arithmetic (for faster calculations, it can also optionally be linked with the GNU arbitrary precision math library libgmp) and is able to execute symbolic manipulations on various mathematical objects by following user-defined rules.

Currently, the Yacas programming language is stable and seems powerful enough for all computer algebra applications. External libraries providing additional functionality may be dynamically loaded into Yacas via the "plugin" mechanism.

This section describes how to get started with Yacas locally by downloading and compiling the program. However, this is not strictly necessary. You can also go online to our web site and use Yacas in there inside your browser. The web page contains tutorials, example calculations and lots of documentation. This document is only useful if you plan to build and install Yacas yourself.


Installing Yacas

Read the file INSTALL for instructions on how to compile Yacas. Yacas is portable across most Unix-ish platforms and requires only a standard C++ compiler such as g++.

The base Yacas application accepts text as input and returns text as output. This makes it rather platform-independent. Apart from Unix-like systems, Yacas has been compiled on Windows and on EPOC32, aka Psion (which doesn't come with a standard C++ library!). The source code to compile Yacas for Windows can be found at the Sourceforge repository .

For Unix, compilation basically amounts to the standard sequence

./configure
make
make install
This will install the binaries to /usr/local/bin and the library files to /usr/local/share/yacas/.

A note for MacOS X 10.4 users; for now loading dynamic link libraries does not work well (December 2005). So in order to build Yacas properly on Mac OS X the collowing configure command can be used:

./configure CFLAGS="-O9 -DDISABLE_DYNAMIC" \
    CXXFLAGS="-O9 -DDISABLE_DYNAMIC" \
    --enable-server --disable-shared

The arbitrary precision math in Yacas will be generally faster if you compile Yacas with the libgmp library (the option --with-numlib=gmp for the configure script). Precompiled Red Hat (RPM) and Debian (DEB) packages are also available.

Additionally, LaTeX-formatted documentation in PostScript and PDF formats can be produced by the command

make texdocs

or, alternatively, by passing --enable-ps-doc or --enable-pdf-doc to ./configure when building Yacas. In the latter case, the documentation will be automatically rebuilt every time the documentation changes (which is useful when maintaining the documentation).

In addition, there is also a Java version of the lower-level interpreter. The code for this Java version can be found in the directory "JavaYacas", and can be compiled with the make file "makefile.yacas", by typing in:

make -f makefile.yacas

The interpreter can then be invoked from the command line with:

java -jar yacas.jar

or alternatively it can be invoked as an applet, by opening yacasconsole.html.

The binary files that comprise the entire binary release for the Java version are:

To get copy-pasting to work in the applet version, you need to tell the Java virtual machine that you trust this applet to get or set data on the clipboard of your OS.

On Unix-like systems this means creating a file ~/.java.policy if it does not already exist, and then adding the following lines to it:

grant codeBase "http://yacas.sourceforge.net/*" {
permission java.awt.AWTPermission "accessClipboard";
};

This grants all applets residing at http://www.xs4all.nl/~apinkus/* access to the clipboard.

This can be done in a similar way on Windows, but the directory where you need to place the .java.policy file depends on the version of Windows that is running.

The Java version has almost all the features the C++ version has. In fact, there is no reason the Java version should not have all the same features. At the time of writing (version 1.0.58), plugins are not available yet, not all command line arguments are available yet, and the command line prompt does not have the history yet.


Using the console mode

You can run Yacas in the console mode simply by typing yacas. The Yacas command prompt looks like this:
In>
and Yacas's answers appear after the prompt
Out>

A Yacas session may be terminated by typing Exit() or quit. Pressing ^C will also quit Yacas; however, pressing ^C while Yacas is busy with a calculation will stop just that calculation. A session can be restarted (forgetting all previous definitions and results) by typing
restart

Typically, you would enter one statement per line, for example

In> Sin(Pi/2);
Out> 1;

Statements should end with a semicolon (;) although this is not required in interactive sessions (Yacas will append a semicolon at end of line to finish the statement).

Type Example(); to get some random examples of Yacas calculations.

The command line has a history list, so it should be easy to browse through the expressions you entered previously using the Up and Down arrow keys.

When a few characters have been typed, the command line will use the characters before the cursor as a filter into the history, and allow you to browse through all the commands in the history that start with these characters quickly, instead of browsing through the entire history.

Typing the first few characters of a previous expression and then hitting the TAB key makes Yacas recall the last expression in the history list that matches these first characters.

Commands spanning multiple lines can (and actually have to) be entered by using a trailing backslash \ at end of each continued line. For example:

In> a:=2+3+
Error on line 1 in file [CommandLine]
Line error occurred on:
>>>
Error parsing expression

In> a:=2+3+ \
In> 1
Out> 6;
The error after our first attempt occurred because Yacas has appended a semicolon at end of the first line and 2+3+; is not a valid Yacas expression.

Incidentally, any text Yacas prints without a prompt is either messages printed by functions as their side-effect, or error messages. Resulting values of expressions are always printed after an Out> prompt.