  Views: 512
Image: ubuntu2004-dev
Kernel: SageMath 9.2

# Sage 9.2 on CoCalc

```version()
```

## NEW: 3D Animations!

```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')
```

## eigenvalues with errors using Arb

```from sage.matrix.benchmark import hilbert_matrix
mat = hilbert_matrix(5).change_ring(CBF)
mat.eigenvalues()
```

## Polyomino tilings

```from sage.combinat.tiling import Polyomino
H = Polyomino([ (-1, 1), (-1, 4), (-1, 7), (0, 0), (0, 1), (0, 2),
(0, 3), (0, 4), (0, 5), (0, 6), (0, 7), (0, 8), (1, 1), (1, 2),
(1, 3), (1, 4), (1, 5), (1, 6), (1, 7), (1, 8), (2, 0), (2, 2),
(2, 3), (2, 5), (2, 6), (2, 8)])
H.show2d()
```
```%time solution = H.self_surrounding(10, ncpus=2)
```
```G = sum([p.show2d() for p in solution], Graphics())
G
```

## Manifolds: diff function for exterior derivatives

```M = Manifold(2, 'M')
X.<x,y> = M.chart()
f = M.scalar_field(x^2*y, name='f')
diff(f)
```
```diff(f).display()
```
```a = M.one_form(-2*x*y, x, name='a'); a.display()
diff(a).display()
```

## Differential Weyl algebra

```W.<x,y> = DifferentialWeylAlgebra(QQ)
dx, dy = W.differentials()
dx.diff(x^3)
```
```(x*dx + dy + 1).diff(x^4*y^4 + 1)
```

## Temperley-Lieb diagrams now have unicode

```from sage.combinat.diagram_algebras import TL_diagram_ascii_art

TL = [(-15,-12), (-14,-13), (-11,15), (-10,14), (-9,-6),
(-8,-7), (-5,-4), (-3,1), (-2,-1), (2,3), (4,5),
(6,11), (7, 8), (9,10), (12,13)]
TL_diagram_ascii_art(TL, use_unicode=True)
```

## some calculus

```x = var('x')
eq = 6*x^6 - 7*x^5 - 7*x^4 + 7*x^2 + 7*x - 6
sol = solve(eq, x)
sol
```
```show(sol)
```
```plot(eq, (x, -1.1, 1.6))
```
```eq = 6*x^6 - 7*x^5 - 7*x^4 + 7*x^2 + 7*x - 6
complex_plot(eq, (-1.5, 2.1), (-1.5, 1.5))
```
```sage: P = polytopes.cube(intervals='zero_one') # obtain others than the standard cube
sage: P = matrix([[0,1,0],[0,1,1],[1,0,0]])*P  # linear transformations
sage: it = P.face_generator()                  # a (fast and efficient) face generator
sage: next(it)
```

## Generator for cube-connected cycles

```graphs.CubeConnectedCycle(3).plot()
```

## Manifolds

More functionalities in index notation for tensors

```E.<x,y> = EuclideanSpace()
v = E.vector_field(-y, x)
t = E.tensor_field(0, 2, [[1, x], [-2*y, x^2]])
v['j']*(t['_ij'] + t['_ji']) == v.contract(2*t.symmetrize())
```
```v
```
```t
```
```v['j'], t['_ij'],  t['_ji']
```
```t.symmetrize()
```
```
```
```
```
```
```
```
```
```
```
```@interact
def func(k = slider(0, 10, .1), j = (-10, 10), l = range_slider(-5, 5)):
print("k: %s" % k)
print("j: %s" % j)
print("l: [%s, %s]" % l)
```
```
```
```var('t y')
plot_slope_field(y - t, (t,0,10), (y,0,6), plot_points=25)
```
```
```
```
```

## Cellular Automata

```G = cellular_automata.GraftalLace([2,0,3,3,6,0,2,7])
G
```
```G.evolve(42)
G.plot()
```
```
```
```init = 200*
init = 0
init = 0
ECA = cellular_automata.Elementary(151, width=200, initial_state=init)
ECA
```
```ECA.evolve(200)
ECA.plot()
```
```
```
```
```

Torus

```from sage.plot.plot3d.shapes import Torus