Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download

sagemath 8.1 on cocalc

Views: 341
Kernel: SageMath 8.1

Sage 8.1 on CoCalc

https://www.sagemath.org

version()
'SageMath version 8.1, Release Date: 2017-12-07'
C = matrix([[3, 4, 5], [2, 3, 4], [1, 2, 3]]) C.echelon_form() str(C.echelon_form())
'[ 1 0 -1]\n[ 0 1 2]\n[ 0 0 0]'
B = matrix([[1, 3, 2], [1, 3, 2], [1, 3, 6]]) for ev, evec, mult in B.eigenvectors_left(): print("Eigenvalue: {} with eigenvector: {} of multiplicity {}".format(ev, evec[0], mult))
Eigenvalue: 8 with eigenvector: (1, 3, 4) of multiplicity 1 Eigenvalue: 2 with eigenvector: (1, 3, -2) of multiplicity 1 Eigenvalue: 0 with eigenvector: (1, -1, 0) of multiplicity 1
A = matrix(RDF, [[1, -2, 9], [4, 0, 2], [1, -2, 1]]) b = vector(RDF, [9, 5, -1]) x = A.solve_right(b) print("x: {}".format(x)) print("check A*x: {}".format(A * x)) print("bashslash: {}".format(A \ b))
x: (0.625, 1.4375, 1.25) check A*x: (9.0, 5.0, -1.0) bashslash: (0.625, 1.4375, 1.25)
A * x
(9.0, 5.0, -1.0)
A \ b
(0.625, 1.4375, 1.25)
B = BraidGroup(3) B
Braid group on 3 strands
a = B([2, 2, -1, -1, 2, 2]) b = B([2, 1, 2, 1]) print(a.is_pseudoanosov()) print(b.is_pseudoanosov())
True False
c = b * a / b d = a.conjugating_braid(c) d * c / d == a
True
d
s1*s0
c * a / d == c
False
print("testing collaboration") factor(2018)
testing collaboration
2 * 1009

Elliptic Curves

EllipticCurve('123a').plot()
Image in a Jupyter notebook
plot(sin)
Image in a Jupyter notebook
var('x') plot(3*x + sin(4*x) * cos(2*x))
Image in a Jupyter notebook
12398^293
224920054752209012888072239925666166152953315927462721091292220365989203840057376636804982037728842165211127754871180466185804122534771829601833896090835864196025436431924983737586223453054912366095785663715431040046594888989222421603285849332689122816156762538783671266032400455580674287929966023135712111798722104970689971267808493577063364619666993520659753007743124278585124546857412675047916113619801821701603298491596605616499083576796213009485555458658940236325255710647178563003216835067008947943476212542736824832348107381461218975410691680581263762269729207679626566396639963055239930575299610332004044486445038816865938212752679155455404917676116387237772041501081051928065361009924493262242457662069704890209189008254392022246914545263944336919637398245670306009262211730782937608082885675974083069527353881856749463300889196935129916598467151441999086699148318718203024413285031988755115636641407312419386479420956656440082347351337046535199009414178575816234342725422000488935597626813023611877232335981288141998222754683092883556669209212865773658833243333407531495199652510507949303438066553930402482227408453820470971508908699749310101805069233667208284943155721408078335784578449408
GF_13.<x,y> = GF(13)[]
GF_13
Multivariate Polynomial Ring in x, y over Finite Field of size 13
5 * x + 10 * x + y
2*x + y
Integer("abc", base=35)
12647
Integer("z", base=36)
35
R = IntegerModRing(97) a = R(2) / R(3) print(a) print(a.rational_reconstruction()) b = R(47) print(b^20052005) print(b.modulus()) print("is b square? {}".format(b.is_square()))
33 2/3 50 97 is b square? True
x = Integer('secret', base=36) x
1717162949
x.str(base=36)
'secret'
gcd(2011946, 1450942)
2018
2018 * next_prime(718)
1450942
print(gcd(2011946, 1450942)) print(factor(2018)) c = factorial(25) print(c) print([valuation(c,p) for p in prime_range(2,23)]) print(next_prime(2005)) print(previous_prime(2005)) print('%s %s %s' % (divisors(28), sum(divisors(28)), 2*28))
2018 2 * 1009 15511210043330985984000000 [22, 10, 6, 3, 2, 1, 1, 1] 2011 2003 [1, 2, 4, 7, 14, 28] 56 56
d,u,v = xgcd(20,18) print("d: {d}, u: {u}, v: {v}".format(**locals())) print(d == u*20 + v*18)
d: 2, u: 1, v: -1 True
for m in srange(1, 10): print("m {}: {:>6d}".format(m, inverse_mod(m, 997)))
m 1: 1 m 2: 499 m 3: 665 m 4: 748 m 5: 399 m 6: 831 m 7: 285 m 8: 374 m 9: 554
inverse_mod?
prime_divisors(20172018)
[2, 3, 79, 42557]
euler_phi(20172018)
6638736
prime_to_m_part(20172018, 2019)
6724006
x = crt(2, 1, 3, 5); x print(x % 3) # x mod 3 = 2 print(x % 5) # x mod 5 = 1 print([binomial(13,m) for m in range(14)]) print([binomial(13,m)%2 for m in range(14)]) print([kronecker(m,13) for m in range(1,13)]) n = 10000 print(sum([moebius(m) for m in range(1,n)])) print(Partitions(4).list())
2 1 [1, 13, 78, 286, 715, 1287, 1716, 1716, 1287, 715, 286, 78, 13, 1] [1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1] [1, -1, 1, 1, -1, -1, -1, -1, 1, 1, -1, 1] -23 [[4], [3, 1], [2, 2], [2, 1, 1], [1, 1, 1, 1]]
K = Qp(11) print(K) a = K(211/17) print(a) b = K(3211/11^2) print(b) print(a + b)
11-adic Field with capped relative precision 20 4 + 4*11 + 11^2 + 7*11^3 + 9*11^5 + 5*11^6 + 4*11^7 + 8*11^8 + 7*11^9 + 9*11^10 + 3*11^11 + 10*11^12 + 11^13 + 5*11^14 + 6*11^15 + 2*11^16 + 3*11^17 + 11^18 + 7*11^19 + O(11^20) 10*11^-2 + 5*11^-1 + 4 + 2*11 + O(11^18) 10*11^-2 + 5*11^-1 + 8 + 6*11 + 11^2 + 7*11^3 + 9*11^5 + 5*11^6 + 4*11^7 + 8*11^8 + 7*11^9 + 9*11^10 + 3*11^11 + 10*11^12 + 11^13 + 5*11^14 + 6*11^15 + 2*11^16 + 3*11^17 + O(11^18)
R.<x> = PolynomialRing(QQ) K = NumberField(x^3 + x^2 - 2*x + 8, 'a') K.galois_group(type="pari")
Galois group PARI group [6, -1, 2, "S3"] of degree 3 of the Number Field in a with defining polynomial x^3 + x^2 - 2*x + 8
[1, 5, .., 100]
[1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 65, 69, 73, 77, 81, 85, 89, 93, 97]

formula [x]2+[y]2[x]^2 + [y]^2

C = matrix([[3, 4, 5], [2, 3, 4], [1, 2, 3]]) C.echelon_form()
[ 1 0 -1] [ 0 1 2] [ 0 0 0]
C = matrix([[3, 4, 5], [2, 3, 4], [1, 2, 3]]) C = C.change_ring(GF(2)) C.echelon_form()
[1 0 1] [0 1 0] [0 0 0]
show(GF(2))
F2\renewcommand{\Bold}[1]{\mathbf{#1}}\Bold{F}_{2}
C = matrix([[3, 4, 5], [2, 3, 4], [1, 2, 3]]) print(C.echelon_form()) C2 = C.change_ring(GF(2)) print(C2) print(C2.echelon_form())
[ 1 0 -1] [ 0 1 2] [ 0 0 0] [1 0 1] [0 1 0] [1 0 1] [1 0 1] [0 1 0] [0 0 0]
A = matrix([[ 1, 2, 3, 4], [ 5, 6, 7, 8], [ 9,10,11,12]]) A[1, 3]
8
A[:, 1]
[ 2] [ 6] [10]
A = matrix([[ 1, 2, 3, 4], [ 5, 6, 7, 8], [ 9,10,11,12]]) print(A[0, :] + A[1, :])
[ 6 8 10 12]
print(A[0, :] * A[1, :].transpose())
[70]
print(A[:, 1] + A[:, 2])
[ 5] [13] [21]
A.elementwise_product(A)
[ 1 4 9 16] [ 25 36 49 64] [ 81 100 121 144]
A[0:2, 1:3]
[2 3] [6 7]