From ArchWiki
Revision as of 12:16, 19 September 2012 by Freso (Talk | contribs) (Sage-Notebook: Fixing typos/spelling mistakes.)

Jump to: navigation, search

Sage is a program for numerical and symbolic mathematical computation. It is meant to provide an alternative for commercial programs such as Maple, Matlab, and Mathematica. It is actually mantained in the community repository.


To install binaries from community repository:

# pacman -S sage-mathematics



Once installed, users should be able to start the sage commandline in bash.

$ sage

Math can then be typed at this commandline.

sage: 2+2

Note, however, that the CLI is not very comforable for certain purposed. For instance, if you plot a function,

sage: plot(sin,(x,0,10))

this is opened in a browser window. In these cases, you can start the notebook server by

sage: notebook()


To start the Sage-Notebook server from bash, without going through Sage-Commandline:

$ sage -n

The notebook will be accessible in the browser from http://localhost:8000 , and will require you to login. However, If you are only intending to run the server for personal use, and not across the internet, the login will be an annoyance.

You can instead start Sage notebook without requiring login, and have it automatically pop up in a browser.

$ BROWSER="chromium" sage -c "notebook(require_login=false,open_viewer=true)"

More detailed documentation can be read about the "notebook() command."


The KDE Education Project includes a package called Cantor which acts as a front-end for several pieces of mathematical software including Sage. See: "Sage Wiki - Cantor page" "KDEEdu - Cantor page"

You can install it with:

$ pacman -S kdeedu-cantor

or along with the 'kde' or 'kdeedu' groups.


For local Documentation, one can compile it into html or even pdfs. Apparently, this needs to be executed as root (perhaps unsafely):

# sage -docbuild reference html

This builds html docs for the whole tree "reference" (which is alot; Expect many many hours). An option is to build a smaller part of the documentation tree, but you would need to know what it is you want. Until then, you might consider just browsing reference online. One place this can be found is at .

Optional additions


If you have installed Texlive on your system, you may be interested in using SageTeX, a package that makes possible the inclusion of sage code in LaTeX files. Starting from version 4.6.1-3, Texlive is made aware of SageTeX automagically, and you can start using it straight away.

As a simple example, here is how you include a Sage 2D plot in your latex document (assuming you use pdfLaTeX):

  • include the sagetex package in the preamble of your document with the usual
  • create a sagesilent environment in which you insert your sage code:
dob(x) = sqrt(x^2-1)/(x * arctan(sqrt(x^2-1)))
dpr(x) = sqrt(x^2-1)/(x * log( x + sqrt(x^2-1)))
p1 = plot(dob,(x,1,10),color='blue')
p2 = plot(dpr,(x,1,10),color='red')
  • create the plot e.g. inside a float environment:
  • compile your document with the following procedure:
$pdflatex <doc.tex>
$sage <doc.sage>
$pdflatex <doc.tex>
  • you can have a look at your output document.

The full documentation of SageTeX is available on CTAN.


If your Texlive installation does not find the sagetex package, you can try the following procedure (do it as root, or with sudo, or use a local folder):

  • Copy the files to the texmf directory:
# cp /opt/sage/local/share/texmf/tex/* /usr/share/texmf/tex/
  • Refresh Texlive:
# texhash /usr/share/texmf/
texhash: Updating /usr/share/texmf/.//ls-R... 
texhash: Done.

Additional Packages

If you need to compile your own custom packages in addition to the standard ones, you might need to install aur/sage-mathematics-spkgs so that you will have the spkgs of the original packages.