Sage is available at http://www.sagemath.org
Use its online notebook for trying-out!
Disclaimer:
This notes are an introduction to SageMath, and most of details were ommited. These will be carefully filled in during classes.
Assignment & Arithmetic
2 2 |
True True |
False False |
True True |
True True |
1 1 |
1/2*pi 1/2*pi |
1.57079632679490 1.57079632679490 |
|
|
3.1415926535897932384626433832795028841971694 3.1415926535897932384626433832795028841971694 |
-1.0000000000000000000000000000000000000000000 -1.0000000000000000000000000000000000000000000 |
-1 -1 |
<type 'sage.symbolic.expression.Expression'> <type 'sage.symbolic.expression.Expression'> |
<type 'sage.rings.real_mpfr.RealNumber'> <type 'sage.rings.real_mpfr.RealNumber'> |
Changing types on-the-fly...
|
|
<type 'sage.rings.integer.Integer'> <type 'sage.rings.integer.Integer'> |
11/3 11/3 |
<type 'sage.rings.rational.Rational'> <type 'sage.rings.rational.Rational'> |
Changing basis...
['1010', '111'] ['1010', '111'] |
'1010111' '1010111' |
Just add "?" at the end of the command.
Use autocompletion pressing the TAB key.
|
File: /home/pedro/sage-4.7/devel/sage/sage/rings/integer_ring.pyx Type: <type ‘builtin_function_or_method’> Definition: IntegerRing() Docstring:
File: /home/pedro/sage-4.7/devel/sage/sage/rings/integer_ring.pyx Type: <type ‘builtin_function_or_method’> Definition: IntegerRing() Docstring:
|
|
File: /home/pedro/sage-4.7/local/lib/python2.6/site-packages/sage/rings/arith.py Type: <type ‘function’> Definition: factor(n, proof=None, int_=False, algorithm=’pari’, verbose=0, **kwds) Docstring:
|
Define your own functions.
|
|
|
|
|
|
|
|
[[x == (10/3), y == (-2/3)]] [[x == (10/3), y == (-2/3)]] |
[x == -1/2*b - 1/2*sqrt(b^2 - 4*c), x == -1/2*b + 1/2*sqrt(b^2 - 4*c)] [x == -1/2*b - 1/2*sqrt(b^2 - 4*c), x == -1/2*b + 1/2*sqrt(b^2 - 4*c)] |
|
|
Scaling matters!
|
|
The command show(c, aspect_ratio=1) accomplishes the same thing, or you can save the picture using c.save('filename.png',aspect_ratio=1).
|
|
|
|
|
|
|
|
|
|
|
|
3D!
|
|
|
|
|
|
Click to the left again to hide and once more to show the dynamic interactive window |
Click to the left again to hide and once more to show the dynamic interactive window |
Click to the left again to hide and once more to show the dynamic interactive window |
Click to the left again to hide and once more to show the dynamic interactive window |
|
|
|
|
5 5 |
True True |
|
|
False False |
Finite Field in a of size 2^3 Finite Field in a of size 2^3 |
[0, a, a^2, a + 1, a^2 + a, a^2 + a + 1, a^2 + 1, 1] [0, a, a^2, a + 1, a^2 + a, a^2 + a + 1, a^2 + 1, 1] |
2 2 |
Constructing the Galois field.
|
|
|
|
|
|
<type 'sage.rings.polynomial.polynomial_gf2x.Polynomial_GF2X'> <type 'sage.rings.polynomial.polynomial_gf2x.Polynomial_GF2X'> |
True True |
True True |
x^3 + x + 1 x^3 + x + 1 |
Univariate Quotient Polynomial Ring in x over Finite Field of size 2 with modulus x^3 + x + 1 Univariate Quotient Polynomial Ring in x over Finite Field of size 2 with modulus x^3 + x + 1 |
|
|
<class 'sage.rings.polynomial.polynomial_quotient_ring_element.PolynomialQuotie\ ntRingElement'> <class 'sage.rings.polynomial.polynomial_quotient_ring_element.PolynomialQuotientRingElement'> |
True True |
<type 'sage.rings.polynomial.polynomial_gf2x.Polynomial_GF2X'> <type 'sage.rings.polynomial.polynomial_gf2x.Polynomial_GF2X'> |
x^2 + x x^2 + x |
8 8 |
[(1, x + 1), (2, x^2 + 1), (3, x^2), (4, x^2 + x + 1), (5, x), (6, x^2 + x), (7, 1)] [(1, x + 1), (2, x^2 + 1), (3, x^2), (4, x^2 + x + 1), (5, x), (6, x^2 + x), (7, 1)] |
|
|
x^2 + 1 x^2 + 1 |
x^2 + x x^2 + x |
x + 1 x + 1 |
[(1, x), (2, x^2), (3, x + 1), (4, x^2 + x), (5, x^2 + x + 1), (6, x^2 + 1), (7, 1)] [(1, x), (2, x^2), (3, x + 1), (4, x^2 + x), (5, x^2 + x + 1), (6, x^2 + 1), (7, 1)] |
We have considered the euclidean domain \mathbb{Z}_2 [x] and its irreducible element pol(x)=x^3+x+1, which in turn is equivalent to the ideal (pol(x)) being maximal.
The quocient \mathbb{F}=\mathbb{Z}_2[x] /(pol(x)) is a field and \mathbb{F}^* is a cyclic group with order 2^3-1=7.
|
|
x^7 + x + 1 x^7 + x + 1 |
|
|
[x^10 + x^6 + x^5 + x^3 + x^2 + x + 1, Finite Field in x of size 2^10, 827] [x^10 + x^6 + x^5 + x^3 + x^2 + x + 1, Finite Field in x of size 2^10, 827] |
|
|
x^3 + x + 1 x^3 + x + 1 |
[ 1 3 2 6] [ 3 5 2 1] [ 6 0 1 -1] [ 1 3 2 6] [ 3 5 2 1] [ 6 0 1 -1] |
[ 1 1 7 37] [ 0 2 9 48] [ 0 0 14 79] [ 1 1 7 37] [ 0 2 9 48] [ 0 0 14 79] |
Free module of degree 4 and rank 3 over Integer Ring Echelon basis matrix: [ 1 1 7 37] [ 0 2 9 48] [ 0 0 14 79] Free module of degree 4 and rank 3 over Integer Ring Echelon basis matrix: [ 1 1 7 37] [ 0 2 9 48] [ 0 0 14 79] |
|
|
[ 1 3 2 6] [ 3 5 2 1] [ 6 0 1 10] [ 1 3 2 6] [ 3 5 2 1] [ 6 0 1 10] |
1 1 |
[ 1 0 0 4] [ 0 1 0 10] [ 0 0 1 8] [ 1 0 0 4] [ 0 1 0 10] [ 0 0 1 8] |
|
|
Finite Field in x of size 2^7 Finite Field in x of size 2^7 |
x^7 + x + 1 x^7 + x + 1 |
Full MatrixSpace of 3 by 3 dense matrices over Finite Field in x of size 2^7 Full MatrixSpace of 3 by 3 dense matrices over Finite Field in x of size 2^7 |
[ x^5 + x^4 + x^3 + x^2 + x + 1 x^3 + x + 1 x^6 + x^5 + x^4 + x^3 + x^2 + x] [ x^4 + x x^5 + x^4 + x^3 + 1 x^6 + x^5 + 1] [ x^6 + x^3 + x^2 + x + 1 x^6 + x^5 + x^3 + x^2 + x + 1 x^6 + x^5 + x^4 + x^2 + x + 1] [ x^5 + x^4 + x^3 + x^2 + x + 1 x^3 + x + 1 x^6 + x^5 + x^4 + x^3 + x^2 + x] [ x^4 + x x^5 + x^4 + x^3 + 1 x^6 + x^5 + 1] [ x^6 + x^3 + x^2 + x + 1 x^6 + x^5 + x^3 + x^2 + x + 1 x^6 + x^5 + x^4 + x^2 + x + 1] |
x^6 + x^4 + 1 x^6 + x^4 + 1 |
[ x^5 + x^4 + x^3 + x^2 + x + 1 x^3 + x + 1 x^6 + x^5 + x^4 + x^3 + x^2 + x] [ x^4 + x x^5 + x^4 + x^3 + 1 x^6 + x^5 + 1] [ x^5 + x^3 + x^2 + 1 x^5 + x^4 + x x^4 + x^3 + x^2 + x + 1] [ x^5 + x^4 + x^3 + x^2 + x + 1 x^3 + x + 1 x^6 + x^5 + x^4 + x^3 + x^2 + x] [ x^4 + x x^5 + x^4 + x^3 + 1 x^6 + x^5 + 1] [ x^5 + x^3 + x^2 + 1 x^5 + x^4 + x x^4 + x^3 + x^2 + x + 1] |
0 0 |
\newcommand{\Bold}[1]{\mathbf{#1}}\left(\begin{array}{rrr}
1 & 0 & x^{6} + x^{4} + x^{3} + x^{2} \\
0 & 1 & x^{5} + x^{4} + x^{2} + x + 1 \\
0 & 0 & 0
\end{array}\right)
\newcommand{\Bold}[1]{\mathbf{#1}}\left(\begin{array}{rrr}
1 & 0 & x^{6} + x^{4} + x^{3} + x^{2} \\
0 & 1 & x^{5} + x^{4} + x^{2} + x + 1 \\
0 & 0 & 0
\end{array}\right)
|
\left(\begin{array}{rrr}
1 & 0 & x^{6} + x^{4} + x^{3} + x^{2} \\
0 & 1 & x^{5} + x^{4} + x^{2} + x + 1 \\
0 & 0 & 0
\end{array}\right)
\left(\begin{array}{rrr}
1 & 0 & x^{6} + x^{4} + x^{3} + x^{2} \\
0 & 1 & x^{5} + x^{4} + x^{2} + x + 1 \\
0 & 0 & 0
\end{array}\right)
|
|
|
Euclid's algorithm allows to compute the gcd of the integers a,b, n.s.z., and also to solve the linear equation ax+by=(a,b), with x,y\in \mathbb{Z}.
(1, 15, -19) (1, 15, -19) |
1 1 |
Set P as the set of prime numbers..
Set of all prime numbers: 2, 3, 5, 7, ... Set of all prime numbers: 2, 3, 5, 7, ... |
[4, 6, 8, 9, 10, 12, 14, 15, 16, 18, 20, 21, 22, 24, 25, 26, 27, 28, 30, 32, 33, 34, 35, 36, 38, 39] [4, 6, 8, 9, 10, 12, 14, 15, 16, 18, 20, 21, 22, 24, 25, 26, 27, 28, 30, 32, 33, 34, 35, 36, 38, 39] |
[2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37] [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37] |
Create your own function that show the non primes \le n.
|
|
Twin primes...
[[3, 5], [5, 7], [11, 13], [17, 19], [29, 31], [41, 43], [59, 61], [71, 73], [101, 103], [107, 109], [137, 139], [149, 151], [179, 181], [191, 193], [197, 199]] [[3, 5], [5, 7], [11, 13], [17, 19], [29, 31], [41, 43], [59, 61], [71, 73], [101, 103], [107, 109], [137, 139], [149, 151], [179, 181], [191, 193], [197, 199]] |
|
|
([[3, 5], [5, 7], [11, 13], [17, 19], [29, 31], [41, 43], [59, 61], [71, 73], [101, 103], [107, 109], [137, 139], [149, 151], [179, 181], [191, 193], [197, 199], [227, 229], [239, 241], [269, 271], [281, 283], [311, 313], [347, 349], [419, 421], [431, 433], [461, 463], [521, 523], [569, 571], [599, 601], [617, 619], [641, 643], [659, 661], [809, 811], [821, 823], [827, 829], [857, 859], [881, 883], [1019, 1021], [1031, 1033], [1049, 1051], [1061, 1063], [1091, 1093], [1151, 1153], [1229, 1231], [1277, 1279], [1289, 1291], [1301, 1303], [1319, 1321], [1427, 1429], [1451, 1453], [1481, 1483], [1487, 1489], [1607, 1609], [1619, 1621], [1667, 1669], [1697, 1699], [1721, 1723], [1787, 1789], [1871, 1873], [1877, 1879], [1931, 1933], [1949, 1951], [1997, 1999]], 61) ([[3, 5], [5, 7], [11, 13], [17, 19], [29, 31], [41, 43], [59, 61], [71, 73], [101, 103], [107, 109], [137, 139], [149, 151], [179, 181], [191, 193], [197, 199], [227, 229], [239, 241], [269, 271], [281, 283], [311, 313], [347, 349], [419, 421], [431, 433], [461, 463], [521, 523], [569, 571], [599, 601], [617, 619], [641, 643], [659, 661], [809, 811], [821, 823], [827, 829], [857, 859], [881, 883], [1019, 1021], [1031, 1033], [1049, 1051], [1061, 1063], [1091, 1093], [1151, 1153], [1229, 1231], [1277, 1279], [1289, 1291], [1301, 1303], [1319, 1321], [1427, 1429], [1451, 1453], [1481, 1483], [1487, 1489], [1607, 1609], [1619, 1621], [1667, 1669], [1697, 1699], [1721, 1723], [1787, 1789], [1871, 1873], [1877, 1879], [1931, 1933], [1949, 1951], [1997, 1999]], 61) |
Interact...
Click to the left again to hide and once more to show the dynamic interactive window |
Fermat's little theorem: n prime implies a^{n-1}\equiv 1 \text{ mod } n, if (a,n)=1., This gives an elementary way for checking if a number is not prime.
2848515765597237675947403497177089 2848515765597237675947403497177089 |
Traceback (click to the left of this block for traceback) ... RuntimeError: exponent must be at most 9223372036854775807 Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "_sage_input_4.py", line 10, in <module>
exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8 -*-\\n" + _support_.preparse_worksheet_cell(base64.b64decode("Ml4obi0xKSVu"),globals())+"\\n"); execfile(os.path.abspath("___code___.py"))
File "", line 1, in <module>
File "/tmp/tmpnxvD2p/___code___.py", line 3, in <module>
exec compile(u'_sage_const_2 **(n-_sage_const_1 )%n
File "", line 1, in <module>
File "integer.pyx", line 1839, in sage.rings.integer.Integer.__pow__ (sage/rings/integer.c:13120)
RuntimeError: exponent must be at most 9223372036854775807
|
This gives an overflow error. We may avoid this by using a fast modular exponential algorithm.
Or by taking, in sagemath, the right algebraic struture.
Ring of integers modulo 2848515765597237675947403497177089 Ring of integers modulo 2848515765597237675947403497177089 |
825326789816013506777461377270418 825326789816013506777461377270418 |
825326789816013506777461377270418 825326789816013506777461377270418 |
13 * 1263499 * 173420475484059478781201647 13 * 1263499 * 173420475484059478781201647 |
False False |
We may also compute the multicative inverse of an element, in case it exists.
2114271018564409330905060359705976 2114271018564409330905060359705976 |
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 380, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 396, 397, 398, 399, 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, 418, 419, 420, 421, 422, 423, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 439, 440, 441, 442, 443, 444, 445, 446, 447, 448, 449, 450, 451, 452, 453, 454, 455, 456, 457, 458, 459, 460, 461, 462, 463, 464, 465, 466, 467, 468, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 481, 482, 483, 484, 485, 486, 487, 488, 489, 490, 491, 492, 493, 494, 495, 496, 497, 498, 499, 500, 501, 502, 503, 504, 505, 506, 507, 508, 509, 510, 511, 512, 513, 514, 515, 516, 517, 518, 519, 520, 521, 522, 523, 524, 525, 526, 527, 528, 529, 530, 531, 532, 533, 534, 535, 536, 537, 538, 539, 540, 541, 542, 543, 544, 545, 546, 547, 548, 549, 550, 551, 552, 553, 554, 555, 556, 557, 558, 559, 560, 561, 562, 563, 564, 565, 566, 567, 568, 569, 570, 571, 572, 573, 574, 575, 576, 577, 578, 579, 580, 581, 582, 583, 584, 585, 586, 587, 588, 589, 590, 591, 592, 593, 594, 595, 596, 597, 598, 599, 600, 601, 602, 603, 604, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 617, 618, 619, 620, 621, 622, 623, 624, 625, 626, 627, 628, 629, 630, 631, 632, 633, 634, 635, 636, 637, 638, 639, 640, 641, 642, 643, 644, 645, 646, 647, 648, 649, 650, 651, 652, 653, 654, 655, 656, 657, 658, 659, 660, 661, 662, 663, 664, 665, 666, 667, 668, 669, 670, 671, 672, 673, 674, 675, 676, 677, 678, 679, 680, 681, 682, 683, 684, 685, 686, 687, 688, 689, 690, 691, 692, 693, 694, 695, 696, 697, 698, 699, 700, 701, 702, 703, 704, 705, 706, 707, 708, 709, 710, 711, 712, 713, 714, 715, 716, 717, 718, 719, 720, 721, 722, 723, 724, 725, 726, 727, 728, 729, 730, 731, 732, 733, 734, 735, 736, 737, 738, 739, 740, 741, 742, 743, 744, 745, 746, 747, 748, 749, 750, 751, 752, 753, 754, 755, 756, 757, 758, 759, 760, 761, 762, 763, 764, 765, 766, 767, 768, 769, 770, 771, 772, 773, 774, 775, 776, 777, 778, 779, 780, 781, 782, 783, 784, 785, 786, 787, 788, 789, 790, 791, 792, 793, 794, 795, 796, 797, 798, 799, 800, 801, 802, 803, 804, 805, 806, 807, 808, 809, 810, 811, 812, 813, 814, 815, 816, 817, 818, 819, 820, 821, 822, 823, 824, 825, 826, 827, 828, 829, 830, 831, 832, 833, 834, 835, 836, 837, 838, 839, 840, 841, 842, 843, 844, 845, 846, 847, 848, 849, 850, 851, 852, 853, 854, 855, 856, 857, 858, 859, 860, 861, 862, 863, 864, 865, 866, 867, 868, 869, 870, 871, 872, 873, 874, 875, 876, 877, 878, 879, 880, 881, 882, 883, 884, 885, 886, 887, 888, 889, 890, 891, 892, 893, 894, 895, 896, 897, 898, 899, 900, 901, 902, 903, 904, 905, 906, 907, 908, 909, 910, 911, 912, 913, 914, 915, 916, 917, 918, 919, 920, 921, 922, 923, 924, 925, 926, 927, 928, 929, 930, 931, 932, 933, 934, 935, 936, 937, 938, 939, 940, 941, 942, 943, 944, 945, 946, 947, 948, 949, 950, 951, 952, 953, 954, 955, 956, 957, 958, 959, 960, 961, 962, 963, 964, 965, 966, 967, 968, 969, 970, 971, 972, 973, 974, 975, 976, 977, 978, 979, 980, 981, 982, 983, 984, 985, 986, 987, 988, 989, 990, 991, 992, 993, 994, 995, 996, 997, 998, 999] [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 380, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 396, 397, 398, 399, 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, 418, 419, 420, 421, 422, 423, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 439, 440, 441, 442, 443, 444, 445, 446, 447, 448, 449, 450, 451, 452, 453, 454, 455, 456, 457, 458, 459, 460, 461, 462, 463, 464, 465, 466, 467, 468, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 481, 482, 483, 484, 485, 486, 487, 488, 489, 490, 491, 492, 493, 494, 495, 496, 497, 498, 499, 500, 501, 502, 503, 504, 505, 506, 507, 508, 509, 510, 511, 512, 513, 514, 515, 516, 517, 518, 519, 520, 521, 522, 523, 524, 525, 526, 527, 528, 529, 530, 531, 532, 533, 534, 535, 536, 537, 538, 539, 540, 541, 542, 543, 544, 545, 546, 547, 548, 549, 550, 551, 552, 553, 554, 555, 556, 557, 558, 559, 560, 561, 562, 563, 564, 565, 566, 567, 568, 569, 570, 571, 572, 573, 574, 575, 576, 577, 578, 579, 580, 581, 582, 583, 584, 585, 586, 587, 588, 589, 590, 591, 592, 593, 594, 595, 596, 597, 598, 599, 600, 601, 602, 603, 604, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 617, 618, 619, 620, 621, 622, 623, 624, 625, 626, 627, 628, 629, 630, 631, 632, 633, 634, 635, 636, 637, 638, 639, 640, 641, 642, 643, 644, 645, 646, 647, 648, 649, 650, 651, 652, 653, 654, 655, 656, 657, 658, 659, 660, 661, 662, 663, 664, 665, 666, 667, 668, 669, 670, 671, 672, 673, 674, 675, 676, 677, 678, 679, 680, 681, 682, 683, 684, 685, 686, 687, 688, 689, 690, 691, 692, 693, 694, 695, 696, 697, 698, 699, 700, 701, 702, 703, 704, 705, 706, 707, 708, 709, 710, 711, 712, 713, 714, 715, 716, 717, 718, 719, 720, 721, 722, 723, 724, 725, 726, 727, 728, 729, 730, 731, 732, 733, 734, 735, 736, 737, 738, 739, 740, 741, 742, 743, 744, 745, 746, 747, 748, 749, 750, 751, 752, 753, 754, 755, 756, 757, 758, 759, 760, 761, 762, 763, 764, 765, 766, 767, 768, 769, 770, 771, 772, 773, 774, 775, 776, 777, 778, 779, 780, 781, 782, 783, 784, 785, 786, 787, 788, 789, 790, 791, 792, 793, 794, 795, 796, 797, 798, 799, 800, 801, 802, 803, 804, 805, 806, 807, 808, 809, 810, 811, 812, 813, 814, 815, 816, 817, 818, 819, 820, 821, 822, 823, 824, 825, 826, 827, 828, 829, 830, 831, 832, 833, 834, 835, 836, 837, 838, 839, 840, 841, 842, 843, 844, 845, 846, 847, 848, 849, 850, 851, 852, 853, 854, 855, 856, 857, 858, 859, 860, 861, 862, 863, 864, 865, 866, 867, 868, 869, 870, 871, 872, 873, 874, 875, 876, 877, 878, 879, 880, 881, 882, 883, 884, 885, 886, 887, 888, 889, 890, 891, 892, 893, 894, 895, 896, 897, 898, 899, 900, 901, 902, 903, 904, 905, 906, 907, 908, 909, 910, 911, 912, 913, 914, 915, 916, 917, 918, 919, 920, 921, 922, 923, 924, 925, 926, 927, 928, 929, 930, 931, 932, 933, 934, 935, 936, 937, 938, 939, 940, 941, 942, 943, 944, 945, 946, 947, 948, 949, 950, 951, 952, 953, 954, 955, 956, 957, 958, 959, 960, 961, 962, 963, 964, 965, 966, 967, 968, 969, 970, 971, 972, 973, 974, 975, 976, 977, 978, 979, 980, 981, 982, 983, 984, 985, 986, 987, 988, 989, 990, 991, 992, 993, 994, 995, 996, 997, 998, 999] |
0 0 |
31 31 |
|
|
[0, 1, 2, 3, 0, 5, 0, 7, 0, 0, 0, 11, 0, 13, 0, 0, 0, 17, 0, 19, 0, 0, 0, 23, 0, 0, 0, 0, 0, 29, 0, 31, 0, 0, 0, 0, 0, 37, 0, 0, 0, 41, 0, 43, 0, 0, 0, 47, 0, 0, 0, 0, 0, 53, 0, 0, 0, 0, 0, 59, 0, 61, 0, 0, 0, 0, 0, 67, 0, 0, 0, 71, 0, 73, 0, 0, 0, 0, 0, 79, 0, 0, 0, 83, 0, 0, 0, 0, 0, 89, 0, 0, 0, 0, 0, 0, 0, 97, 0, 0, 0, 101, 0, 103, 0, 0, 0, 107, 0, 109, 0, 0, 0, 113, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 127, 0, 0, 0, 131, 0, 0, 0, 0, 0, 137, 0, 139, 0, 0, 0, 0, 0, 0, 0, 0, 0, 149, 0, 151, 0, 0, 0, 0, 0, 157, 0, 0, 0, 0, 0, 163, 0, 0, 0, 167, 0, 0, 0, 0, 0, 173, 0, 0, 0, 0, 0, 179, 0, 181, 0, 0, 0, 0, 0, 0, 0, 0, 0, 191, 0, 193, 0, 0, 0, 197, 0, 199, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 211, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 223, 0, 0, 0, 227, 0, 229, 0, 0, 0, 233, 0, 0, 0, 0, 0, 239, 0, 241, 0, 0, 0, 0, 0, 0, 0, 0, 0, 251, 0, 0, 0, 0, 0, 257, 0, 0, 0, 0, 0, 263, 0, 0, 0, 0, 0, 269, 0, 271, 0, 0, 0, 0, 0, 277, 0, 0, 0, 281, 0, 283, 0, 0, 0, 0, 0, 0, 0, 0, 0, 293, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 307, 0, 0, 0, 311, 0, 313, 0, 0, 0, 317, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 331, 0, 0, 0, 0, 0, 337, 0, 0, 0, 0, 0, 0, 0, 0, 0, 347, 0, 349, 0, 0, 0, 353, 0, 0, 0, 0, 0, 359, 0, 0, 0, 0, 0, 0, 0, 367, 0, 0, 0, 0, 0, 373, 0, 0, 0, 0, 0, 379, 0, 0, 0, 383, 0, 0, 0, 0, 0, 389, 0, 0, 0, 0, 0, 0, 0, 397, 0, 0, 0, 401, 0, 0, 0, 0, 0, 0, 0, 409, 0, 0, 0, 0, 0, 0, 0, 0, 0, 419, 0, 421, 0, 0, 0, 0, 0, 0, 0, 0, 0, 431, 0, 433, 0, 0, 0, 0, 0, 439, 0, 0, 0, 443, 0, 0, 0, 0, 0, 449, 0, 0, 0, 0, 0, 0, 0, 457, 0, 0, 0, 461, 0, 463, 0, 0, 0, 467, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 479, 0, 0, 0, 0, 0, 0, 0, 487, 0, 0, 0, 491, 0, 0, 0, 0, 0, 0, 0, 499, 0, 0, 0, 503, 0, 0, 0, 0, 0, 509, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 521, 0, 523, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 541, 0, 0, 0, 0, 0, 547, 0, 0, 0, 0, 0, 0, 0, 0, 0, 557, 0, 0, 0, 0, 0, 563, 0, 0, 0, 0, 0, 569, 0, 571, 0, 0, 0, 0, 0, 577, 0, 0, 0, 0, 0, 0, 0, 0, 0, 587, 0, 0, 0, 0, 0, 593, 0, 0, 0, 0, 0, 599, 0, 601, 0, 0, 0, 0, 0, 607, 0, 0, 0, 0, 0, 613, 0, 0, 0, 617, 0, 619, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 631, 0, 0, 0, 0, 0, 0, 0, 0, 0, 641, 0, 643, 0, 0, 0, 647, 0, 0, 0, 0, 0, 653, 0, 0, 0, 0, 0, 659, 0, 661, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 673, 0, 0, 0, 677, 0, 0, 0, 0, 0, 683, 0, 0, 0, 0, 0, 0, 0, 691, 0, 0, 0, 0, 0, 0, 0, 0, 0, 701, 0, 0, 0, 0, 0, 0, 0, 709, 0, 0, 0, 0, 0, 0, 0, 0, 0, 719, 0, 0, 0, 0, 0, 0, 0, 727, 0, 0, 0, 0, 0, 733, 0, 0, 0, 0, 0, 739, 0, 0, 0, 743, 0, 0, 0, 0, 0, 0, 0, 751, 0, 0, 0, 0, 0, 757, 0, 0, 0, 761, 0, 0, 0, 0, 0, 0, 0, 769, 0, 0, 0, 773, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 787, 0, 0, 0, 0, 0, 0, 0, 0, 0, 797, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 809, 0, 811, 0, 0, 0, 0, 0, 0, 0, 0, 0, 821, 0, 823, 0, 0, 0, 827, 0, 829, 0, 0, 0, 0, 0, 0, 0, 0, 0, 839, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 853, 0, 0, 0, 857, 0, 859, 0, 0, 0, 863, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 877, 0, 0, 0, 881, 0, 883, 0, 0, 0, 887, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 907, 0, 0, 0, 911, 0, 0, 0, 0, 0, 0, 0, 919, 0, 0, 0, 0, 0, 0, 0, 0, 0, 929, 0, 0, 0, 0, 0, 0, 0, 937, 0, 0, 0, 941, 0, 0, 0, 0, 0, 947, 0, 0, 0, 0, 0, 953, 0, 0, 0, 0, 0, 0, 0, 961, 0, 0, 0, 0, 0, 967, 0, 0, 0, 971, 0, 0, 0, 0, 0, 977, 0, 0, 0, 0, 0, 983, 0, 0, 0, 0, 0, 989, 0, 991, 0, 0, 0, 0, 0, 997, 0, 999] [0, 1, 2, 3, 0, 5, 0, 7, 0, 0, 0, 11, 0, 13, 0, 0, 0, 17, 0, 19, 0, 0, 0, 23, 0, 0, 0, 0, 0, 29, 0, 31, 0, 0, 0, 0, 0, 37, 0, 0, 0, 41, 0, 43, 0, 0, 0, 47, 0, 0, 0, 0, 0, 53, 0, 0, 0, 0, 0, 59, 0, 61, 0, 0, 0, 0, 0, 67, 0, 0, 0, 71, 0, 73, 0, 0, 0, 0, 0, 79, 0, 0, 0, 83, 0, 0, 0, 0, 0, 89, 0, 0, 0, 0, 0, 0, 0, 97, 0, 0, 0, 101, 0, 103, 0, 0, 0, 107, 0, 109, 0, 0, 0, 113, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 127, 0, 0, 0, 131, 0, 0, 0, 0, 0, 137, 0, 139, 0, 0, 0, 0, 0, 0, 0, 0, 0, 149, 0, 151, 0, 0, 0, 0, 0, 157, 0, 0, 0, 0, 0, 163, 0, 0, 0, 167, 0, 0, 0, 0, 0, 173, 0, 0, 0, 0, 0, 179, 0, 181, 0, 0, 0, 0, 0, 0, 0, 0, 0, 191, 0, 193, 0, 0, 0, 197, 0, 199, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 211, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 223, 0, 0, 0, 227, 0, 229, 0, 0, 0, 233, 0, 0, 0, 0, 0, 239, 0, 241, 0, 0, 0, 0, 0, 0, 0, 0, 0, 251, 0, 0, 0, 0, 0, 257, 0, 0, 0, 0, 0, 263, 0, 0, 0, 0, 0, 269, 0, 271, 0, 0, 0, 0, 0, 277, 0, 0, 0, 281, 0, 283, 0, 0, 0, 0, 0, 0, 0, 0, 0, 293, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 307, 0, 0, 0, 311, 0, 313, 0, 0, 0, 317, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 331, 0, 0, 0, 0, 0, 337, 0, 0, 0, 0, 0, 0, 0, 0, 0, 347, 0, 349, 0, 0, 0, 353, 0, 0, 0, 0, 0, 359, 0, 0, 0, 0, 0, 0, 0, 367, 0, 0, 0, 0, 0, 373, 0, 0, 0, 0, 0, 379, 0, 0, 0, 383, 0, 0, 0, 0, 0, 389, 0, 0, 0, 0, 0, 0, 0, 397, 0, 0, 0, 401, 0, 0, 0, 0, 0, 0, 0, 409, 0, 0, 0, 0, 0, 0, 0, 0, 0, 419, 0, 421, 0, 0, 0, 0, 0, 0, 0, 0, 0, 431, 0, 433, 0, 0, 0, 0, 0, 439, 0, 0, 0, 443, 0, 0, 0, 0, 0, 449, 0, 0, 0, 0, 0, 0, 0, 457, 0, 0, 0, 461, 0, 463, 0, 0, 0, 467, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 479, 0, 0, 0, 0, 0, 0, 0, 487, 0, 0, 0, 491, 0, 0, 0, 0, 0, 0, 0, 499, 0, 0, 0, 503, 0, 0, 0, 0, 0, 509, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 521, 0, 523, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 541, 0, 0, 0, 0, 0, 547, 0, 0, 0, 0, 0, 0, 0, 0, 0, 557, 0, 0, 0, 0, 0, 563, 0, 0, 0, 0, 0, 569, 0, 571, 0, 0, 0, 0, 0, 577, 0, 0, 0, 0, 0, 0, 0, 0, 0, 587, 0, 0, 0, 0, 0, 593, 0, 0, 0, 0, 0, 599, 0, 601, 0, 0, 0, 0, 0, 607, 0, 0, 0, 0, 0, 613, 0, 0, 0, 617, 0, 619, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 631, 0, 0, 0, 0, 0, 0, 0, 0, 0, 641, 0, 643, 0, 0, 0, 647, 0, 0, 0, 0, 0, 653, 0, 0, 0, 0, 0, 659, 0, 661, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 673, 0, 0, 0, 677, 0, 0, 0, 0, 0, 683, 0, 0, 0, 0, 0, 0, 0, 691, 0, 0, 0, 0, 0, 0, 0, 0, 0, 701, 0, 0, 0, 0, 0, 0, 0, 709, 0, 0, 0, 0, 0, 0, 0, 0, 0, 719, 0, 0, 0, 0, 0, 0, 0, 727, 0, 0, 0, 0, 0, 733, 0, 0, 0, 0, 0, 739, 0, 0, 0, 743, 0, 0, 0, 0, 0, 0, 0, 751, 0, 0, 0, 0, 0, 757, 0, 0, 0, 761, 0, 0, 0, 0, 0, 0, 0, 769, 0, 0, 0, 773, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 787, 0, 0, 0, 0, 0, 0, 0, 0, 0, 797, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 809, 0, 811, 0, 0, 0, 0, 0, 0, 0, 0, 0, 821, 0, 823, 0, 0, 0, 827, 0, 829, 0, 0, 0, 0, 0, 0, 0, 0, 0, 839, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 853, 0, 0, 0, 857, 0, 859, 0, 0, 0, 863, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 877, 0, 0, 0, 881, 0, 883, 0, 0, 0, 887, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 907, 0, 0, 0, 911, 0, 0, 0, 0, 0, 0, 0, 919, 0, 0, 0, 0, 0, 0, 0, 0, 0, 929, 0, 0, 0, 0, 0, 0, 0, 937, 0, 0, 0, 941, 0, 0, 0, 0, 0, 947, 0, 0, 0, 0, 0, 953, 0, 0, 0, 0, 0, 0, 0, 961, 0, 0, 0, 0, 0, 967, 0, 0, 0, 971, 0, 0, 0, 0, 0, 977, 0, 0, 0, 0, 0, 983, 0, 0, 0, 0, 0, 989, 0, 991, 0, 0, 0, 0, 0, 997, 0, 999] |
|
|
Sagemath has some classic criptosystems...
Free alphabetic string monoid on A-Z Free alphabetic string monoid on A-Z |
Vigenere cryptosystem on Free alphabetic string monoid on A-Z of period 5 Vigenere cryptosystem on Free alphabetic string monoid on A-Z of period 5 |
VBONV VBONV |
FZMNF FZMNF |
|
|
Cipher on Free alphabetic string monoid on A-Z Cipher on Free alphabetic string monoid on A-Z |
OIWFDNBGRXMFHZZNTOTZ OIWFDNBGRXMFHZZNTOTZ |
|
|
THISISASECRETMESSAGE THISISASECRETMESSAGE |
Hill cryptosystem on Free alphabetic string monoid on A-Z of block length 5 Hill cryptosystem on Free alphabetic string monoid on A-Z of block length 5 |
[ 1 24 14 9 22] [24 11 5 2 9] [ 9 20 10 21 1] [15 5 4 0 10] [14 8 25 0 19] [ 1 24 14 9 22] [24 11 5 2 9] [ 9 20 10 21 1] [15 5 4 0 10] [14 8 25 0 19] |
21 21 |
[24 19 4 9 13] [ 6 25 0 18 21] [25 2 25 20 13] [19 17 20 15 13] [ 3 18 23 6 22] [24 19 4 9 13] [ 6 25 0 18 21] [25 2 25 20 13] [19 17 20 15 13] [ 3 18 23 6 22] |
THISISASECRETMESSAGE THISISASECRETMESSAGE |
Hill cipher on Free alphabetic string monoid on A-Z of block length 5 Hill cipher on Free alphabetic string monoid on A-Z of block length 5 |
RPDPPIWEUYAOYOBYQYQS RPDPPIWEUYAOYOBYQYQS |
[24 19 4 9 13] [ 6 25 0 18 21] [25 2 25 20 13] [19 17 20 15 13] [ 3 18 23 6 22] [24 19 4 9 13] [ 6 25 0 18 21] [25 2 25 20 13] [19 17 20 15 13] [ 3 18 23 6 22] |
[1 0 0 0 0] [0 1 0 0 0] [0 0 1 0 0] [0 0 0 1 0] [0 0 0 0 1] [1 0 0 0 0] [0 1 0 0 0] [0 0 1 0 0] [0 0 0 1 0] [0 0 0 0 1] |
THISISASECRETMESSAGE THISISASECRETMESSAGE |
The "standard elliptic curve" has the form
for some fixed a and b. (This is called a Weierstrass equation).
In characteristic 2 or 3 the form is slightly more complicated.
|
|
Elliptic Curve defined by y^2 = x^3 - 5*x + 4 over Rational Field Elliptic Curve defined by y^2 = x^3 - 5*x + 4 over Rational Field |
1088 1088 |
|
|
-368 -368 |
|
|
|
|
|
|
|
|
Elliptic Curve defined by y^2 = x^3 + x over Finite Field of size 37 Elliptic Curve defined by y^2 = x^3 + x over Finite Field of size 37 |
Alice and Bob choose an e.c. E modulus p.
|
|
(85938953, Ring of integers modulo 85938953) (85938953, Ring of integers modulo 85938953) |
|
|
We now have an "authorized" e.c.
Elliptic Curve defined by y^2 = x^3 + 60201846*x + 12864088 over Ring of integers modulo 85938953 Elliptic Curve defined by y^2 = x^3 + 60201846*x + 12864088 over Ring of integers modulo 85938953 |
Alice and Bob pick a random point P in E.
(12808456 : 23729794 : 1) (12808456 : 23729794 : 1) |
Alice picks a and Bob picks b.
Alice sends aP to Bob, and Bob sends bP to Alice. Now both can compute abP.
(58323290, 55794135) (58323290, 55794135) |
((16143726 : 52623811 : 1), (4152859 : 44091311 : 1)) ((16143726 : 52623811 : 1), (4152859 : 44091311 : 1)) |
(75728692 : 3973049 : 1) (75728692 : 3973049 : 1) |
(75728692 : 3973049 : 1) (75728692 : 3973049 : 1) |
|
|