CoCalc Shared Filestmp / graphs.sagews
Views : 6
G = graphs.RandomLobster(9, .6, .3)

G

Graph on 16 vertices
show(G)

d3-based renderer not yet implemented
a = random_matrix(ZZ,300)
%time a.det()

288413063841346937521424491565448894617927159949506186315382434636893631558073770430264189268489158898466920413557477569939251454745797624396925838364818750971974917608948253670946080852720238166464777182236081363778137427721507637358084970299052680671655434748198583028549088648307767405529667064860592818820892213131668704954006815630418645486434045469628654175355964494577971759745534650545449611679917728046913972236926013895508877589170354444011343347752552109448229921147243968702425915728525581276098304636541562603620829947473427575292816233894309325297876687919936039116373515008429258291577735881378366539635124350808482488366328101338730147067701910751642311610188576994473392932794928219042300366366427587636273149164023753809538565713295484 CPU time: 0.21 s, Wall time: 0.21 s
%time a*a

300 x 300 dense matrix over Integer Ring CPU time: 0.04 s, Wall time: 0.04 s
sage: u = var('u')
sage: circle = (cos(u), sin(u))
sage: revolution_plot3d(circle, (u,0,2*pi), axis=(0,0), show_curve=True, opacity=0.5).show(aspect_ratio=(1,1,1))


3D rendering not yet implemented


%var x y
plot3d(x * sin(y^2), (x, -5, 5), (y, -5, 5), mesh=1)

3D rendering not yet implemented
show(integrate(1 + x + x^2 + sin(x^2), x))

$\displaystyle \frac{1}{3} \, x^{3} + \frac{1}{2} \, x^{2} + \frac{1}{16} \, \sqrt{\pi} {\left(\left(i + 1\right) \, \sqrt{2} \operatorname{erf}\left(\left(\frac{1}{2} i + \frac{1}{2}\right) \, \sqrt{2} x\right) + \left(i - 1\right) \, \sqrt{2} \operatorname{erf}\left(\left(\frac{1}{2} i - \frac{1}{2}\right) \, \sqrt{2} x\right) - \left(i - 1\right) \, \sqrt{2} \operatorname{erf}\left(\sqrt{-i} x\right) + \left(i + 1\right) \, \sqrt{2} \operatorname{erf}\left(\left(-1\right)^{\frac{1}{4}} x\right)\right)} + x$
show(random_matrix(QQ,20,21).echelon_form())

$\displaystyle \left(\begin{array}{rrrrrrrrrrrrrrrrrrrrr} 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & -\frac{96717479949848}{169253122998923} \\ 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & -\frac{773519161331315}{507759368996769} \\ 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & \frac{24816759462017}{338506245997846} \\ 0 & 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & \frac{411230844508096}{169253122998923} \\ 0 & 0 & 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & -\frac{250027807404355}{1015518737993538} \\ 0 & 0 & 0 & 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & \frac{133169247879598}{169253122998923} \\ 0 & 0 & 0 & 0 & 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & -\frac{1225747834880455}{507759368996769} \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & -\frac{518712919747616}{507759368996769} \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & \frac{504554277612904}{507759368996769} \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & -\frac{4184944236896429}{1015518737993538} \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & \frac{195673416796142}{507759368996769} \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & \frac{472624734138331}{1015518737993538} \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & -\frac{318766355599873}{338506245997846} \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 & -\frac{558518133516938}{507759368996769} \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 & -\frac{314208949607469}{338506245997846} \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 & 0 & 0 & 0 & 0 & -\frac{903749526332950}{507759368996769} \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 & 0 & 0 & 0 & \frac{496592873398489}{507759368996769} \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 & 0 & 0 & -\frac{260851554849143}{338506245997846} \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 & 0 & -\frac{382807471530563}{507759368996769} \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 & \frac{2076639054992747}{1015518737993538} \end{array}\right)$
# choose a graph
g = graphs.FuzzyBallGraph([3,1],2)

plot(g)

show(g)

d3-based renderer not yet implemented
set_random_seed(2)
plot(g)



plot(g).save('a.pdf')

g.chromatic_number()

6
col = g.coloring(hex_colors=True); col

{'#0000ff': [4], '#ff00ff': [5], '#ffff00': [1], '#00ff00': [2], '#00ffff': [3, 'a1'], '#ff0000': [0, 'a2']}
# finally we plot it...
g.graphplot(vertex_colors=col).show()

show(g)

d3-based renderer not yet implemented


G = g.automorphism_group()

G

Permutation Group with generators [(4,5), (1,2), (0,1)]
G.order()

12
plot(G.cayley_graph())

G.multiplication_table()

* a b c d e f g h i j k l +------------------------ a| a b c d e f g h i j k l b| b a h e d j k c l f g i c| c g a f i d b k e l h j d| d e f a b c i j g h l k e| e d j b a h l f k c i g f| f i d c g a e l b k j h g| g c k i f l h a j d b e h| h k b j l e a g d i c f i| i f l g c k j d h a e b j| j l e h k b d i a g f c k| k h g l j i c b f e a d l| l j i k h g f e c b d a
G.normal_subgroups()

[Subgroup of (Permutation Group with generators [(4,5), (1,2), (0,1)]) generated by [()], Subgroup of (Permutation Group with generators [(4,5), (1,2), (0,1)]) generated by [(0,2,1)], Subgroup of (Permutation Group with generators [(4,5), (1,2), (0,1)]) generated by [(1,2)(4,5), (0,2,1)], Subgroup of (Permutation Group with generators [(4,5), (1,2), (0,1)]) generated by [(1,2), (0,2,1)], Subgroup of (Permutation Group with generators [(4,5), (1,2), (0,1)]) generated by [(4,5)], Subgroup of (Permutation Group with generators [(4,5), (1,2), (0,1)]) generated by [(4,5), (0,2,1)], Subgroup of (Permutation Group with generators [(4,5), (1,2), (0,1)]) generated by [(4,5), (1,2), (0,1)]]
R.<x> = CC[]
show((x^4+x^2+5*x+1).roots())

[($\displaystyle -1.42190286063708$, $\displaystyle 1$), ($\displaystyle -0.209129590408507$, $\displaystyle 1$), ($\displaystyle 0.815516225522795 - 1.64250971973597i$, $\displaystyle 1$), ($\displaystyle 0.815516225522795 + 1.64250971973597i$, $\displaystyle 1$)]
A = random_matrix(QQ,8,12)
show(A)

$\displaystyle \left(\begin{array}{rrrrrrrrrrrr} 0 & -1 & 1 & 0 & 1 & 0 & 1 & 0 & 1 & 0 & -\frac{1}{2} & 2 \\ 2 & 0 & 2 & 0 & 0 & \frac{1}{2} & 1 & 0 & 1 & 1 & -\frac{1}{2} & 0 \\ -1 & -\frac{1}{2} & 2 & 0 & 0 & -2 & 0 & -\frac{1}{2} & -1 & 1 & 1 & -1 \\ -2 & -2 & 0 & 1 & -2 & -1 & 0 & 1 & 0 & 2 & -1 & 2 \\ -\frac{1}{2} & 0 & \frac{1}{2} & 0 & 1 & -1 & 2 & 0 & \frac{1}{2} & 2 & 0 & -1 \\ -\frac{1}{2} & 2 & 0 & 0 & -2 & 1 & 0 & -1 & 2 & -1 & 1 & 0 \\ 1 & 2 & 0 & 1 & -2 & -1 & -2 & 1 & 2 & 0 & 1 & -2 \\ 0 & 1 & -2 & -2 & 0 & -2 & -2 & -1 & 1 & -1 & 2 & 2 \end{array}\right)$
A.right_kernel()

Vector space of degree 12 and dimension 4 over Rational Field Basis matrix: [ 1 0 0 0 -13/14 83/49 1279/392 2389/392 -873/392 -15/56 1417/196 1375/784] [ 0 1 0 0 -5/14 -107/49 -23/196 -425/196 37/196 -29/28 -403/98 -151/392] [ 0 0 1 0 9/7 430/49 451/196 2573/196 -717/196 117/28 1805/98 1623/392] [ 0 0 0 1 11/14 87/49 -22/49 43/49 -20/49 10/7 143/49 75/98]
show(A.echelon_form())

$\displaystyle \left(\begin{array}{rrrrrrrrrrrr} 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & -\frac{613}{45} & \frac{1163}{225} & -\frac{8}{15} & -\frac{372}{25} \\ 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 & \frac{887}{90} & -\frac{1567}{450} & \frac{11}{15} & \frac{224}{25} \\ 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 & \frac{572}{45} & -\frac{1027}{225} & \frac{7}{15} & \frac{338}{25} \\ 0 & 0 & 0 & 1 & 0 & 0 & 0 & 0 & -\frac{2933}{90} & \frac{4993}{450} & -\frac{14}{15} & -\frac{896}{25} \\ 0 & 0 & 0 & 0 & 1 & 0 & 0 & 0 & -\frac{2}{15} & -\frac{53}{75} & \frac{1}{10} & -\frac{4}{25} \\ 0 & 0 & 0 & 0 & 0 & 1 & 0 & 0 & \frac{409}{45} & -\frac{899}{225} & -\frac{1}{15} & \frac{256}{25} \\ 0 & 0 & 0 & 0 & 0 & 0 & 1 & 0 & -\frac{31}{18} & \frac{161}{90} & -\frac{1}{3} & -\frac{12}{5} \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 & \frac{3049}{90} & -\frac{5009}{450} & \frac{7}{15} & \frac{898}{25} \end{array}\right)$
V = A.right_kernel()
V

Vector space of degree 12 and dimension 4 over Rational Field Basis matrix: [ 1 0 0 0 -13/14 83/49 1279/392 2389/392 -873/392 -15/56 1417/196 1375/784] [ 0 1 0 0 -5/14 -107/49 -23/196 -425/196 37/196 -29/28 -403/98 -151/392] [ 0 0 1 0 9/7 430/49 451/196 2573/196 -717/196 117/28 1805/98 1623/392] [ 0 0 0 1 11/14 87/49 -22/49 43/49 -20/49 10/7 143/49 75/98]
V.0 in V

True
A = random_matrix(QQ,300)

v = random_vector(QQ,300)

%time x = A \ v

CPU time: 7.43 s, Wall time: 7.49 s
reset('x')
diff(1 + 3*x + x^4, x)


4*x^3 + 3
plot(1+3*x+x^4,(0,10))

x[0]

364770467213426355359371803665150804470725649831034892761870270651294376951931844678214017641981637697276545816310204150165043650792953775767250220168170074401802930217688982482994250177354401286583555110509455504399145658149328658491855123161254486350047872505973477497565265940253312475214335460819449207732349356254161111073948355745503325440982063966530352197867832715389526707157854281766399826310859877556210119677861/8610793998992134262925758379803344403978580373328583806718745264992151907231175711537939110246884243706324940997697034033589707580916697714774779567791374310295532539023309439853594815272961283089464401203706630304207313599872889248673634304907519513500372323381584822598958790735820035980832581995713782023609443237451380255790499277071897232107757844240547419876806541599866399704918368799858617879294122070036650887520
complex_plot(log(x)+exp(x), (-10, 10), (-10, 10))