# Difference between revisions of "SageMath"

Kynikos.bot (talk | contribs) (Template:i18n is deprecated, use interlanguage links, see Help talk:I18n#"Dummy" interlanguage links and deprecation of Template:i18n) |
m (Updated CTAN link.) |
||

Line 74: | Line 74: | ||

* you can have a look at your output document. | * you can have a look at your output document. | ||

− | The full documentation of SageTeX is available on [http:// | + | The full documentation of SageTeX is available on [http://www.ctan.org/pkg/sagetex CTAN]. |

====Troubleshooting==== | ====Troubleshooting==== |

## Revision as of 17:24, 28 June 2012

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.

## Contents

## Installation

**Note:**With version 4.8, the package sage-mathematics

^{AUR}has been temporarily moved back to the AUR. Consider a compile- and build-time up to 4+ hours, depending on the performance of your system.

To install binaries from community repository:

# pacman -S sage-mathematics

## Usage

### Sage-Commandline

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 4

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()

### Sage-Notebook

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

$ sage -n

The notebook will be accessable 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."

### Cantor

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.

### Documentation

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 http://www.sagemath.org/doc/ .

## Optional additions

### SageTeX

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

\usepackage{sagetex}

- create a sagesilent environment in which you insert your sage code:

\begin{sagesilent} 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') ptot=p1+p2 ptot.axes_labels(['$\\xi$','$\\frac{R_h}{\\max(a,b)}$']) \end{sagesilent}

- create the plot e.g. inside a float environment:

\begin{figure} \begin{center} \sageplot[width=\linewidth]{ptot} \end{center} \end{figure}

- 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.

#### Troubleshooting

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.