\documentclass{article}
\begin{document}
\section{Installation}
Insure that you have installed GMP, FLTK, optionnaly GSL, NTL and PARI 
and you that have a recent version  of {\tt gcc} (e.g. 2.95, 2.96, note
that GCC 3.0 will compile GMP but not FLTK AFAIK).
Then~:\\
{\tt tar xvfz giac-0.2.2.tar.gz}\\
{\tt cd giac-0.2.2} \\
{\tt ./configure --enable-fltk-support --enable-debug-support} \\
{\tt make}\\
Now become {\tt root}:\\
{\tt su}\\
and eventually~:\\
{\tt make install}

\section{Using the {\tt cas} command.}
You can invoke {\tt cas} directly from the command line (in an {\tt xterm}
window for example). But (except for very simple input) you must
quote the arguments so that the shell does not interpret badly parentheses
or {\tt *}, ....
For example~:
\verb|cas 'factor(x^3-1)'|\\
Or you can call \verb|factor| as a command, like~:\\
\verb|factor x^3-1|\\
Note that you don't require quote here since argument can not be interpreted
by the shell.

You can also put a filename instead of an argument. Then all commands
in this filename will be executed. For example, using your favorite
editor (e.g. emacs) create a file named {\tt test} containing:
\begin{verbatim}
factor(x^100-1);
rref([[1,2,3],[4,5,6]])
\end{verbatim}
(note that you don't have to quote inside a file) and run~:\\
{\tt cas test}

If you want to assign variables a value, just make a file having the
variable name with the value of the variable in the file. For example, edit a
file named {\tt mat}, write {\tt [[1,2,3],[4,5,6]]}, save the file
and try one of the following command~:\\
{\tt cas 'ker(mat)'}\\
{\tt ker mat}

You can store the result of a {\tt cas} command using the usual redirection
symbol, for example~:\\
{\tt ker mat > kermat}
will create a file named {\tt kermat} that you can use as a variable name
later. You can also pipe the result of a command as argument of 
another command, e.g.~:\\
\verb?gcd x^4-1 x^6-1 | factor?

The syntax is as similar as possible to usual CAS (especially HP49/40G CAS). 
Vectors are delimited by {\tt [ ]} and coordinates are separated by {\tt ,}.
Matrices are vectors of vectors.

If you want to know how much time was needed to evaluate your cas query,
just define the environment variable \verb|SHOW_TIME|, if your shell is
\verb|tcsh|~:\\
\verb|setenv SHOW_TIME 1|\\
will define the environment variable and\\
\verb|unsetenv SHOW_TIME|\\
will undefine it. With \verb|bash|,\\
\verb|export SHOW_TIME=1|\\
defines the variable and\\
\verb|unset SHOW_TIME|\\
undefines the variable.

Currently implemented~:
\begin{enumerate}
\item usual arithmetic on integers, reals, complex, vectors and matrices:
{\tt abs},  {\tt arg},  {\tt conj},
{\tt evalf},  {\tt im}, {\tt inv},  {\tt max}, {\tt min}, 
{\tt re}, {\tt sign},  {\tt sqrt}.
For the usual operations, since {\tt *} is interpreted by the shell, 
you must quote {\tt '*'} or escape \verb|\*| the multiplication symbol. 
For division, I use currently the quoted or escaped symbol {\tt \%}, this
is likely to change.
\item more advanced arithmetic: {\tt cyclotomic}, {\tt egcd}, {\tt gcd}, 
{\tt ichinrem}, {\tt iquo}, {\tt irem}, \verb|is_prime| (returns 2 if
certainly prime, 0 if not prime, 1 if probably prime), 
{\tt nextprime}, {\tt prevprime}, {\tt jacobi}, {\tt legendre}, {\tt smod}.
\item transcendental functions: {\tt acos}, {\tt acosh}, {\tt alog},  
{\tt asin}, {\tt asinh}, {\tt atan}, {\tt atanh}, 
{\tt cos}, {\tt cosh}, {\tt exp}, {\tt Log}, {\tt log10},  
{\tt sin}, {\tt sinh}, {\tt tan}, {\tt tanh}. 
\item polynomial functions: {\tt normal}: rational simplification \\
{\tt factor}: factorization over the integers or Gau\ss\ integers\\
{\tt partfrac}: partial fraction expansion \\
{\tt resultant}: resultant of 2 polynomials \\
{\tt solve}: solving polynomial-like equations
\item rewriting functions: {\tt fdistrib} (full distribute $\times$ over $+$)\\
 {\tt simplify}: currently rational simplification only \\
{\tt texpand}, {\tt tlin}: trigonometric expansion and linearization
\item calculus: {\tt derive}: derivation\\
{\tt lim}, {\tt series} : limits and series expansion \\
{\tt integrate}: integration of rational fractions
\item linear algebra: {\tt rref}, {\tt ker}, {\tt image}, {\tt det}, 
{\tt pcar}, {\tt trace}, {\tt tran}, {\tt egv}, {\tt egvl}, 
{\tt jordan}.
\item conversion functions: {\tt e2r} (entier to rational) and
{\tt r2e} (rational to entier). They expect a list of variables with
respect to which the expression should be a rational fraction, you can
use {\tt lname} or {\tt lvar} to get this list. The internal format
for rational fractions is parsed directly from the command line:
\begin{itemize}
\item integers, Gau\ss\ integers: usual notation ({\tt 2}, {\tt 3-5*i})  
\item dense univariate polynomial: like a vector with coefficients
by descending power ({\tt [1,2,3]} for $x^2+2x+3$) 
\item sparse univariate polynomial and series expansion: a sum of
monomials, each monomial is a couple of coefficient and exponent separated
by {\tt ,}, e.g. {\tt \{1,1/2\}+\{2,3\}} for $x^{1/2}+2x^3$. For
a series expansion, use {\tt undef} as coefficient for the remainder
term.
\item sparse multivariate polynomials: same notation, but the second
term of the couple is a vector of indices, the powers of the variables
in the monomial, e.g. {\tt \{ 2,[1,3]\} }, for the 2-d polynomial
$2xy^3$ with respect to the list of variables $[x,y]$.
\item (internal) algebraic extension objects. Similar notation, but
use {\tt :} instead of {\tt ,}. The first term of the couple is a
polynomial with respect to an algebraic integer $\theta$, defined by the second
term of the couple. This second term might be the minimal polynomial
of $\theta$ or another extension with as first term an approximate
value or an index and second term the minimal polynomial in order to
differentiate the different roots of the minimal polynomial. The
minimal polynomial is a dense univariate polynomial.
For second order extension, there are only two models of monic minimal
polynomials used: $x^2-d$ if $d \neq 1 \pmod 4$ and $x^2-x=\frac{d-1}{4}$
otherwise and by convention $\theta=\sqrt{d}$ in the first case
or $\theta=\frac{1+\sqrt{d}}{2}$. This to insure that every monic polynomial
of second order can be factored over such an extension without introducing
fractions.
\item Fractions: using the {\tt /} division sign.
\end{itemize}
\end{enumerate}

A somewhat more complex example~:\\
\verb? ( sin x ; tan x ) | \% | lim?\\
We first compute $\sin(x)$ and $\tan(x)$, then we pipe both answer to the
division function and pipe the result to the limit function.
This is equivalent to~:\\
\verb|lim 'sin(x)/tan(x)'|\\
but it demonstrates how it is possible to build expressions using the
shell syntax: the shell is used as a polish notation calculator with
mixed syntax (infix for sin and tan, reverse polish notation when we pipe).
This gives some flexibility to make small programs using the shell.

A final example: open a file {\tt testjordan} and write~:
\begin{verbatim}
[[1,1,-1,2,-1],\
 [2,0,1,-4,-1],\
 [0,1,1,1,1],\
 [0,1,2,0,1],\
 [0,0,-3,3,-1]]
\end{verbatim}
then write the command~:\\
{\tt ( jordan testjordan ; cas p j ) | sto }\\
or {\tt cas 'sto(jordan(testjordan),[p,j])'}
that will compute the Jordan decomposition of the matrix and store the
passage matrix in {\tt p} and the Jordan normal form in {\tt j}.
If you want to check that $p j p^{-1}$ is the original matrix,
you can write the following command~:\\
\verb?cas p j 'inv(p)' | \* | normal ?\\
or {\tt cas 'normal(p*j*inv(p))'}

\section{\TeX\ translation}
The \LaTeX\ translation of the commands are logged in the file 
{\tt session.tex} in the current directory except when you set the
\verb|SHOW_TIME| environment variables. They require a preamble that
you can copy from the file {\tt doc/preamble.tex}.

Note that every new command is appended to {\tt session.tex}, it is
a good idea to remove this file from time to time.

You can translate formulas in \LaTeX\ using the {\tt cas2tex} command
and get directly a compilable \LaTeX\ source file.
For example~:\\
{\tt cas2tex '[[1,2],[3,4]]' > essai.tex}\\
followed by~:\\
{\tt latex essai.tex}\\
Or in one step~:\\
{\tt cas2tex '[[1,2],[3,4]]' | latex --}\\
(this produces the file {\tt texput.dvi})

\section{Programming in C++}
First example~:
\begin{verbatim}
#include <giac/giac.h>
using namespace std;
using namespace giac;

int main(){
  gen e(string("x^2-1"));
  cout << factor(e) << endl;
}
\end{verbatim}
Write this as {\tt essai.cc} and compile it~:\\
{\tt g++ -g essai.cc -lgiac -lgmp}\\
and run it~:\\
{\tt ./a.out}

\subsection{Organization of the source code}
Note that you can use \verb|#include <giac/giac.h>| to include all headers
of the library.
\begin{itemize}
\item \verb|gen.cc/.h|: arithmetic operations on the base class entier
\item \verb|identificateur.cc/.h|: global name 
\item \verb|unary.cc/.h|: unary operators class including non unary operations
viewed as unary operation on the vector of it's arguments
\item \verb|symbolic.cc/.h|: symbolic object class
\item \verb|usual.cc/.h| Usual unary operations 
\item \verb|vecteur.cc/.h|: linear algebra
\item \verb|derive.cc intg.cc lin.cc series.cc subst.cc/.h|: Calculus.
Derive is OK as well as rational fraction integration, the rest has 
to be implemented
\item \verb|moyal.cc/.h|: pseudo-diff operators
\item \verb|tex.cc/.h|: \LaTeX\ conversion
\item \verb|sym2poly.cc/.h|: conversion polynomials to symbolic
\item \verb|index.cc/index.h|: class for indexation of multivariate tensors
\item \verb|poly.h, monomial.h|: multivariate template class tensors
\item \verb|gausspol.cc/.h|: specialization of template tensors 
to entier coeffs
\item \verb|input_parser.yy input_lexer.ll input_lexer.h|: parser 
\item \verb|modpoly.cc/.h|: univariate dense polynomials over integers 
and modular integers (Warning: gcd-like functions do not work if non 
modular arithmetic)
\item \verb|modfactor.cc/.h|: 
factorization of univariate dense square-free polynomials
(Requires NTL or PARI for lll and knapsack to be full speed functional)
\item \verb|series.cc/.h|: 
series expansion and limits using the mrv algorithm.
\end{itemize}

See {\tt giac.texinfo} for a short description of the classes available.
Some examples of programs are provided: {\tt src/factor.cc}, 
{\tt src/normalize.cc},
{\tt src/cas.cc}, {\tt src/partfrac.cc} and {\tt src/integrate.cc}.
To compile these programs, you can either use~:\\
\verb|g++ -g |{\em name.cc\/} \verb| -lgmp -lgiac|\\
or launch \verb|emacs| and run it's compile command (menu Tools).

\end{document}