CoCalc Public Filessage-9.2.ipynbOpen with one click!
Author: Harald Schilly
Views : 92
Compute Environment: Ubuntu 20.04 (Experimental)
In [1]:
version()
'SageMath version 9.2, Release Date: 2020-10-24'

NEW: 3D Animations!

In [32]:
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

In [6]:
from sage.matrix.benchmark import hilbert_matrix mat = hilbert_matrix(5).change_ring(CBF) mat.eigenvalues()
<ipython-input-6-175dab4ddc5a>:3: FutureWarning: This class/method/function is marked as experimental. It, its functionality or its interface might change without a formal deprecation. See https://trac.sagemath.org/30393 for details. mat.eigenvalues()
[[1.56705069109823 +/- 8.92e-15] + [+/- 5.27e-15]*I, [0.2085342186110 +/- 2.01e-14] + [+/- 5.27e-15]*I, [3.28792877e-6 +/- 7.64e-15] + [+/- 5.27e-15]*I, [0.00030589804015 +/- 6.67e-15] + [+/- 5.27e-15]*I, [0.01140749162342 +/- 5.68e-15] + [+/- 5.27e-15]*I]

Polyomino tilings

In [16]:
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()
In [17]:
%time solution = H.self_surrounding(10, ncpus=2)
CPU times: user 1.55 s, sys: 1.63 s, total: 3.18 s Wall time: 21.5 s
In [18]:
G = sum([p.show2d() for p in solution], Graphics()) G

Manifolds: diff function for exterior derivatives

In [20]:
M = Manifold(2, 'M') X.<x,y> = M.chart() f = M.scalar_field(x^2*y, name='f') diff(f)
1-form df on the 2-dimensional differentiable manifold M
In [21]:
diff(f).display()
df = 2*x*y dx + x^2 dy
In [23]:
a = M.one_form(-2*x*y, x, name='a'); a.display() diff(a).display()
da = (2*x + 1) dx/\dy

Differential Weyl algebra

In [24]:
W.<x,y> = DifferentialWeylAlgebra(QQ) dx, dy = W.differentials() dx.diff(x^3)
3*x^2
In [25]:
(x*dx + dy + 1).diff(x^4*y^4 + 1)
5*x^4*y^4 + 4*x^4*y^3 + 1

Temperley-Lieb diagrams now have unicode

In [26]:
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

In [2]:
x = var('x') eq = 6*x^6 - 7*x^5 - 7*x^4 + 7*x^2 + 7*x - 6 sol = solve(eq, x) sol
[x == (2/3), x == -1, x == (3/2), x == -1/2*I*sqrt(3) - 1/2, x == 1/2*I*sqrt(3) - 1/2, x == 1]
In [3]:
show(sol)
[x=(23),x=(1),x=(32),x=12i312,x=12i312,x=1]\left[x = \left(\frac{2}{3}\right), x = \left(-1\right), x = \left(\frac{3}{2}\right), x = -\frac{1}{2} i \, \sqrt{3} - \frac{1}{2}, x = \frac{1}{2} i \, \sqrt{3} - \frac{1}{2}, x = 1\right]
In [4]:
plot(eq, (x, -1.1, 1.6))
In [5]:
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))