# SAGE in action

some examples showing the abilites of SAGE

## basic calculus

 sqrt(pi)*((sqrt(2)*I + sqrt(2))*erf((sqrt(2)*I + sqrt(2))*x/2) + (sqrt(2)*I - sqrt(2))*erf((sqrt(2)*I - sqrt(2))*x/2))/8 sqrt(pi)*((sqrt(2)*I + sqrt(2))*erf((sqrt(2)*I + sqrt(2))*x/2) + (sqrt(2)*I - sqrt(2))*erf((sqrt(2)*I - sqrt(2))*x/2))/8
latex output
 \frac{{\sqrt{ \pi } \cdot \left( {\left( {\sqrt{ 2 } \cdot i} + \sqrt{ 2 } \right) \cdot \left( \text{erf} \left( \frac{{\left( {\sqrt{ 2 } \cdot i} + \sqrt{ 2 } \right) \cdot x}}{2} \right) \right)} + {\left( {\sqrt{ 2 } \cdot i} - \sqrt{ 2 } \right) \cdot \left( \text{erf} \left( \frac{{\left( {\sqrt{ 2 } \cdot i} - \sqrt{ 2 } \right) \cdot x}}{2} \right) \right)} \right)}}{8} \frac{{\sqrt{ \pi } \cdot \left( {\left( {\sqrt{ 2 } \cdot i} + \sqrt{ 2 } \right) \cdot \left( \text{erf} \left( \frac{{\left( {\sqrt{ 2 } \cdot i} + \sqrt{ 2 } \right) \cdot x}}{2} \right) \right)} + {\left( {\sqrt{ 2 } \cdot i} - \sqrt{ 2 } \right) \cdot \left( \text{erf} \left( \frac{{\left( {\sqrt{ 2 } \cdot i} - \sqrt{ 2 } \right) \cdot x}}{2} \right) \right)} \right)}}{8}
pretty print using jsmath (renderd inside the browser)
 8pÙÁÒ°p2Ái+p2ÑÁÒerfÒ2(p2Ái+p2)ÁxÓÓ+°p2ÁiÀp2ÑÁÒerfÒ2(p2ÁiÀp2)ÁxÓÓÓ  8pÙÁÒ°p2Ái+p2ÑÁÒerfÒ2(p2Ái+p2)ÁxÓÓ+°p2ÁiÀp2ÑÁÒerfÒ2(p2ÁiÀp2)ÁxÓÓÓ
 Vector space of dimension 3 over Real Field with 53 bits of precision Vector space of dimension 3 over Real Field with 53 bits of precision
 False False
 (1/28, -3, -1/2) (1/28, -3, -1/2)
 [x=r1; y=ÀpÀr13Àr1+5; z=Àr13À2Ár1+7];   [x=r2; y=pÀr23Àr2+5; z=Àr23À2Ár2+7];   [x=r1; y=ÀpÀr13Àr1+5; z=Àr13À2Ár1+7];   [x=r2; y=pÀr23Àr2+5; z=Àr23À2Ár2+7];  
 x |--> (x^3 + 5*x^2 + 2*x)/(2 - 3*x^3) x |--> (x^3 + 5*x^2 + 2*x)/(2 - 3*x^3)
 x |--> -1/3 x |--> -1/3
 x 7! 3Á(3Áx3À2)À15Áx2+6Áx+2À31 x 7! 3Á(3Áx3À2)À15Áx2+6Áx+2À31
 x 7! 9Áx6À12Áx3+415Áx4+12Áx3+6Áx2+20Áx+4  x 7! 9Áx6À12Áx3+415Áx4+12Áx3+6Áx2+20Áx+4
 -78/79 -78/79
 -0.98734177215189873417721518987341772151898734177215189873417721518\ 98734177215189873417721518987341772151898734177215189873417721518987\ 34177215189873417722 -0.987341772151898734177215189873417721518987341772151898734177215189873417721518987341772151898734177215189873417721518987341772151898734177215189873417722

## Arbitrary Precision Interval Arithmetics

 Real Interval Field with 150 bits of precision Real Interval Field with 150 bits of precision
 [2.0000000999999999999999999999999999999999999984 .. 2.0000001000000000000000000000000000000000000013] [2.0000000999999999999999999999999999999999999984 .. 2.0000001000000000000000000000000000000000000013]
 [7.1039990175447649168126806044014828532186237369e315652 .. 7.1039990175447649168126806044014828532394989976e315652] [7.1039990175447649168126806044014828532186237369e315652 .. 7.1039990175447649168126806044014828532394989976e315652]
 -1.9244198246303974986110659184666764220799913e-46 -1.9244198246303974986110659184666764220799913e-46
 True True
 8.4077907859489024255423774997394967876977518e-38 8.4077907859489024255423774997394967876977518e-38

## polynomial rings

 Univariate Polynomial Ring in x over Finite Field of size 5 Univariate Polynomial Ring in x over Finite Field of size 5
 4*x 4*x
 [(3, 1), (2, 1)] [(3, 1), (2, 1)]
 0 0
 [(-sqrt(7)/sqrt(3), 1), (sqrt(7)/sqrt(3), 1), (-sqrt(2)*I, 1), (sqrt(2)*I, 1)] [(-sqrt(7)/sqrt(3), 1), (sqrt(7)/sqrt(3), 1), (-sqrt(2)*I, 1), (sqrt(2)*I, 1)]
 [0, 0, 0, 0] [0, 0, 0, 0]
 Time: CPU 0.00 s, Wall: 0.02 s Time: CPU 2.74 s, Wall: 5.77 s Time: CPU 0.00 s, Wall: 0.02 s Time: CPU 2.74 s, Wall: 5.77 s
 Time: CPU 0.00 s, Wall: 0.04 s Time: CPU 0.28 s, Wall: 0.35 s Time: CPU 0.00 s, Wall: 0.04 s Time: CPU 0.28 s, Wall: 0.35 s
 [°23Àp3Ái;1Ñ; °2p3Ái+3;1Ñ; (À1;1)];   [°23Àp3Ái;1Ñ; °2p3Ái+3;1Ñ; (À1;1)];
 [(4;1);(6;2)] [(4;1);(6;2)]
 (x+3)Á(x+1)2  (x+3)Á(x+1)2
 0 0

### ring extension

 Univariate Polynomial Ring in x over Rational Field Univariate Polynomial Ring in x over Rational Field
 Univariate Quotient Polynomial Ring in a over Univariate Polynomial Ring in x over Rational Field with modulus a^2 + 5 Univariate Quotient Polynomial Ring in a over Univariate Polynomial Ring in x over Rational Field with modulus a^2 + 5
 Multivariate Polynomial Ring in x, y over Rational Field Multivariate Polynomial Ring in x, y over Rational Field
 Quotient of Multivariate Polynomial Ring in x, y over Rational Field by the ideal (x^2 + y^2) Quotient of Multivariate Polynomial Ring in x, y over Rational Field by the ideal (x^2 + y^2)
 Ring morphism: From: Multivariate Polynomial Ring in x, y over Rational Field To: Quotient of Multivariate Polynomial Ring in x, y over Rational Field by the ideal (x^2 + y^2) Defn: Natural quotient map Ring morphism: From: Multivariate Polynomial Ring in x, y over Rational Field To: Quotient of Multivariate Polynomial Ring in x, y over Rational Field by the ideal (x^2 + y^2) Defn: Natural quotient map
 Set-theoretic ring morphism: From: Quotient of Multivariate Polynomial Ring in x, y over Rational Field by the ideal (x^2 + y^2) To: Multivariate Polynomial Ring in x, y over Rational Field Defn: Choice of lifting map Set-theoretic ring morphism: From: Quotient of Multivariate Polynomial Ring in x, y over Rational Field by the ideal (x^2 + y^2) To: Multivariate Polynomial Ring in x, y over Rational Field Defn: Choice of lifting map
 x x
 y y
 0 0
 -x*y^2 -x*y^2
 -x*y^2 -x*y^2
 x x
 Number Field in a with defining polynomial x^4 + 1 Number Field in a with defining polynomial x^4 + 1
 Vector space of dimension 4 over Rational Field Isomorphism from Vector space of dimension 4 over Rational Field to Number Field in a with defining polynomial x^4 + 1 Isomorphism from Number Field in a with defining polynomial x^4 + 1 to Vector space of dimension 4 over Rational Field Vector space of dimension 4 over Rational Field Isomorphism from Vector space of dimension 4 over Rational Field to Number Field in a with defining polynomial x^4 + 1 Isomorphism from Number Field in a with defining polynomial x^4 + 1 to Vector space of dimension 4 over Rational Field
 5*a^3 + 4 5*a^3 + 4
 (0, 2, 0, -1/2) (0, 2, 0, -1/2)
 [Ring morphism: From: Number Field in a with defining polynomial x^4 + 1 To: Complex Field with 53 bits of precision Defn: a |--> -0.707106781186548 - 0.707106781186548*I, Ring morphism: From: Number Field in a with defining polynomial x^4 + 1 To: Complex Field with 53 bits of precision Defn: a |--> -0.707106781186547 + 0.707106781186547*I, Ring morphism: From: Number Field in a with defining polynomial x^4 + 1 To: Complex Field with 53 bits of precision Defn: a |--> 0.707106781186548 - 0.707106781186547*I, Ring morphism: From: Number Field in a with defining polynomial x^4 + 1 To: Complex Field with 53 bits of precision Defn: a |--> 0.707106781186548 + 0.707106781186548*I] [Ring morphism: From: Number Field in a with defining polynomial x^4 + 1 To: Complex Field with 53 bits of precision Defn: a |--> -0.707106781186548 - 0.707106781186548*I, Ring morphism: From: Number Field in a with defining polynomial x^4 + 1 To: Complex Field with 53 bits of precision Defn: a |--> -0.707106781186547 + 0.707106781186547*I, Ring morphism: From: Number Field in a with defining polynomial x^4 + 1 To: Complex Field with 53 bits of precision Defn: a |--> 0.707106781186548 - 0.707106781186547*I, Ring morphism: From: Number Field in a with defining polynomial x^4 + 1 To: Complex Field with 53 bits of precision Defn: a |--> 0.707106781186548 + 0.707106781186548*I]
 (2,3,4) (2,3,4)
 24 24
 [ 1 -1 1 1 -1] [ 3 -1 -1 0 1] [ 2 0 2 -1 0] [ 3 1 -1 0 -1] [ 1 1 1 1 1] [ 1 -1 1 1 -1] [ 3 -1 -1 0 1] [ 2 0 2 -1 0] [ 3 1 -1 0 -1] [ 1 1 1 1 1]
 Alternating group of order 5!/2 as a permutation group Alternating group of order 5!/2 as a permutation group

## benchmarking calculation time in Q

 Multivariate Polynomial Ring in x, y, z over Rational Field Multivariate Polynomial Ring in x, y, z over Rational Field
 Time: CPU 2.86 s, Wall: 5.39 s Time: CPU 2.86 s, Wall: 5.39 s

## ideals and gröbner basis

 Ideal (2*x^2 + 4*y, 2*x^2 - y + z) of Multivariate Polynomial Ring in x, y, z over Rational Field Ideal (2*x^2 + 4*y, 2*x^2 - y + z) of Multivariate Polynomial Ring in x, y, z over Rational Field
 [y - 1/5*z, x^2 + 2/5*z] [y - 1/5*z, x^2 + 2/5*z]

## matrix groups

 Special Linear Group of degree 2 over Integer Ring Special Linear Group of degree 2 over Integer Ring
 [ [ 0 1] [-1 0], [1 1] [0 1] ] [ [ 0 1] [-1 0], [1 1] [0 1] ]
  
 General Unitary Group of degree 3 over Finite Field of size 7 General Unitary Group of degree 3 over Finite Field of size 7
 [5*a + 5 5*a + 2 4*a + 2] [ a + 4 6*a + 4 4*a + 1] [5*a + 5 0 2*a] [5*a + 5 5*a + 2 4*a + 2] [ a + 4 6*a + 4 4*a + 1] [5*a + 5 0 2*a]
 Matrix group over Finite Field in a of size 7^2 with 2 generators: [[[6, 0, 0], [0, 6, 0], [0, 0, 6]], [[2*a + 4, 0, 0], [0, 2*a + 4, 0], [0, 0, 2*a + 4]]] Matrix group over Finite Field in a of size 7^2 with 2 generators: [[[6, 0, 0], [0, 6, 0], [0, 0, 6]], [[2*a + 4, 0, 0], [0, 2*a + 4, 0], [0, 0, 2*a + 4]]]
 45308928 45308928
 Vector space of degree 40 and dimension 39 over Finite Field of size 3 Basis matrix: 39 x 40 dense matrix over Finite Field of size 3 Vector space of degree 40 and dimension 39 over Finite Field of size 3 Basis matrix: 39 x 40 dense matrix over Finite Field of size 3
 Vector space of degree 40 and dimension 1 over Finite Field of size 3 Basis matrix: [0 1 2 2 0 1 1 0 0 0 1 0 1 0 0 2 1 0 0 1 1 1 0 2 2 0 1 2 1 1 0 0 2 0 2 0 0 0 0 0] Vector space of degree 40 and dimension 1 over Finite Field of size 3 Basis matrix: [0 1 2 2 0 1 1 0 0 0 1 0 1 0 0 2 1 0 0 1 1 1 0 2 2 0 1 2 1 1 0 0 2 0 2 0 0 0 0 0]
kernel from left!
 (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
extension of Q  with °7=p7À1
 [ 2*zeta7^3 -1] [ 0 -zeta7] [ 0 -zeta7^5 - 1] [ 1 zeta7^3 - 1] [ 2*zeta7^3 -1] [ 0 -zeta7] [ 0 -zeta7^5 - 1] [ 1 zeta7^3 - 1]
 Vector space of degree 4 and dimension 2 over Cyclotomic Field of order 7 and degree 6 Basis matrix: [ 1 0 zeta7^5 + zeta7^4 + 2*zeta7^3 - zeta7 -2*zeta7^3] [ 0 1 -zeta7^4 - zeta7^3 - zeta7 - 1 0] Vector space of degree 4 and dimension 2 over Cyclotomic Field of order 7 and degree 6 Basis matrix: [ 1 0 zeta7^5 + zeta7^4 + 2*zeta7^3 - zeta7 -2*zeta7^3] [ 0 1 -zeta7^4 - zeta7^3 - zeta7 - 1 0]
 ï1 0 0 1 °75+°74+2°73À°7 À°74À°73À°7À1 À2°73 0  !  ï1 0 0 1 °75+°74+2°73À°7 À°74À°73À°7À1 À2°73 0  !
 (0, 0) (0, 0)

### different calculations with matrix visualization

 [ 0.0 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0] [ 9.0 10.0 11.0 12.0 13.0 14.0 15.0 16.0 17.0] [18.0 19.0 20.0 21.0 22.0 23.0 24.0 25.0 26.0] [27.0 28.0 29.0 30.0 31.0 32.0 33.0 34.0 35.0] [ 0.0 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0] [ 9.0 10.0 11.0 12.0 13.0 14.0 15.0 16.0 17.0] [18.0 19.0 20.0 21.0 22.0 23.0 24.0 25.0 26.0] [27.0 28.0 29.0 30.0 31.0 32.0 33.0 34.0 35.0]
 39 x 39 dense matrix over Finite Field of size 3 39 x 39 dense matrix over Finite Field of size 3

## rule based calculation of a matrix with graph

 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16] [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]
 [[0, 15, 13], [0, 15, 16], [0, 9]] [[0, 15, 13], [0, 15, 16], [0, 9]]
 [(0, 9, None), (0, 13, None), (0, 15, None), (0, 16, None), (1, 9, None), (1, 10, None), (1, 14, None), (2, 10, None), (2, 11, None), (3, 7, None), (3, 11, None), (3, 12, None), (4, 5, None), (4, 6, None), (4, 8, None), (4, 12, None)] [(0, 9, None), (0, 13, None), (0, 15, None), (0, 16, None), (1, 9, None), (1, 10, None), (1, 14, None), (2, 10, None), (2, 11, None), (3, 7, None), (3, 11, None), (3, 12, None), (4, 5, None), (4, 6, None), (4, 8, None), (4, 12, None)]
 [[5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16], [0], [1], [2], [3], [4]] [[5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16], [0], [1], [2], [3], [4]]

### included library of graphs

 4 4

### Directed Graphs

 Paths in Multi-digraph on 7 vertices Paths in Multi-digraph on 7 vertices
 [[5], [1, 5], [4, 5], [2, 4, 5], [1, 2, 4, 5], [1, 2, 4, 5], [3, 4, 5], [1, 3, 4, 5], [2, 3, 4, 5], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5]] [[5], [1, 5], [4, 5], [2, 4, 5], [1, 2, 4, 5], [1, 2, 4, 5], [3, 4, 5], [1, 3, 4, 5], [2, 3, 4, 5], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5]]
 [4] has length 1 [2, 4] has length 2 [1, 2, 4] has length 3 [1, 2, 4] has length 3 [3, 4] has length 2 [1, 3, 4] has length 3 [2, 3, 4] has length 3 [1, 2, 3, 4] has length 4 [1, 2, 3, 4] has length 4 [4] has length 1 [2, 4] has length 2 [1, 2, 4] has length 3 [1, 2, 4] has length 3 [3, 4] has length 2 [1, 3, 4] has length 3 [2, 3, 4] has length 3 [1, 2, 3, 4] has length 4 [1, 2, 3, 4] has length 4

## included library of elliptic curves

 Elliptic Curve defined by y^2 + y = x^3 - 7*x + 6 over Rational Field Elliptic Curve defined by y^2 + y = x^3 - 7*x + 6 over Rational Field
 [(1 : 0 : 1), (2 : 0 : 1), (-3 : 0 : 1), (1 : -1 : 1), (2 : -1 : 1), (-3 : -1 : 1), (0 : 2 : 1), (-1 : 3 : 1), (-2 : 3 : 1), (3 : 3 : 1), (0 : -3 : 1), (-1 : -4 : 1), (-2 : -4 : 1), (3 : -4 : 1), (0 : 1 : 0)] [(1 : 0 : 1), (2 : 0 : 1), (-3 : 0 : 1), (1 : -1 : 1), (2 : -1 : 1), (-3 : -1 : 1), (0 : 2 : 1), (-1 : 3 : 1), (-2 : 3 : 1), (3 : 3 : 1), (0 : -3 : 1), (-1 : -4 : 1), (-2 : -4 : 1), (3 : -4 : 1), (0 : 1 : 0)]

### change base ring and plot over finite field

 Elliptic Curve defined by y^2 + y = x^3 + 990*x + 6 over Finite Field of size 997 Elliptic Curve defined by y^2 + y = x^3 + 990*x + 6 over Finite Field of size 997
 949 949
 Elliptic Curve defined by y^2 + 2765*y = x^3 + 100000000000000000038*x^2 + 765465*x + 99999999999999994394 over Finite Field of size 100000000000000000039 and it's cardinality is: 99999999993684546596 Elliptic Curve defined by y^2 + 2765*y = x^3 + 100000000000000000038*x^2 + 765465*x + 99999999999999994394 over Finite Field of size 100000000000000000039 and it's cardinality is: 99999999993684546596
 (Multiplicative Abelian Group isomorphic to C949, ((324 : 505 : 1),)) (Multiplicative Abelian Group isomorphic to C949, ((324 : 505 : 1),))
 f^713 f^713
 Projective Curve over Finite Field of size 7 defined by -x^8*z + y^2*z^7 - x*z^8 Projective Curve over Finite Field of size 7 defined by -x^8*z + y^2*z^7 - x*z^8
 [(0:0:1); (0:1:0); (1:0:0); (1:1:0); (1:3:1); (1:4:1); (2:1:0); (3:1:0); (4:1:0); (5:1:0); (5:3:1); (5:4:1); (6:0:1); (6:1:0)];   [(0:0:1); (0:1:0); (1:0:0); (1:1:0); (1:3:1); (1:4:1); (2:1:0); (3:1:0); (4:1:0); (5:1:0); (5:3:1); (5:4:1); (6:0:1); (6:1:0)];
 0 0

## coding theory

 Linear code of length 6, dimension 4 over Finite Field of size 5 Linear code of length 6, dimension 4 over Finite Field of size 5
 3 3
 (0, 3, 4, 1, 3, 4) (0, 3, 4, 1, 3, 4)
 [4 4 1 0 0 0] [3 4 0 1 0 0] [1 4 0 0 1 0] [2 4 0 0 0 1] [4 4 1 0 0 0] [3 4 0 1 0 0] [1 4 0 0 1 0] [2 4 0 0 0 1]
 [1 2 3 4 1 0] [4 4 3 2 0 1] [1 2 3 4 1 0] [4 4 3 2 0 1]
 [1 2 3 4 1 0] [4 4 3 2 0 1] [1 2 3 4 1 0] [4 4 3 2 0 1]
 [4 4 1 0 0 0] [3 4 0 1 0 0] [1 4 0 0 1 0] [2 4 0 0 0 1] [4 4 1 0 0 0] [3 4 0 1 0 0] [1 4 0 0 1 0] [2 4 0 0 0 1]
 [0 0 1 2 1 2] [0 0 1 2 1 2]
 (0, 4, 1, 2, 1, 2) (0, 4, 1, 2, 1, 2)

## embedded compilation in cython

 5003498500 CPU time: 26.39 s, Wall time: 52.70 s 5003498500 CPU time: 26.39 s, Wall time: 52.70 s
  
 5003498500L CPU time: 1.70 s, Wall time: 2.93 s 5003498500L CPU time: 1.70 s, Wall time: 2.93 s