| Hosted by CoCalc | Download
Kernel: SageMath 9.4
reset('version') version()
'SageMath version 9.4, Release Date: 2021-08-22'
M = matrix([[sin(x), cos(x)], [-cos(x), sin(x)]]) M_sympy = M._sympy_() M_sympy

[sin(x)cos(x)cos(x)sin(x)]\displaystyle \left[\begin{matrix}\sin{\left(x \right)} & \cos{\left(x \right)}\\- \cos{\left(x \right)} & \sin{\left(x \right)}\end{matrix}\right]

M_sympy.subs(x, pi/4)

[22222222]\displaystyle \left[\begin{matrix}\frac{\sqrt{2}}{2} & \frac{\sqrt{2}}{2}\\- \frac{\sqrt{2}}{2} & \frac{\sqrt{2}}{2}\end{matrix}\right]

in_small_oblong(x, y) = x^2 + 3 * y^2 <= 42 SmallOblongUniverse = ConditionSet(QQ^2, in_small_oblong) SmallOblongUniverse
{ (x, y) ∈ Vector space of dimension 2 over Rational Field : x^2 + 3*y^2 <= 42 }
parity_check(x, y) = abs(sin(pi/2*(x + y))) < 1/1000 EvenUniverse = ConditionSet(ZZ^2, parity_check); EvenUniverse
{ (x, y) ∈ Ambient free module of rank 2 over the principal ideal domain Integer Ring : abs(sin(1/2*pi*x + 1/2*pi*y)) < (1/1000) }
SmallOblongUniverse & EvenUniverse
{ (x, y) ∈ Free module of degree 2 and rank 2 over Integer Ring Echelon basis matrix: [1 0] [0 1] : x^2 + 3*y^2 <= 42, abs(sin(1/2*pi*x + 1/2*pi*y)) < (1/1000) }
symbolic_expression(lambda x,y: x^2+y^2) == (SR.var("x")^2 + SR.var("y")^2).function(SR.var("x"), SR.var("y"))
(x, y) |--> x^2 + y^2 == x^2 + y^2
predicate(x, y, z) = sqrt(x^2 + y^2 + z^2) < 12 # preparser syntax, creates globals
ConditionSet(ZZ^3, predicate)
{ (x, y, z) ∈ Ambient free module of rank 3 over the principal ideal domain Integer Ring : sqrt(x^2 + y^2 + z^2) < 12 }
M = Manifold(2, 'M') X.<x,y> = M.chart() M.identity_map().display()
Id_M: M → M (x, y) ↦ (x, y)
v = M.vector_field(-y, x, name='v') v.display()
v = -y ∂/∂x + x ∂/∂y
f = M.scalar_field(x^2 + y^2, name='f') (v*diff(f)).display()
v⊗df = -2*x*y ∂/∂x⊗dx - 2*y^2 ∂/∂x⊗dy + 2*x^2 ∂/∂y⊗dx + 2*x*y ∂/∂y⊗dy
sage: M = Manifold(2, 'M') sage: X.<x,y> = M.chart(coord_restrictions=lambda x,y: [x^2+y^2<1, x+y>0]) sage: X.plot(max_range=1, number_values=41)
Image in a Jupyter notebook
from veerer import * T = VeeringTriangulation([(0,1,2), (-1,-2,-3)], [RED, RED, BLUE]) print(T.is_core()) F = T.flat_structure_middle() print(F) F.plot(vertical_train_track=True)
True FlatVeeringTriangulation(Triangulation("(0,1,2)(~2,~0,~1)"), [(1, 2), (-2, -1), (1, -1), (-1, 1), (2, 1), (-1, -2)])
Image in a Jupyter notebook
F.plot(horizontal_train_track=True)
Image in a Jupyter notebook
import flatsurf.geometry.similarity_surface_generators as sfg T = sfg.translation_surfaces.regular_octagon() T
TranslationSurface built from 1 polygon
T.stratum()
H_2(2)
import flatsurf flatsurf.__version__
'0.4.1'
from surface_dynamics.all import * o = Origami('(1,2)', '(1,3)') o
(1,2)(3) (1,3)(2)
o.lyapunov_exponents_approx()
[0.333283800731917]
q = QuadraticStratum(1, 1, 1, 1) q.orientation_cover()
H_5(2^4)
%display latex
@interact def f(x=slider(-1,10,0.1)): print(x)
#import matplotlib.pyplot #matplotlib.pyplot.style.available
import matplotlib.pyplot as plt plt.style.use('fivethirtyeight') plot(sin(x^2), (x, 0, 2*pi))
Image in a Jupyter notebook

Bär–Faddeev–LeVerrier algorithm for the Pfaffian of skew-symmetric matrices

A = matrix([(0, 0, 1, 0, -1, -2, -1, 0, 2, 1), (0, 0, 1, -3/2, 0, -1, 1/2, 3, 3/2, -1/2), (-1, -1, 0, 2, 0, 5/2, 1, 0, -2, 1), (0, 3/2, -2, 0, 5/2, -1, 2, 0, -1, -3/2), (1, 0, 0, -5/2, 0, 0, -1, 1/2, 1, -1), (2, 1, -5/2, 1, 0, 0, 2, 1, 2, 1), (1, -1/2, -1, -2, 1, -2, 0, 0, -3, -1), (0, -3, 0, 0, -1/2, -1, 0, 0, 1/2, 1/2), (-2, -3/2, 2, 1, -1, -2, 3, -1/2, 0, 1), (-1, 1/2, -1, 3/2, 1, -1, 1, -1/2, -1, 0)]) %time A.pfaffian(algorithm='bfl')
CPU times: user 853 µs, sys: 0 ns, total: 853 µs Wall time: 8.53 ms
81716\renewcommand{\Bold}[1]{\mathbf{#1}}\frac{817}{16}

Polyhedral geometry

fcube = polytopes.hypercube(4) tfcube = fcube.face_truncation(fcube.faces(0)[0]) tfcube.facets()[-1]
Ax3-dimensionalxfacexofxaxPolyhedronxinxQQ^4xdefinedxasxthexconvexxhullxofx8xvertices\renewcommand{\Bold}[1]{\mathbf{#1}}\verb|A|\phantom{\verb!x!}\verb|3-dimensional|\phantom{\verb!x!}\verb|face|\phantom{\verb!x!}\verb|of|\phantom{\verb!x!}\verb|a|\phantom{\verb!x!}\verb|Polyhedron|\phantom{\verb!x!}\verb|in|\phantom{\verb!x!}\verb|QQ^4|\phantom{\verb!x!}\verb|defined|\phantom{\verb!x!}\verb|as|\phantom{\verb!x!}\verb|the|\phantom{\verb!x!}\verb|convex|\phantom{\verb!x!}\verb|hull|\phantom{\verb!x!}\verb|of|\phantom{\verb!x!}\verb|8|\phantom{\verb!x!}\verb|vertices|
sp = tfcube.schlegel_projection(tfcube.facets()[-1]) sp.plot() # The proper Schlegel diagram is shown
sp = tfcube.schlegel_projection(tfcube.facets()[4],1/2) sp.plot()

*-insertion algorithm from ​https://arxiv.org/abs/1911.08732:

from sage.combinat.rsk import RuleStar p,q = RuleStar().forward_rule([1,1,2,2,4,4], [1,3,2,4,2,4]) ascii_art(p, q)
xx1xx2xx4xx1xx1xx2xx1xx4xxxxx2xx4xx3xxxxxxxx4\renewcommand{\Bold}[1]{\mathbf{#1}}\begin{array}{l} \phantom{\verb!xx!}\verb|1|\phantom{\verb!xx!}\verb|2|\phantom{\verb!xx!}\verb|4|\phantom{\verb!xx!}\verb|1|\phantom{\verb!xx!}\verb|1|\phantom{\verb!xx!}\verb|2|\\ \phantom{\verb!xx!}\verb|1|\phantom{\verb!xx!}\verb|4|\phantom{\verb!xxxxx!}\verb|2|\phantom{\verb!xx!}\verb|4|\\ \phantom{\verb!xx!}\verb|3|\phantom{\verb!xxxxxxxx!}\verb|4| \end{array}
line1,line2 = RuleStar().backward_rule(p, q) line1,line2
([1,1,2,2,4,4],[1,3,2,4,2,4])\renewcommand{\Bold}[1]{\mathbf{#1}}\left(\left[1, 1, 2, 2, 4, 4\right], \left[1, 3, 2, 4, 2, 4\right]\right)

Spheres added to the manifold catalog

S3 = manifolds.Sphere(3) S3
S3\renewcommand{\Bold}[1]{\mathbf{#1}}\mathbb{S}^{3}
S3.atlas()
S3.embedding().display()
g = S3.induced_metric() g.display()
S3.stereographic_coordinates()

3d plots

line = parametric_plot3d([x*cos(x),x*sin(x),x], (x,0,2*pi), thickness=10) surface = dodecahedron(mesh=True, thickness=10) show(line + surface)
x, y = var('x, y') def build_frame(t): """Build a single frame of animation at time t.""" e = parametric_plot3d([sin(2*x - t), sin(x + t), x], (x, 0, 2*pi), color='red') b = parametric_plot3d([cos(x + t), -sin(x - t), x], (x, 0, 2*pi), color='green') return e + b frames = [build_frame(t) for t in (0, pi/32, pi/16, .., 2*pi)] animate(frames, delay=5).interactive(projection='orthographic')
@interact def func(k = slider(0, 10, .1)): print("k: %s" % k) s = (1 - sqrt(k))^2 print("s: %s" % s)