FriCAS Installation

Default installation

FriCAS comes with an Installation Guide of how to compile/install it from the official FriCAS release. Unfortunately, this binary distribution does not work nicely together with jFriCAS (which is the Jupyter interface of FriCAS). Although QEta would work perfectly with that distribution, we recommend another way to install FriCAS.

(optional) jFriCAS installation

jFriCAS is the Jupyter notebook interface to FriCAS. Of course, jFriCAS needs Jupyter in a reasonably recent version (at least 4).

Install prerequisites if not yet available (needs root access, but it may already be installed on your system).

sudo apt install python3-pip python3-venv

Prepare directories and download jfricas.

FDIR=$HOME/fricas
mkdir -p $FDIR/venv
cd $FDIR
git clone https://github.com/hemmecke/jfricas

Install prerequisites, Jupyter and jfricas.

python3 -m venv $FDIR/venv/jfricas
source $FDIR/venv/jfricas/bin/activate
pip3 install wheel jupyter
cd $FDIR/jfricas
pip3 install .
jupyter kernelspec list

The output of the last command should show something similar to the following.

Available kernels:
  jfricas     /home/hemmecke/fricas/venv/jfricas/share/jupyter/kernels/jfricas
  python3     /home/hemmecke/fricas/venv/jfricas/share/jupyter/kernels/python3

Create the script jfricas.

cat > $FDIR/usr/local/bin/jfricas <<EOF
source $FDIR/venv/jfricas/bin/activate
jupyter notebook \$1
EOF
chmod +x $FDIR/usr/local/bin/jfricas

Start a new terminal or set the PATH on the commandline like above and start jfricas from any directory. Note that inside jupyter the place from where you start jfricas is the place where your notebooks will be stored.

If you want to enjoy nice looking output, then type the following inside a notebook cell.

)set output algebra off
setFormat!(FormatMathJax)$JFriCASSupport

You can go back to standard 2D ASCII output as follows.

)set output formatted off
)set output algebra on

(optional) Install JupyText

Ordinary Jupyter notebooks use a special format in order to store their content. They have the file extension .ipynb. It is an incredible feature to be able to load and store notebooks as ordinary FriCAS .input files. You can even synchronize between the .ipynb and .input formats.

There are two types of cells in Jupyter Markdown documentation cells and execution cells. With the help of JupyText, Markdown cells will appear inside an .input file as FriCAS comments and execution cells appear without the "-- " comment prefix.

source $FDIR/venv/jfricas/bin/activate
pip3 install jupytext

If $HOME/.jupyter/jupyter_notebook_config.py does not yet exist, generate it. Note that this is outside the $FDIR directory.

jupyter notebook --generate-config

Make Jupytext available.

sed -i 's|^# *c.NotebookApp.contents_manager_class =.*|c.NotebookApp.contents_manager_class = "jupytext.TextFileContentsManager"|;s|^# *c.NotebookApp.use_redirect_file = .*|c.NotebookApp.use_redirect_file = False|' $HOME/.jupyter/jupyter_notebook_config.py

Enable the spad language and set the respective parameters.

cd $HOME
J=$(find $FDIR/venv -type d | grep '/site-packages/jupytext$')

Edit the file $J/languages.py and change appropriately.

#+BEGIN_ASCII
# Jupyter magic commands that are also languages
_JUPYTER_LANGUAGES = ['spad', "R", ...]

# Supported file extensions (and languages)
# Please add more languages here (and add a few tests) - see CONTRIBUTING.md
_SCRIPT_EXTENSIONS = {
   ".py": {"language": "python", "comment": "#"},
    '.input': {'language': 'spad', 'comment': '--'},
    '.input-test': {'language': 'spad', 'comment': '--'},
    ...
}

Put the following input into the file $FDIR/foo.input.

-- # FriCAS demo notebook

)set output algebra off
setFormat!(FormatMathJax)$JFriCASSupport

-- Here we compute $\frac{d^2}{dx^2} sin(x^3)$.

D(sin(x^3),x,2)

-- We compute the indefinite integral $\int \sin x \cdot e^x dx$.

integrate(exp(x)*sin(x), x)

Then start via jfricas, load foo.input and enjoy.

cd $FDIR
jfricas

You can also download or clone the demo notebooks from https://github.com/fricas/fricas-notebooks/ and compare them with what you see at FriCAS Demos and Tutorials.

(optional) Install frimacs

frimacs is an Emacs mode for FriCAS with special features to edit .input and .spad files as well as executing a FriCAS session inside an Emacs buffer.

Install as follows.

cd
git clone https://github.com/pdo/frimacs.git

Then add the line

(load-file "/home/hemmecke/frimacs/frimacs.el")

to your .emacs or .emacs.d/init.el file.

To start a FriCAS session use

M-x run-fricas