SageMath (Stein et al. (2024)) is an open-source system that combines many powerful mathematical software packages into one interface. It provides tools for symbolic computation, numerical analysis, plotting, and more, making it highly useful for both research and education in mathematics, physics, and engineering.
Basics
Fundamental operations, symbolic computation, and core mathematical structures.
SageMath provides tools for symbolic calculus such as differentiation and integration. You can compute derivatives and integrals of functions symbolically:
# Define functionf = x^2 + 3 * x + 2f
# Differentiate with respect to xdiff(f, x)
# Integrate with respect to xintegrate(f, x)
# Plot of the functionplot(f, (x, -5, 5))
Differential equations
SageMath can solve differential equations symbolically:
# Define a differential equationy = function('y')(x)deqn = (diff(y, x) + y == sin(x))deqn
# Solve the differential equationdesolve(deqn, y)
Linear algebra
SageMath handles matrix operations, such as addition, multiplication, and finding eigenvalues:
# Define matrix AA = Matrix([[1, 2], [3, 4], [5, 6]]) A
# Validation of eigenvalue equationfor eigenvalue, (eigenvector, *_), _ in C.eigenvectors_right(): display((C, eigenvector, eigenvalue, C * eigenvector == eigenvalue * eigenvector))
Group theory
SageMath includes tools for working with groups:
# Define the symmetric group S3G = SymmetricGroup(3)G
# Get the order of S3G.order()
# List the elements of S3G.list()
# Standard representation of S3[g.matrix() for g in G]
Differentiable manifolds
SageMath allows for computations in differential geometry, including tangent vectors, differential forms, and more:
# Declare the spacetime manifold MS2 = manifolds.Sphere(2)S2
# Spherical coordinatesS2.spherical_coordinates()
# MetricS2.metric().display()
Advanced
Exploring advanced mathematics in SageMath, including group theory, manifolds, Lie groups, and Lie algebras. This section broadly follows (Keski-Vakkuri, Montonen, and Panero 2022).
Group theory
We begin by exploring finite groups, followed by an introduction to free groups and their presentation. Finally, we examine continuous groups and group actions.
Smallest finite groups
We present the list of all groups of finite order .
Order N = 1
# Z1Z1 = CyclicPermutationGroup(1)Z1.list()
Order N = 2
# Z2Z2 = CyclicPermutationGroup(2)Z2.list()
# Z2 Cayley tableprint(Z2.cayley_table())
* a b
+----
a| a b
b| b a
# S2S2 = SymmetricGroup(2)S2.list()
# S2 Cayley tableprint(S2.cayley_table())
* a b
+----
a| a b
b| b a
# Z2, S2 isomorphicassert S2.is_isomorphic(Z2)
Order N = 3
# Z3Z3 = CyclicPermutationGroup(3)Z3.list()
# Z3 Cayley tableprint(Z3.cayley_table())
* a b c
+------
a| a b c
b| b c a
c| c a b
Order N = 4
# Z4Z4 = CyclicPermutationGroup(4)Z4.list()
# Z4 Cayley tableprint(Z4.cayley_table())
* a b c d
+--------
a| a b c d
b| b c d a
c| c d a b
d| d a b c
# Z4 cyclicassert Z4.is_cyclic()
# Klein four-groupK4G = direct_product_permgroups([Z2, Z2])K4G.list()
# Klein four-group Cayley tableprint(K4G.cayley_table())
* a b c d
+--------
a| a b c d
b| b a d c
c| c d a b
d| d c b a
# Klein four-group cyclicassert not K4G.is_cyclic()
Order N = 5
# Z5Z5 = CyclicPermutationGroup(5)Z5.list()
# Z5 Cayley tableprint(Z5.cayley_table())
* a b c d e
+----------
a| a b c d e
b| b c d e a
c| c d e a b
d| d e a b c
e| e a b c d
Order N = 6
# Z6Z6 = CyclicPermutationGroup(6)Z6.list()
# Z6 Cayley tableprint(Z6.cayley_table())
* a b c d e f
+------------
a| a b c d e f
b| b c d e f a
c| c d e f a b
d| d e f a b c
e| e f a b c d
f| f a b c d e
# Z2 x Z3Z2xZ3 = direct_product_permgroups([Z2, Z3])Z2xZ3.list()
# Z2 x Z3 Cayley tableprint(Z2xZ3.cayley_table())
* a b c d e f
+------------
a| a b c d e f
b| b c a e f d
c| c a b f d e
d| d e f a b c
e| e f d b c a
f| f d e c a b
# S3S3 = SymmetricGroup(3)S3.list()
# S3 Cayley tableprint(S3.cayley_table())
* a b c d e f
+------------
a| a b c d e f
b| b a d c f e
c| c e a f b d
d| d f b e a c
e| e c f a d b
f| f d e b c a
# Z6, Z2 x Z3 isomorphicassert Z6.is_isomorphic(Z2xZ3)
# S3, Z6 non-isomorphicassert not S3.is_isomorphic(Z6)
# S3, Z2 x Z3 non-isomorphicassert not S3.is_isomorphic(Z2xZ3)
# Z6 cyclicassert Z6.is_cyclic()
# Z2 x Z3 cyclicassert Z2xZ3.is_cyclic()
# S3 cyclicassert not S3.is_cyclic()
# Z6 abelianassert Z6.is_abelian()
# Z2 x Z3 abelianassert Z2xZ3.is_abelian()
# S3 non-abelianassert not S3.is_abelian()
Order N = 7
# Z7Z7 = CyclicPermutationGroup(7)Z7.list()
# Z7 Cayley tableprint(Z7.cayley_table())
* a b c d e f g
+--------------
a| a b c d e f g
b| b c d e f g a
c| c d e f g a b
d| d e f g a b c
e| e f g a b c d
f| f g a b c d e
g| g a b c d e f
Order N = 8
# Z8Z8 = CyclicPermutationGroup(8)Z8.list()
# Z8 Cayley tableprint(Z8.cayley_table())
* a b c d e f g h
+----------------
a| a b c d e f g h
b| b c d e f g h a
c| c d e f g h a b
d| d e f g h a b c
e| e f g h a b c d
f| f g h a b c d e
g| g h a b c d e f
h| h a b c d e f g
# Z4 x Z2Z4xZ2 = direct_product_permgroups([Z4, Z2])Z4xZ2.list()
# Z4xZ2 Cayley tableprint(Z4xZ2.cayley_table())
* a b c d e f g h
+----------------
a| a b c d e f g h
b| b a d c f e h g
c| c d e f g h a b
d| d c f e h g b a
e| e f g h a b c d
f| f e h g b a d c
g| g h a b c d e f
h| h g b a d c f e
# Z2 x Z2 x Z2Z2xZ2xZ2 = direct_product_permgroups([Z2, Z2, Z2])Z2xZ2xZ2.list()
* a b c d e f g h
+----------------
a| a b c d e f g h
b| b a d c f e h g
c| c d a b g h e f
d| d c b a h g f e
e| e f g h a b c d
f| f e h g b a d c
g| g h e f c d a b
h| h g f e d c b a
# D4D4 = DihedralGroup(4)D4.list()
# D4 Cayley tableprint(D4.cayley_table())
* a b c d e f g h
+----------------
a| a b c d e f g h
b| b a d c f e h g
c| c g a e d h b f
d| d h b f c g a e
e| e f g h a b c d
f| f e h g b a d c
g| g c e a h d f b
h| h d f b g c e a
# QQ = QuaternionGroup()Q.list()
# Q Cayley tableprint(Q.cayley_table())
* a b c d e f g h
+----------------
a| a b c d e f g h
b| b c d a h e f g
c| c d a b g h e f
d| d a b c f g h e
e| e f g h c d a b
f| f g h e b c d a
g| g h e f a b c d
h| h e f g d a b c
# Z8, Z4 x Z2, Z2 x Z2 x Z2, D4, Q non-isomorphicfrom itertools import combinationsgroups = [Z8, Z4xZ2, Z2xZ2xZ2, D4, Q]for group1, group2 in combinations(groups, 2): if not group1.is_isomorphic(group2): display(f'{group1}, {group2} are not isomorphic.')
# Z8 abelianassert Z8.is_abelian()
# Z4 x Z2 abelianassert Z4xZ2.is_abelian()
# Z2 x Z2 x Z2 abelianassert Z2xZ2xZ2.is_abelian()
# D4 non-abelianassert not D4.is_abelian()
# Q non-abelianassert not Q.is_abelian()
# Q subgroupsfor G in Q.subgroups(): display(G)
# Q proper subgroupsfor G in Q.subgroups(): if G.order() == 2: if G.is_isomorphic(Z2) and G.is_normal(): display(f'{G} is isomorphic to {Z2} and a normal subgroup of {Q}.') elif G.order() == 4: if G.is_isomorphic(Z4) and G.is_normal(): display(f'{G} is isomorphic to {Z4} and a normal subgroup of {Q}.')
Symmetric groups
We present symmetric groups of different orders along with their properties.