Introduction

Yacas (Yet Another Computer Algebra System) is a small and highly flexible computer algebra language. The syntax uses a infix-operator grammar parser. 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. It supports arbitrary precision arithmetic.

Getting started

Read the file INSTALL for instructions on how to compile Yacas. After launching Yacas, you should be able to halt again by typing
Exit();
Typically, lines should end with a ; , although this is not required (Yacas will append a ;).

There is also some online help. If you type
??
you should be able to read this manual. Typing
?function
should give you help on that function. Type
Example();
to get some random examples.

In this documentation you should find some examples on how to use Yacas.

Syntax

The syntax is handled by an infix operator grammar parser. This means that most of the times you type in expressions of the form Func(var1,var2) , or using infix operators, a+b , prefix operators -x ,or postfix operators x++. Last but not least there are the 'bodied' operators, which look like normal functions f(x) but with the last argument outside of the argument list: more like f(x)y . A typical example is the function While, which takes on the form While(predicate)body;

Lists

In addition, there are lists. Lists are groups of items, represented by putting the objects between braces. The list of objects a,b, and c could be entered by typing {a,b,c}. In this system, vectors are represented through lists. Matrices are lists of lists.

Lists can be accessed through the [[i]] operator. Examples: when you enter
uu:={a,b,c,d,e,f};
then
uu[[2]];
evaluates to b, and
uu[[2 .. 4]];
evaluates to {b,c,d}. Here
2 .. 4
evaluates to {2,3,4}. Note that spaces around the .. operator are needed, because otherwise the parser will not be able to distinguish it from a number.

Another list type is the associated list, which can act as a mini database. Indexing can go through strings. As an example, first enter
u:={};
and then
u[["hello"]]:="world"
. Then,
u[["hello"]]
would return
"world"

Compound bodies

Multiple commands can be grouped together using the [ and ] brackets. the form
[a;b;c;];
evaluates a, then b, then c, and returns the result of evaluating c.

Threading

Some functions can be threaded. This means that calling the function with a list as argument will result in a list with that function being called on each item in the list. Eg.
Sin({a,b,c});
will result in {Sin(a),Sin(b),Sin(c)}. This functionality is implemented for most normal analytic functions and arithmetic operators.

Pure functions

Pure functions are currently implemented using the operator Apply. The following line:
Apply( {{x,y},x+y} , {2,3} );
would also evaluate to 5.

Here, {{x,y},x+y} is treated as a pure function, x and y becoming the local variables bound to the parameters passed, and x+y the body.