Sage Notebook Interface

From Norsemathology
Jump to navigation Jump to search

Sage Notebook Interface

Starting the Notebook Interface

To start the sage notebook interface type notebook() at the sage prompt. Then to access the interface open a web browser and go to the address http://localhost:8000.

Notebook Function Parameters

Below is a list of some of the common parameters to the notebook function. This list is not complete, but seeks to illustrate the more useful parameters available. For a full list of parameters type notebook? at a sage prompt. No parameters are required for the notebook function, and multiple parameters can be passed. Parameters should be separated with commas, and the order they are passed in doesn't matter.


The accounts parameter can be set to either True or False (The default is False). If accounts is set True a visitor to the site can create an account and login. If accounts is set to False only the admin user can create accounts.

Example Usage:

sage: notebook(accounts=True)


The port parameter specifies the port that the notebook server will listen on (The default is 8000).

Example Usage:

sage: notebook(port=9000)


The require_login parameter can be set to either True or False (The default is True). If require_login is set to True users will be required to login with a username and password. If require_login is set to False no login will be required to access the notebook interface. It is recommend to leave this parameter set to True.

Example Usage:

sage: notebook(require_login=False)


The reset parameter can be set to either True or False (The default is False). If reset is set to True the admin user's password can be reset. This should only be used when the admin password needs to be changed.

Example Usage:

sage: notebook(reset=False)


The secure parameter can be set to either True or False (The default is False). If secure is set to True all communication with the notebook interface goes through https, thus all logins and communication will be encrypted.

Example Usage:

sage: notebook(secure=True)

Evaluating Cells

Once you have entered in all the commands you want in a cell you can evaluate the cell by holding down control and pressing the enter key.

Auto Evaluate Cells

By default in Sage if you save a worksheet and then load it back up later the cells in that work sheet are not automatically evaluated. As a result the functions and variables defined in those cells will not be accessible until the cell is evaluated manually by pressing shift+enter. However it is often desirable to have a cell be evaluated automatically when the worksheet is opened. This can be done by putting #auto on the first line of the cell.

Installing the Tex Fonts

If you notice that some of the symbols such as do not display correctly it is likely due to the fact that the required Tex fonts are not installed on your system. To get the Sage fonts you can click on the JS Math logo at the bottom right hand corner of the screen in the worksheet window and click on options. In options you will see an option that says use native Tex fonts, and next to it there will be a download link. If you click on that link you will be taken to a page where you can download the fonts. The link is


If Firefox gives an error: 'JSMath: Failed Error Code: -7' this means that Firefox is unable to locate the Tex fonts required. To fix this issue extract all of the Tex fonts from jsMath to the folder /home/$username/.fonts where $username is your username.

Indenting Text in Cells

If you want to indent a section of text in a cell you can highlight the text you want to indent and press the tab key. If you want to un-indent text you can highlight the text and press shift+tab and the text will be unindented.

Tab Completion

Sage provides a nice auto-completion feature when working in the notebook interface. To trigger auto-completion press the tab key inside of a cell. There are two types of auto-completion the first is for example if you type the letter f into the cell and press tab you will get a blue box containing all the functions and classes starting with f that are available. The other type of tab completion is based on objects. So let's say you have a matrix variable named m and in a cell you type m. and then press the tab key, you will get a list of all the methods available for the variable m.

Referencing the Result of the Previous Cell

The result of the previous cell can be referenced using the _ character.


Cell 1:
x = 5
x + 7
Cell 2:
_ + 1
Output: 13

Creating an HTML cell

You may create an HTML cell by placing the cursor at the position where a new cell is desired and typing Shift+Click. This will bring up a text editor box. When finished be sure to click save before returning to the full notebook.