XCAS
Logiciel libre de calcul formel
Forum Educational resources
Giac

Xcas and the different programming languages

In this section you will find all the specific documents for the different languages compatible with Giac.

CAS inside Julia

First install Giac/Xcas on your Linux distribution then the interface created by Harald Hofstaetter, by typing in a Julia shell
using Pkg
Pkg.add(PackageSpec(url="https://github.com/parisseb/Giac.jl"))

After install type using Giac to access Xcas commands from Julia. More infos here.

Computer Algebra with Python

Frédéric Han has developed a Python interface for giac, giacpy for Windows, Mac OS and Linux. It provides access to all the features and performance of Giac/Xcas from the Python language (version 2.7, 3.2 or 3.3): an essential complement for students in preparatory classes who want to do computer algebra using the program language.

Example of commands: launch the python interpreter then input:

from giacpy import *
ifactor(2**128+1)
x=giac('x')
f=factor(x**10-1)
d=plot(sin(x))
d.qcas()
help("giacpy")
normal.help()

Example Python program using giac and giacpy: ocapy by Didier Gosseau, an RPN calculator.

Write a C++ program using Giac

The source code of giac contains a directory examples/demo with a test program pgcd.cc which will allow you to test that your installation irs correct (to be compiled byg++ pgcd.cc -lgiac , it may be necessary to add -lgmp).
You then have to consult the documentation information of giac to know the data structures of giac (in particular the type gen).

Giac in Javascript

There are several interfaces using Giac compiled in Javascript:

Xcas for Firefox Xcas blackboard Simple CAS Calculator

To use Giac in your own Javascript projects, you can get the file giacjs.tar.gz or use the command
npm install "https://www-fourier.univ-grenoble-alpes.fr/~parisse/giacjs.tar.gz"

Finally, you can find other documents for javascript by clicking on this link.

Giac and Latex

There are several methods to call giac automatically from a LaTeX document and delegate certain calculations to it.
  • Compiling LaTeX to computer algebra enabled HTML5 explains how you can add Xcas commands to a LaTeX document to compile it in HTML+MathML with a good rendering of the mathematical formulas and the possibility for the reader to modify and execute the commands from his browser. You can also obtain a PDF file with the calculations (and graphs) made during compilation.
  • Under Linux, the program giac (or icas) can "filter" latex files to generate HTML5 code and PDF with calculations and graphics performed by giac's computer algebra engine (this is inspired by Jean-Michel Sarlat's pgiac described below). You must have hevea and pdflatex installed. Just type in a terminal
    giac nom_fichier
    instead of pdflatex nom_fichier (put the .tex extension in case of file name conflict). giac filters the calculations, performs them, creates EPS of the 2d graphics, then giac calls hevea -fix to generate HTML5 (to be consulted from Firefox for optimal performance) and pdflatex to generate the PDF.
    The calculations are placed in a normal .tex file where we put (just after \begin{document}) \begin{giacjsonline} and (just before \end{document}) \end{giacjsonline}. To make a calculation or a graph, we use a command of the type \giacinputbigmath{factor(x^4-1)} or \giacinput{plot(sin(x))}. The reader can modify and/or execute the order in their compatible browser (Firefox recommended). View file testfr.tex for typical examples of commands or methnum.tex for full-scale use.
  • professor.sty is a collection of style files for automatically creating variation tables, statistics, etc. in your LaTeX documents. By Denis Le Fur and Guillaume Connan (contains the famous tablor.sty by Guillaume Connan). Usable from texmacs via plugins professor and tablor by E. Corcelle.
  • the Perl script pgiac of J.M. Sarlat makes it possible to create sources .w containing commands giac (lines beginning with .g and sections beginning with .g: and ending with .end), transformed after calculations into files .tex by command pgiac nom_fichier.w. All you have to do is compile it with your preferred LaTeX distribution, cf. the website Syracuse.
  • see also examples of LaTeX source using giac for calculations of G. Connan, of Yves Delhaye (see also its query generator), and of Alexandre Boisseau

Giac/Xcas (c) 2022 B. Parisse, R. De Graeve, Institut Fourier, Université de Grenoble. Ce site est fourni aux conditions de la GFDL (Gnu Free Documentation Licence).

Remerciements à Elie Carrot, Eliott Dokenoo et Zexi Ru dont le travail sur le site web de Xcas a inspiré le design de cette page.