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.
- Windows installation: install Python then open "Command Prompt" from the Accessories menu. Input
the commands
python.exe -mpip install --upgrade pip
python.exe -mpip install
wheel
python.exe -mpip install giacpy
- Mac installation: install Xcas for Mac or seeF. Han's site
- Linux debian compatible installation:
sudo apt-get install python-giacpy OR
sudo apt-get install python3-giacpy.
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
- Windows: Easiest is to install 32-bit CodeBlocks, then unpack mingw giac 32 bits in the CodeBlocks/MinGW directory, then create a console project by adding the giacdll library to Settings, Compiler, Linker settings. Or modify thisexemple.
If you compile with cygwin, the DLLs are installed by the Xcas installer. Otherwise, you must use these DLLs:win32 dll, win64 dll
- Mac: install Xcas for Mac, the libraries and headers are in/Applications/usr/, launch Xcas and the menu Fich, create links to create links to /usr/local/.
Alternative, compile with -I/Applications/usr/include and -L/Applications/usr/lib (can compel to perform export LD_LIBRARY_PATH=/Applications/usr/lib)
- iOS: For Mac OS x.6, the giac library and header for iphone ARM7 and x86 simulator compiled with the version 0.39 of libtommath. For arm64, add giac's source files to your project, as well as those of tommath, copy config.h.iphone to config.h and modify the defines for 64-bit code.
- Linux: The easiest way on a supported Debian distribution (debian, ubuntu, ...) is to install thegiac debian package or else to follow the debian/ubuntu quick guide. You may then need to install missing header files, with commands like
sudo apt-get install libgmp-dev libao-dev
- On other systems, you must install Giac from the source.
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 by
g++ 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
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.