Jupyter¶
Project Jupyter is an open-source project intended to support interactive scientific computing across numerous languages.
Documentation: https://jupyter.readthedocs.io/en/latest/
Tip
Scared of commitment? To try Jupyter without installation, click here.
Table of Contents
Jupyter Notebook¶
The Jupyter Notebook is an open-source web application which provides an interactive environment that smoothly integrates live code, images, equations, data visualization, interactive widgets, and text.
Note
Jupyter is not exclusive to Python - it supports over 40 languages, including R, Java, and MATLAB. IPython is the default kernel of Jupyter Notebook but other kernels can be installed to enable the use of other languages within Jupyter.
Check out the list of available kernels here.
LaTeX¶
Jupyter Notebooks can include inline and displayed mathematical equations written in LateX.
LaTeX is used to typeset mathematical notation in scientific documents.
- The Jupyter Notebook documentation has a brief section on LaTeX equations.
- For the basics of LaTeX, An Introduction to Using TeX in the Harvard Mathematics Department is a concise and useful reference written by R. Kuhn, R. Scott, and L. Andreev.
- A list of LaTeX Math Symbols prepared by L. Kocbach.
Example of use
In a Markdown cell,
The Nernst Equation is as follows $$E_x = \frac{RT}{zF}ln{\frac{[X]_o}{[X]_i}}$$ where $R$ is the gas constant, $T$ the temperature, $z$ the valence of the ion, $F$ the Faraday constant, and $[X]_o$ and $[X]_i$ the concentrations of the ion outside and inside the cell.
where $$
and $
indicate the start and end of a displayed and inline equation respectively.
This produces
The Nernst Equation is as follows
where \(R\) is the gas constant, \(T\) the temperature, \(z\) the valence of the ion, \(F\) the Faraday constant, and \([X]_o\) and \([X]_i\) the concentrations of the ion outside and inside the cell.
ipywidgets¶
ipywidgets are interactive HTML widgets that can be used to build GUIs within Jupyter Notebooks. Available widgets include buttons, sliders, textboxes, and checkboxes.
Hint
$ pip install ipywidgets
$ jupyter nbextension enable --py widgetsnbextension
To use:
import ipywidgets as widgets
Tools¶
nbconvert¶
nbconvert converts Jupyter Notebooks (.ipynb files) to other formats, including HTML and PDF.
Hint
Installing Jupyter (pip install jupyter
) also installs nbconvert. To use nbconvert from the
command line, enter the following command in the directory in which the notebook is stored.
$ jupyter nbconvert --to format notebook.ipynb
Replace format
wtih the desired format and notebook.ipynb
with the notebook file.
Tip
Saving as different formats is also possible within Jupyter. To see the available formats:
In Jupyter Notebook,
click on File then hover over Download as.
In Jupyter Lab,
click on File then hover over Export Notebook As….
Jupyter Lab¶
Jupyter Lab is the web-based user interface intended to replace Jupyter Notebook. It has all the classic features of its predecessor plus some cool new ones, most notably it offers a flexible and unified workspace that can include a code console, terminal, text editor, and Notebook.
Syzygy¶
Syzygy is a service provided by the Pacific Insittute for the Mathematical Sciences (PIMS), Compute Canada, and Cybera that launches Jupyter notebooks in a browser. It is accessed by logging in with a CWL through https://ubc.syzygy.ca/.
Note
Each user is allocated 1GB of space.