SageMath
SageMath is a free and open-source mathematics software system designed as a comprehensive alternative to proprietary tools such as Magma, Maple, Mathematica, and MATLAB, providing a unified platform for research and teaching in various mathematical domains.[1] Initiated by mathematician William Stein in 2004 and first released in 2005, it combines a core library of unique mathematical algorithms with interfaces built primarily in the Python programming language.[1] Licensed under the GNU General Public License version 2 or later (GPLv2+), SageMath emphasizes community-driven development and openness, supporting areas including algebra, geometry, number theory, cryptography, numerical computation, combinatorics, graph theory, and group theory.[2][3] SageMath integrates over 250 established open-source software packages, such as GAP, Maxima, and PARI/GP, to leverage their specialized functionalities while offering a consistent Python-based interface that simplifies workflows across disciplines.[4] It provides multiple access methods, including a command-line interface, a web-based notebook environment, and embedding capabilities in LaTeX documents via the SageTeX package, enabling seamless incorporation into academic writing and presentations.[1] The system's modular design allows users to extend its capabilities through Python scripting, fostering reproducibility in computational mathematics and supporting both interactive exploration and large-scale simulations.[2] Developed collaboratively by over 700 contributors worldwide, SageMath has seen numerous releases, including over 70 stable versions, with the latest stable version 10.7 issued on August 9, 2025, encompassing approximately 600 MB of source code.[5][1] Its impact is evidenced by citations in over 500 academic papers and an active user base exceeding 30,000 on platforms like CoCalc, an online computational environment.[1] As a flagship project in open-source scientific computing, SageMath promotes accessibility and peer-reviewed enhancements, including participation in the Google Summer of Code 2025, making advanced mathematical tools available without licensing restrictions.[6]History and Development
Origins and Founding
SageMath was founded in 2005 by William A. Stein, then a mathematician at Harvard University, as an open-source alternative to proprietary mathematical software systems such as Magma, Maple, Mathematica, and Matlab.[7] Stein, who had previously contributed to the development of key components in Magma, sought to address the limitations of commercial tools that restricted accessibility for students and researchers due to high licensing costs and restrictive terms.[8] His vision was to create a unified, free platform that integrated existing open-source mathematical libraries, enabling seamless computation across diverse areas without the need for multiple paid subscriptions.[9] The initial motivations stemmed from Stein's frustrations encountered during his research in number theory and algebraic geometry, where proprietary software hindered collaboration and reproducibility.[10] He aimed to build a system that was not only cost-free but also extensible by users, drawing on his experience with closed-source development to prioritize openness from the outset. Early development focused on wrapping high-quality open-source packages like PARI/GP, GAP, and Maxima into a cohesive interface, with the first prototype released in September 2005 and the initial version 0.1 on February 24, 2005.[7] Funding for the project's inception came from an NSF grant (DMS-0400386) awarded to Stein, supplemented by his personal resources to bootstrap development.[7] This support enabled the acquisition of computational hardware and initial coding efforts, laying the groundwork for SageMath's growth into a comprehensive tool accessible to the global mathematical community.[11]Key Milestones and Releases
SageMath's development has progressed through numerous releases since its inception, with stable versions marking significant advancements in functionality and usability. The first stable release, version 1.0, arrived in February 2006, establishing a foundational system that integrated core open-source mathematical libraries into a cohesive Python-based environment.[12] Subsequent releases built on this base, with version 4.0 launched on May 29, 2009, delivering enhanced stability through refined dependency management and bug fixes across algebraic and numerical components.[13] By 2020, version 9.0, released on January 1, introduced seamless integration with Jupyter notebooks, enabling interactive workflows that aligned SageMath more closely with modern computational practices.[14] Version 10.0, released in May 2023, introduced support for Drinfeld modules, with applications in number theory and cryptography.[15] The most recent stable release, version 10.7, was issued on August 9, 2025, incorporating improvements in numerical stability for floating-point operations and new algorithms for graph theory applications, such as enhanced shortest-path computations.[16] Beta testing for version 10.8 began in August 2025, with the beta9 pre-release on November 11, 2025 (following beta8 on October 27), allowing developers to evaluate upcoming features like refined package handling before the anticipated stable rollout. As of November 2025, version 10.8 remains in beta.[17][18] Key milestones include SageMath's participation in the Google Summer of Code program starting in 2008, which has fostered contributions from over 100 students across multiple years, accelerating feature development.[19] In 2015, the project saw the incorporation of SageMath, Inc., providing a structured entity for funding and commercialization efforts while maintaining open-source principles.[20] A pivotal shift occurred in 2023 with the migration to GitHub for version control, streamlining collaboration through pull requests and issue tracking for the community's distributed efforts.[21] Architecturally, SageMath has long relied on SPKGs (Sage Packages) to simplify the integration of external libraries, allowing users to install dependencies like GAP or Maxima via simple commands without manual configuration.[4] This approach, refined over releases, ensures compatibility and ease of extension, supporting the system's modular design.Features and Architecture
Core Language and Interface
SageMath is built primarily on the Python programming language, extending its syntax to facilitate mathematical computations through a specialized preparser that transforms user input into valid Python code compatible with Sage's mathematical structures.[22] This preparser enables intuitive notation, such as treating1/2 as a rational fraction Integer(1)/Integer(2) rather than a floating-point number, and supports symbolic variable declarations like x = var('x') followed by expressions such as f = x^2 + 1 to create symbolic functions.[22][23] Users interact with Sage in a Pythonic environment where standard Python constructs, including loops, conditionals, and object-oriented programming, are fully available, augmented by Sage-specific enhancements for mathematical precision and expressiveness.[24]
SageMath offers multiple user interfaces to accommodate different workflows, with Jupyter notebooks serving as the default since version 8.0, providing an interactive environment that integrates code execution, textual explanations, and graphical outputs in a unified format.[25] The command-line interface allows direct REPL (read-eval-print loop) access for scripting and quick computations, while legacy graphical options like SageNB offer a web-based notebook for more visual exploration.[26] Additionally, the SageCell server provides a lightweight, browser-based interface for executing short Sage code snippets online without local installation, ideal for testing or sharing computations.[27]
Key syntax features include support for literate programming within notebook interfaces, where users can interweave executable code, narrative text, and results, and automatic coercion between data types to ensure consistent operations across mathematical domains.[28][29] For instance, adding an integer polynomial p = 2*x + 3 to a rational q = 1/2 automatically coerces to a polynomial over the rationals, yielding parent(p + q) as the univariate polynomial ring over the rational field.[29] This coercion model prioritizes structure-preserving maps, enabling seamless arithmetic and comparisons without explicit type conversions.[30]
The system's extensibility leverages Python's flexibility, allowing users to define custom functions, classes, and modules that integrate with Sage's core objects, such as extending symbolic expressions or creating new coercion paths.[24] The preparser further aids this by handling mathematical shorthand, like implicit multiplication (when enabled) or literal methods (e.g., 16.sqrt() evaluating to 4), making it straightforward to build upon Sage's framework for specialized applications.[31]
Integrated Packages
SageMath integrates a variety of open-source packages as standard components of its distribution, providing foundational capabilities across mathematical domains. These standard packages are automatically installed during SageMath setup if equivalent system libraries are not detected, ensuring a self-contained environment for computation.[4] Key standard packages include SymPy, a Python library for symbolic mathematics that handles algebraic manipulation, differentiation, and equation solving; Maxima, a system for manipulating symbolic and numerical expressions, including integration and special functions;[32] GAP, a system for computational discrete algebra focused on group theory and permutation groups; PARI/GP, a computer algebra system specialized in number theory, including prime factorization and elliptic curves; NumPy and SciPy, Python libraries for numerical computing, array operations, and scientific algorithms such as optimization and linear algebra; matplotlib, a plotting library for 2D visualizations of data and functions; FLINT, a library for fast arithmetic over integers, polynomials, and matrices; and Singular, a system for commutative algebra and algebraic geometry, supporting Gröbner bases and ideal computations. Additionally, optional packages such as R for statistical computing and graphics are integrated via dedicated interfaces, allowing users to extend SageMath's functionality without separate installations.[33] SageMath's package management system supports over 150 SPKGs (Sage Packages), which are tarball-based distributions of third-party software tailored for integration. Users can install these via the commandsage -i <package_name>, which downloads, builds, and configures the package within SageMath's environment; examples include Graphviz for graph visualization and layout algorithms, and FriCAS for interactive computer algebra in domains like abstract algebra and calculus.[4]
These packages are exposed through SageMath's unified Python-based interface, enabling seamless interoperability; for instance, users can invoke GAP functions directly from Sage code without launching a separate session, leveraging automatic coercion and translation between data types.
Packages are maintained independently by their upstream projects, with SageMath developers ensuring compatibility through version pinning and build scripts; a complete list of all available packages, including dependencies and installation status, is documented in the official SageMath reference manual.[4][34]
Capabilities and Applications
Mathematical Domains Covered
SageMath provides extensive support for algebraic computations, including symbolic manipulation of expressions, operations in polynomial rings over various coefficient domains such as the rationals or finite fields, and linear algebra functionalities like matrix operations, eigenvalue decompositions, and solving systems over rings including finite fields. In number theory, SageMath facilitates primality testing, integer factorization, computations with elliptic curves including point addition and rank determination, and the study of modular forms through spaces and Hecke operators. The system covers geometry and topology through tools for algebraic geometry, such as defining varieties and computing intersections via integration with Singular, and differential geometry including manifolds, charts, and tensor fields for topological and differentiable structures. Combinatorics and graph theory are well-supported, with capabilities for generating permutations, enumerating combinatorial objects like posets and designs, and graph algorithms including shortest paths, maximum matchings, and isomorphism testing. For numerical and scientific computing, SageMath enables solving differential equations symbolically and numerically, optimization problems, and signal processing tasks through its interface to SciPy.[35] Statistics and probability features include distributions, random variables, hypothesis testing, and statistical modeling, leveraging built-in functions and integrations with SciPy and R.[36] Additionally, SageMath supports cryptography with implementations of elliptic curve cryptography, classical ciphers, and public-key systems, as well as physics simulations through optional packages that extend numerical methods for dynamical systems and mechanics.Educational and Research Uses
SageMath has been widely adopted in undergraduate education for teaching core mathematical concepts, particularly in abstract algebra, calculus, and discrete mathematics. Institutions utilize its interactive environment to facilitate hands-on learning, allowing students to explore group theory operations, solve differential equations, and analyze graph structures without proprietary software barriers. For instance, the Mathematical Association of America's PREP workshops provide quickstart tutorials tailored for these courses, enabling instructors to integrate SageMath into curricula for topics like linear algebra and numerical analysis.[37] The open-access textbook Sage for Undergraduates by Gregory V. Bard, published in 2015, serves as a primary resource, guiding students from post-calculus levels through programming-free computations in SageMath, with free PDF versions available for classroom use.[16] Online tutorials on the official SageMath documentation further support self-paced learning, emphasizing practical examples in multivariable calculus and combinatorics.[38] In research, SageMath supports advanced investigations in number theory and graph theory, enabling computations that contribute to proofs and theoretical advancements. Researchers leverage its number field and elliptic curve functionalities for verifying conjectures, such as those related to L-functions and modular forms. A prominent application is its integration into the L-functions and Modular Forms Database (LMFDB), where SageMath handles computations for arithmetic geometry objects, facilitating discoveries in elliptic curves over number fields.[39] Graph theory tools in SageMath have been employed in papers analyzing spectral properties and isomorphism problems, aiding algorithmic developments in network analysis.[40] Notable achievements include SageMath's role in computational breakthroughs, such as factoring high-degree division polynomials for elliptic curves with complex multiplication, which has informed studies on ranks and regulators.[41] It powers collaborative platforms like CoCalc, where researchers jointly develop Jupyter notebooks for real-time synchronization in projects spanning cryptography and algebraic geometry. As of 2025, SageMath has been cited in over 500 academic papers, underscoring its impact across mathematical disciplines.[1] Community resources enhance its educational and research utility, with the SageMath wiki offering extensive examples and tutorials for interactive implementations. Annual events like Sage Days—specialized workshops and summer schools—foster skill-building in areas such as elliptic curve arithmetic, often held at institutions like SLMath. SageMath's seamless integration with Jupyter notebooks supports interactive lectures and reproducible research, allowing educators to embed dynamic visualizations and code directly into teaching materials.[42][43][16]Performance and Comparisons
Benchmarking and Optimization
SageMath provides built-in benchmarking tools to evaluate the performance of its computational operations. Thesage.misc.[benchmark](/page/Benchmark) module offers functions such as benchmark(n=-1), which executes a series of representative Sage commands and records their execution times, with n=-1 running all predefined benchmarks by default.[44] These include tasks like factoring polynomials over the rationals, such as (x^97 + 19*x + 1)*(x^103 - 19*x^97 + 14)*(x^100 - 1), computing Mordell-Weil groups of elliptic curves, and performing arithmetic with large integers or rationals, like 3^1000001 * 19^100001.[44] Additionally, the symbench suite focuses on symbolic computations, testing real-world problems such as expanding and differentiating polynomials, simplifying rational expressions, and computing Hermite polynomials, to assess efficiency in symbolic manipulation without relying on synthetic tests.[45]
Optimization in SageMath leverages integration with high-performance C libraries to accelerate core arithmetic operations. For instance, the FLINT library, which builds on the GMP for multiple-precision arithmetic, handles number-theoretic computations efficiently, including polynomial operations and integer factorization.[46] Parallel computing is supported through Python's multiprocessing module, enabling parallel iterators and map-reduce frameworks for distributing workloads across multiple processes, particularly useful for embarrassingly parallel tasks like evaluating functions over large iterables.[47] Caching mechanisms further enhance efficiency for repeated computations; decorators like @cached_function and @cached_method store results in memory (or optionally on disk) based on input keys, avoiding redundant calculations in functions or class methods, while weak caching with @weak_cached_function allows automatic cleanup of unused entries.[48]
Performance in SageMath is influenced by the interplay between its Python-based interpreter and underlying native implementations. Pure Python code incurs overhead from interpretation and dynamic typing, which can slow simple operations compared to direct calls to C or Fortran libraries interfaced via Cython; however, Cython extensions compile critical paths to near-native speeds, minimizing this gap for compute-intensive tasks.[49] Recent versions, such as 10.x, have introduced refinements like removing deprecated memory allocators in backends and refactoring methods for multivariate polynomials, improving overall memory usage and reducing allocation overhead in symbolic and numerical routines.[50]
SageMath's testing infrastructure ensures reliability and detects performance regressions through comprehensive automated doctests. These tests, integrated into the documentation, verify both correctness and efficiency across functions and modules.[51] Release candidates undergo benchmarking against previous versions via buildbot systems, flagging any slowdowns or regressions in key operations before finalization.[51]
Comparisons with Other Systems
SageMath distinguishes itself from proprietary systems like Mathematica and Maple by offering unrestricted free access without licensing fees, making it particularly advantageous for educational institutions and individual researchers worldwide. While these commercial alternatives provide polished, out-of-the-box experiences, SageMath requires more initial configuration to integrate its diverse open-source components, such as Maxima for symbolic computation and NumPy/SciPy for numerical analysis. Nonetheless, this architecture enables SageMath to deliver comparable symbolic and numerical capabilities, often matching or exceeding proprietary systems in specific domains like number theory and algebraic geometry through targeted library wrappers.[16][52] In contrast to other open-source alternatives, SageMath provides a more cohesive platform than standalone tools such as SymPy, which focuses solely on symbolic mathematics in pure Python, or GAP, a specialized system for computational group theory. By bundling SymPy and a customized version of GAP as standard packages, SageMath facilitates unified workflows, allowing users to transition seamlessly between symbolic manipulation, group computations, and broader mathematical explorations within a single Python interface. However, for highly specialized algebraic tasks, SageMath interfaces with but does not match the raw computational speed of Magma, a proprietary system optimized for advanced algebra, though it avoids Magma's costs and licensing restrictions.[53][54][55] SageMath's Python-based foundation introduces a steeper learning curve for newcomers without programming experience, yet it surpasses many alternatives in extensibility, enabling users to extend functionality via custom scripts or additional packages. Community evaluations highlight its competitiveness in mixed symbolic-numeric workloads, where it leverages low-level library integrations for efficient numerical operations, often reaching speeds comparable to optimized C code. A key strength lies in its zero-cost model, ideal for educational applications in under-resourced environments, though its comprehensive installation—requiring about 6 GB of free disk space and resulting in a 3-4 GB footprint—contrasts with the minimal overhead of lighter tools like SymPy alone.[56][57]Licensing, Community, and Availability
Licensing
SageMath's core codebase is licensed under the GNU General Public License version 2 or later (GPLv2+), a copyleft license that has governed the original Sage code since the project's inception in 2005.[58][1] This licensing applies to the integrated Sage library and ensures that modifications and derivatives remain open source.[59] The full SageMath distribution incorporates this primary license while bundling numerous external packages, known as Sage Packages (SPKGs), most of which are released under GPL-compatible licenses to maintain overall compatibility.[34][60] For instance, some libraries use the GNU Lesser General Public License (LGPL), but all standard packages must align with GPLv3 compatibility requirements for inclusion.[34] Users redistributing SageMath or its components are required to review the specific license for each SPKG, as detailed in the package's SPKG.txt or SPKG.rst files, to ensure compliance with any unique terms.[34] Under GPLv2+, SageMath permits free use, study, modification, and distribution for any purpose, including commercial applications, as long as derivative works provide source code access and adhere to the license's conditions. There are no proprietary restrictions or fees imposed by the project beyond the standard GPL obligations, fostering broad accessibility and collaboration in mathematical computing.[16] Licensing has remained stable under GPLv2+ through 2025, despite occasional community discussions considering a shift to GPLv3+; no such change has been implemented, and dual-licensing is not employed.[1][5]Community and Support
The SageMath community revolves around collaborative platforms and events that facilitate development, discussion, and knowledge sharing. Historically, the project utilized a Trac server for bug tracking, feature requests, and an integrated wiki for collaborative documentation, but in 2023, development fully migrated to GitHub, where issues and pull requests now centralize these activities. Active mailing lists include sage-support for user queries on installation, usage, and troubleshooting, and sage-devel for technical discussions on code, architecture, and enhancements. Since 2006, the community has organized annual Sage Days conferences—intensive workshops and coding sprints held worldwide—to advance the software through hands-on collaboration among developers, mathematicians, and educators. Contributions to SageMath are welcomed from all participants through an open GitHub workflow, where users submit pull requests to propose code improvements, new features, or bug fixes, with reviews ensuring quality and integration. The project actively engages emerging developers via Google Summer of Code (GSoC), including in 2025 with initiatives exploring cryptography implementations and enhancements to 2D/3D graphics visualization tools. By 2025, SageMath has benefited from hundreds of contributors globally, as mapped across its development history, spanning academics, students, and professionals. User support is robust and multifaceted, with the Ask Sage forum serving as a primary Q&A resource, accumulating over 12,000 questions on topics from basic syntax to advanced algorithms. The official documentation spans extensive resources, including interactive tutorials, a comprehensive reference manual with examples for all modules, and developer guides, all available in HTML and PDF formats with multilingual options. Real-time assistance is provided through the Zulip chat platform, which has superseded the legacy IRC channel and hosts dedicated streams for support, development, and special topics. Funding has historically included institutional grants from the U.S. National Science Foundation (NSF) for core development and educational outreach, and European Union Horizon 2020 projects like OpenDreamKit for infrastructure enhancements; as of 2025, support is sustained via community-driven platforms like Open Collective for donations and transparent fiscal sponsorship, alongside GitHub Sponsors and GSoC stipends.[61][62] Governance emphasizes a decentralized, volunteer-led model, with major decisions coordinated via the sage-devel mailing list, GitHub maintainers, and release managers to ensure consensus and stability. Founder William Stein, through his ongoing involvement via SageMath, Inc., promotes inclusivity by prioritizing accessible entry points for students and underrepresented researchers, such as GSoC mentorship and women-focused Sage Days events.Installation and Distribution
SageMath is available across multiple platforms, including Linux, macOS, Windows, and web-based environments, allowing users to choose installation methods suited to their operating system and needs.[63] On Linux distributions such as Ubuntu and Fedora, SageMath can be installed via native package managers without requiring a full source build, though these typically provide older versions. For the latest release (10.7 as of November 2025), alternatives like conda, source builds, or AppImages are recommended. For Ubuntu, whilesudo apt install sagemath is available, it obtains an outdated version from the repositories; users should verify and prefer other methods for core functionalities in version 10.7.[63][64] Similarly, on Fedora, the command dnf install sagemath installs the package if available, though it may be absent or outdated in recent releases and requires verification of compatibility with the system's Python version, such as Python 3.11 or later; conda or source is advised for current versions.[63][65] For macOS (version 10.15 or later), installation options include pre-built binaries from the official GitHub repository maintained by the 3-manifolds project, which provide a signed and notarized application bundle for macOS 10.13 (High Sierra) and newer, including recent SageMath versions like 10.7, or using Homebrew with brew install --cask sage to handle dependencies like Boost and CMake automatically.[66][67] On Windows, direct native support is limited, so the recommended approach is using the Windows Subsystem for Linux (WSL) with Ubuntu; after setting up WSL, SageMath installs via sudo apt install sagemath or through a virtual machine running Linux.[63] For users preferring no local installation, web-based options include the SageCell server at sagecell.sagemath.org for interactive computations in a browser and CoCalc, a cloud platform that supports full SageMath sessions with Jupyter notebooks.[27][68]
Installation methods emphasize ease of use and flexibility, with binary installers, source builds, and environment managers as primary options. Although pre-built binaries for Linux have been discontinued in recent releases, users can still access version 10.7 binaries for specific architectures via archived mirrors if needed, but package managers are preferred.[69] Building from source requires downloading the stable tarball (e.g., sage-10.7.tar.gz) from mirrors like those at MIT or European sites, extracting it, and running make in the directory; prerequisites include Python 3.11 or later, at least 2 GB of RAM (4-5 GB recommended for WSL), and system libraries such as GCC and Perl, with the build process taking several hours on standard hardware.[57][69] Alternatively, the conda-forge channel simplifies setup across Linux, macOS (x86_64 and aarch64), and WSL by running conda install -c conda-forge [sage](/page/Sage) after installing Miniconda or Mamba, creating an isolated environment with all dependencies like NumPy and SymPy.[70] The full installation typically requires about 2 GB of disk space once built or unpacked.[57]
SageMath is distributed through a network of worldwide mirrors to ensure reliable access, including sites in the Americas (e.g., MIT), Asia (e.g., AARNET in Australia), and Europe (e.g., TUXFamily in France), from which users download source tarballs, optional packages, or older binaries.[69] For containerized deployments, official Docker images are available on Docker Hub under the sagemath namespace, such as sagemath/sagemath:10.7, allowing quick setup with docker run -it sagemath/sagemath:10.7 sage for development or testing environments.[71]
Updates to SageMath can be managed in-place for source installations by using commands like sage -upgrade to fetch and install the latest version over the existing one, preserving user data and notebooks, though a full reinstall is recommended for major releases to resolve potential dependency conflicts.[72] For server-based use, SageMath integrates seamlessly with JupyterHub by launching via sage -n jupyter, enabling multi-user environments where the Sage kernel appears alongside Python and other options in the interface.[73]