<jupyter_start><jupyter_text>Introduction to Sage a free mathematics software system  Sage/SageMathStarted in 2005 by <NAME> as a Computer **S**ystem for **A**lgebra and **G**eometry **E**xperimentation.Mission: "Creating a viable free open source alternative to Magma, Maple, Mathematica and Matlab."Sage is now at version 8.3 with [~500 contributors](git log --format='%aN' | awk '{ print $2; }' | awk 'length>3' | sort -u |wc -l) and 97 workshops.  A Tour of Sage<jupyter_code>1 * 1<jupyter_output><empty_output><jupyter_text>A Tour of Sage – Arithmetic<jupyter_code>1 + 1
a = 12 / 14
a == 42 * (1/7)^2<jupyter_output><empty_output><jupyter_text>a.[TAB] → numerical_approx()a.[TAB] → squarefree_part()  A Tour of Sage – HelpIntegrated reference manual:<jupyter_code>a.squarefree_part?<jupyter_output><empty_output><jupyter_text>* TAB-completion and `?`* Tutorials and Manuals: https://doc.sagemath.org* Ask Sage: https://ask.sagemath.org* Mailing List, IRC channels, …  Common Issues with Tab-Completion<jupyter_code>abcde = 13.numerical_approx()

abcde<jupyter_output><empty_output><jupyter_text>A Tour of Sage – Calculus<jupyter_code>var('x')
f(x) = x - 4*sin(x)
f.plot(-10, 10)
var('x')
f(x) = x - 4*sin(x)
f.derivative(x)
f.integrate(x)
f.limit(x=infinity)<jupyter_output><empty_output><jupyter_text>A Tour of Sage – Plots<jupyter_code>var('y')
PP = plot3d(x^2 + y^2, (x, -1, 1), (y, -1, 1))
PP.show(viewer='threejs')<jupyter_output><empty_output><jupyter_text>G = …G.plot3d(viewer='threejs')<jupyter_code>contour_plot(y^2 + 1 - x^3 - x, (x,-pi,pi), (y,-pi,pi),
             contours=[-8,-4,0,4,8], colorbar=True)
var('t')
@interact
def my_plot(s=(0, 2*pi, .01)):
    f(t) = (sin(t), sin(2*t))
    P = parametric_plot(f, (t, 0, 2*pi), color="purple")
    L = f.derivative(t)(s)*t + f(s)
    P = P + parametric_plot(L, (t, -2, 2))
    P.set_axes_range(-2, 2, -2, 2)
    return P
def f(x, y):
    if x >= 0: return x^2 + y^2
    else: return 0
plot3d(f, (x, -1, 1), (y, -1, 1)).show(viewer='threejs')<jupyter_output><empty_output><jupyter_text>A Tour of Sage – Graphs<jupyter_code>G = graphs.KrackhardtKiteGraph()
G.add_edge(5, 8)
G.show()<jupyter_output><empty_output><jupyter_text>G.chromatic_number()G.is_planar()<jupyter_code>## A Tour of Sage – Linear Algebra<jupyter_output><empty_output><jupyter_text>matrix([[0, 3],[0, 0]]) M = matrix([[0, 3], [0, 0]]) M * M v = vector([1, 0])M * v v * M M.right_kernel() M.solve_right(vector([6,0])) M * vector([0, 2])<jupyter_code>## A Tour of Sage – Base Rings<jupyter_output><empty_output><jupyter_text>M = matrix([[0, 3], [0, 0]])N = matrix(QQ, [[0, 3], [0, 0]]) M.echelon_form() N.echelon_form() ZZ, QQ, AA, QQbar, GF(2) RR, CC, Qp(2) S. = PowerSeriesRing(QQ)L. = LaurentSeriesRing(QQ)S K. = FunctionField(GF(2))R. = PolynomialRing(K)<jupyter_code>## A Tour of Sage – Elements and Parents
all *elements* in Sage have a `parent`<jupyter_output><empty_output><jupyter_text>2.parent() (1/2).parent() matrix([[0, 3], [0, 0]]).parent() ZZ.hom(QQ).parent()<jupyter_code>convert an element to a new parent:<jupyter_output><empty_output><jupyter_text>M.parent() M.parent()(2) QQ(2)  .parent()<jupyter_code>## A Tour of Sage – …<jupyter_output><empty_output><jupyter_text>S = Sudoku('5...8..49...5...3..673....115..........2.8..........187....415..3...2...49..5...3')S f(x) = sqrt(sin(x))latex(f)<jupyter_code>__2D/3D Graphics__, __Categories__, __Basic Rings and Fields__: Integers and Rational Numbers, Real and Complex Numbers, Finite Rings and Fields, Polynomials, Formal Power Series, p-Adic Numbers, Quaternion Algebras, __Linear Algebra__: Matrices and Spaces of Matrices, Vectors and Modules, Tensors on Free Modules of Finite Rank, __Calculus and Analysis__: Symbolic Calculus, Mathematical Constants, Elementary and Special Functions, Asymptotic Expansions, Numerical Optimization, __Probability and Statistics__, Probability , Statistics, Quantitative Finance, __Mathematical Structures__: Sets, Monoids, Groups, Semirings, Rings, Algebras, __Discrete Mathematics__ Combinatorics, Graph Theory, Quivers, Matroid Theory, Discrete Dynamics, Coding Theory, Cryptography, Game Theory, Symbolic Logic, SAT solvers, __Geometry and Topology__: Combinatorial and Discrete Geometry, Hyperbolic Geometry, Cell Complexes and their Homology, Differential Forms, Manifolds, Parametrized Surfaces, Knot Theory, __Number Fields and Function Fields__, __Number Theory__: Diophantine approximation, Quadratic Forms, L-Functions, Arithmetic Subgroups of $SL_2(Z)$, General Hecke Algebras and Hecke Modules, Modular Symbols, Modular Forms, Modular Forms for Hecke Triangle Groups, Modular Abelian Varieties, __Algebraic and Arithmetic Geometry__: Schemes, Plane, Elliptic and Hyperelliptic Curves, __Databases__, __Games__, […](https://doc.sagemath.org/html/en/reference/)
## How to run Sage
Install Sage as it comes with your distribution, go to https://cocalc.com, or download from https://sagemath.org.
Talk about Download options. Talk about paid model, and showcase sharing (expandable depending on time)
## Sage does not reinvent the wheel
### Python-powered
Sage is just a Python library<jupyter_output><empty_output><jupyter_text>from sage.all import * def sum(a, b):    return a + b def max(a, b):    if a > b:        return a    elif a == b:        return a    else:        return b A = [2, 3, 5, 7, 11]for p in A:    print(p)<jupyter_code>Some syntactic sugar not found in Python<jupyter_output><empty_output><jupyter_text>2^3<jupyter_code>preparse(…)<jupyter_output><empty_output><jupyter_text>R. = QQ[] f(x) = sin(x)/x<jupyter_code>#### Interactive Debugger<jupyter_output><empty_output><jupyter_text>import pdbA = [2, 3, 5, 7, 11]for p in A:    pdb.set_trace()    print(p)<jupyter_code>### Based on many existing free software projects
Such as …
#### Maxima<jupyter_output><empty_output><jupyter_text>f(x) = x - 4*sin(x)f.derivative(x)<jupyter_code>#### matplotlib, jsmol, three.js<jupyter_output><empty_output><jupyter_text>f.plot(-10, 10)<jupyter_code>#### FLINT<jupyter_output><empty_output><jupyter_text>matrix([[0, 3], [0, 0]]).right_kernel() M = matrix([[0, 3], [0, 0]])  FLINTM.change_ring(GF(2))          M4RIM.change_ring(GF(4))          M4RIEM.change_ring(GF(3))          LinBoxM.change_ring(GF(9))          MeatAxe<jupyter_code>## Sage is free software
Released under the GPLv2+ it is completely open source.
Use `??` to see the implementation of a method:<jupyter_output><empty_output><jupyter_text>K. = FunctionField(QQ)R. = K[]L. = K.extension(y^2 - x)y.norm()<jupyter_code>y.norm??<jupyter_output><empty_output><jupyter_text>Integration with other Computer Algebra Systemssuch as GAP, Pari/GP, Magma, Matlab, Maple, Mathematica, Maxima, Singular, …<jupyter_code>R.<x> = QQ[]
f = (x^100+17*x+5)*(x^100-5*x+20)
f
f.factor()
f = (x^100+17*x+5)*(x^100-5*x+20)
F = singular(f)
G = F.factorize() # factorize(F)
show(G[1][2].sage())
# x100−5x+20<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1589499495168037, 'fraction_numerical': 0.02942449156209433, 'mean_word_length': 5.7189922480620154, 'pattern_counts': {'":': 0, '<': 95, '<?xml version=': 0, '>': 98, 'https://': 5, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 1, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '23', 'dir': 'jupyter-structured-clean-dedup', 'id': '235195', 'license': 'Unlicense', 'n_tokens_mistral': 2835, 'n_tokens_neox': 2649, 'n_words': 651, 'path': 'A Tour of Sage.ipynb', 'repo_name': 'saraedum/sagemath-tour-rise', 'size': '6940'}