Skip to content

arvidl/sagemath-examples

Repository files navigation

sagemath-examples

SageMath is built out of nearly 100 open-source packages and features a unified interface. SageMath can be used to study elementary and advanced, pure and applied mathematics. This includes a huge range of mathematics, including basic algebra, calculus, elementary to very advanced number theory, cryptography, numerical computation, commutative algebra, group theory, combinatorics, graph theory, exact linear algebra and much more. It combines various software packages and seamlessly integrates their functionality into a common experience. It is well-suited for education and research. The user interface is a notebook in a web browser or the command line. Using the notebook, SageMath connects either locally to your own SageMath installation or to a SageMath server on the network. Inside the SageMath notebook you can create embedded graphics, animations and artwork, interactions, beautifully typeset mathematical expressions, add and delete input, and share your work across the network.

A.L @ MMIV-ML, 2024-05-04

Using SageMath 10.3 (see 01-sagemath-example.ipynb for more info)

logo

More info:

See the ´01-sagemath-example.ipynb` for illustration

Notebook 1-Click Notebook
01-sagemath-example.ipynb
Exploring SageMath 10.2 with Python 3.11, toolboxes, interactions and R 4.2
Google Colab

SageMath 10.2 (sage-build)

build is done in /home/arvid/SW/Sage-10.2 (or /Users/arvid/SW/Sage-10.2) and the sagemath kernel will be located in

  • Ubuntu: /home/arvid/anaconda3/envs/sage-build/share/jupyter/kernels/sagemath
  • MacOS: /Applications/SageMath-10-2.app/Contents/Frameworks/Sage.framework/Versions/10.2/venv/share/jupyter/kernels/sagemath

In ~/SW/Sage-10.2 do:

  • if Ubuntu:
git clone --branch master https://github.com/sagemath/sage.git
./bootstrap-conda
conda env create --file environment-3.11.yml --name sage-build
conda activate sage-build
./configure --with-python=$CONDA_PREFIX/bin/python --prefix=$CONDA_PREF
make -j8
sudo ln -sf $(pwd)/sage /usr/local/bin
coda deactivate   # into (base)
  • if MacOS:

Check: https://github.com/3-manifolds/Sage_macOS/releases
See SageMath 10.3 - v2.3.1
and install SageMath-10.3_x86_64.dmg or SageMath-10.3_arm64.dmg

Make ~/SW/Sage-10.3:

cd ~/SW/Sage-10.3

In ~/SW/Sage-10.3 do:

git clone --branch master https://github.com/sagemath/sage.git
cd sage
./bootstrap-conda
conda env create --file environment-3.11-macos.yml --name sage-build-10-3
conda activate sage-build-10-3

Install sagemath kernel

Ubuntu:

jupyter kernelspec install --user $(sage -sh -c 'ls -d /home/arvid/anaconda3/envs/sage-build/share/jupyter/kernels/sagemath') --name sagemath-10.2

MacOS: in (base) environment

jupyter kernelspec install --user $(sage -sh -c 'ls -d /Applications/SageMath-10-3.app/Contents/Frameworks/Sage.framework/Versions/10.3/venv/share/jupyter/kernels/SageMath-10.3') --name sagemath-10.3

gives:

[InstallKernelSpec] WARNING | Config option `kernel_spec_manager_class` not recognized by `InstallKernelSpec`.
[InstallKernelSpec] Installed kernelspec sagemath-10.3 in /Users/arvid/Library/Jupyter/kernels/sagemath-10.3

Additional R-packages (R-4.4.0):

Installing R-packages

sage -R

> install.packages("lme4")
> install.packages("ggplot2")
> install.packages("ggthemes")
> install.packages("caret")

For MacOS, possibly:

> install.packages(c('repr', 'IRdisplay', 'pbdZMQ', 'devtools'))

Additional Python-packages:

To install a python package or library, say Pandas or Jupyterlab in the SageMath 10.2 kernel:

sage --pip install <package>

e.g.

> sage --pip install pandas
> sage --pip install jupyter
> sage --pip install jupyterlab
> sage --pip install mathjax
> sage --pip install seaborn
> sage --pip install igraph
> sage --pip install manim
> sage --pip install scikit-learn
> sage --pip install networkx
> sage --pip install jupyter-ai
> sage --pip install jupyter_ai
> sage --pip install openai
> sage --pip install rpy2
> sage --pip install gspread
> sage --pip install oauth2client   # Google sheet API
> sage --pip install jason
> sage --pip install requests
> sage --pip install jupyter-collaboration
> sage --pip install jupyterlab_rise  # turn your Jupyter Notebook into a slideshow

If Ubuntu: rpy2 is installed in the sage-build environment:

conda activate sage-build
conda install rpy2

Start Jupyter Notebook (7.0) or Jupyter Lab from sage:

sage -n jupyter

or

sage -n jupyterlab

About

Sage examples

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published