Tutorial

This section should get you up and running with Yacas in a short time. To see all the functions in action the "tests" file that comes with the standard scripts should demonstrate how to use them. "tests" is a test suite for Yacas.

A Quick Introduction: Yacas As A Calculator

You are now ready to enter expressions. For instance, typing 2+3; will result in a prompt
In( 0 ) = 2+3;

Out( 0 ) = 5;

With each input line there is an associated output line. Try FullForm(a+b*c); and you will see the text (+ a (* b c )) appear on the screen. This is the 'internal representation' of the expressions, lists just like LISP.

The Linux version of Yacas has a command line similar to other scripting languages. It holds a history, so you can browse back to what you typed in.

The standard scripts already contain a simple math library for doing symbolic simplification:
In( 1 ) = 0+a;

Out( 1 ) = a;

In( 2 ) = 1*a;

Out( 2 ) = a;

In( 2 ) = Sin(ArcSin(a));

Out( 2 ) = a;

Yacas can deal with arbitrary precision numbers:
In( 3 ) = 20!;

Out( 3 ) = 2432902008176640000;

When dealing with floating point numbers, the command Precision(n);can be used to specify that floating point numbers should have n digits.

Analytic derivatives of functions can also be performed:
In( 4 ) = D(x) Sin(x);

Out( 4 ) = Cos(x);

In( 5 ) = D(x) D(x) Sin(x);

Out( 5 ) = -Sin(x);

Rational functions will stay rational as long as the numerator and denominator are integers, so 55/10; will evaluate to 11/2 . You can override this behaviour by using N : N(55/10) will evaluate to 5.5 .

And some very simple equation solving algorithms are in place:
In( 6 ) = Solve(a+x*y=z,x);

Out( 6 ) = (z-a)/y;

Currently Solve only deals with equations where the variable to be solved for only occurs once in the equation. In the future there will be more sophisticated algorithms.

Taylor series are supported. Typing
Taylor(x,0,3) Exp(x)
will result in 1+x+(1/2)*x^2 .

Variables

Yacas supports variables.There are two places where variables are stored, globally or locally. Variables default to global, unless specifically declared local (a variable var can be declared local with the function Local(var) ).

Try typing
Set(a,2);
and then
a;
The result will be 2 . The variable a has been globally set to 2. To clear the variable binding, just call Clear(a);. a; will now evaluate to a. This is one of the properties of the evaluation scheme of Yacas: when something can not be evaluated any further, it is returned as the final result.

The standard scripts offer the operator := for assigning values to variables (amongst other things), so the rest of this document will use := instead. The equivalent of Set(a,2); would in this case be a:=2;

Lists

Lists can be typed in using the { and } brackets. They evaluate the arguments, and return a list with results of evaluating each element. So, typing
{1+2,3};
would evaluate to {3,3}

The idea of using lists to represent expressions dates back to the language LISP, which was developed in the 70's. Together with a small set of operations on lists very powerful symbolic manipulation algorithms can be built. Lists can also be abused, when a variable number of arguments are expected. Lists are also used as a representation for vectors. This section will take a look at some of the operations on lists Yacas provides.

Lets take one variable and set it to a list:
In( n ) = m:={a,b,c};

Out( n ) = True;

In( n+1 ) = Length(m);

Out( n+1 ) = 3;

In( n+2 ) = Reverse(m);

Out( n+2 ) = {c,b,a};

In( n+3 ) = m;

Out( n+3 ) = {a,b,c};

In( n+4 ) = Concat(m,m);

Out( n+4 ) = {a,b,c,a,b,c};

In( n+5 ) = m[[1]];

Out( n+5 ) = a;

In( n+6 ) = Nth(m,2);

Out( n+6 ) = b;

These are only a small introduction of course. Consult the reference section to see more operations on lists.

List as vectors: Linear Algebra

Vectors are represented through lists. The list {1,2,3} would be a three-dimensional vector with components 1,2 and 3. Matrices are represented as a 'vector of vectors'.

Vector components can be assigned values usign the {{:=}} operator:
In( n ) = l:=ZeroVector(3);

Out( n ) = True;

In( n+1 ) = l;

Out( n+1 ) = {0,0,0};

In( n+2 ) = l[[ 2 ]]:=2;

Out( n+2 ) = True;

In( n+2 ) = l;

Out( n+2 ) = {0,2,0};

Yacas can perform matrix multiplications, multiplications of matrices with vectors, numbers, etcetera. The standard Yacas supplied scripts also support taking the determinant and inverse of a matrix, and solving linear sets of equations, solving A x = b for x, where A is a matrix, and x and b are vectors. There are several more matrix operations which are supported. See the reference for the full list.