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
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
should give you help on that function. Type
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
then
evaluates to b, and
evaluates to {b,c,d}. Here
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
and then
. Then,
would return
Compound bodies
Multiple commands can be grouped together using the [ and ] brackets.
the form
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.
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.