Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download

Examples of using latex in cocalc

Views: 1126
1
## -*- encoding: utf-8 -*-
2
3
# This file was *autogenerated* from the file sagetex.sagetex.sage
4
from sage.all_cmdline import * # import sage library
5
6
_sage_const_181 = Integer(181); _sage_const_345 = Integer(345); _sage_const_349 = Integer(349); _sage_const_695 = Integer(695); _sage_const_693 = Integer(693); _sage_const_118 = Integer(118); _sage_const_84 = Integer(84); _sage_const_85 = Integer(85); _sage_const_87 = Integer(87); _sage_const_81 = Integer(81); _sage_const_622 = Integer(622); _sage_const_337 = Integer(337); _sage_const_629 = Integer(629); _sage_const_339 = Integer(339); _sage_const_13 = Integer(13); _sage_const_12 = Integer(12); _sage_const_11 = Integer(11); _sage_const_10 = Integer(10); _sage_const_17 = Integer(17); _sage_const_16 = Integer(16); _sage_const_14 = Integer(14); _sage_const_19 = Integer(19); _sage_const_18 = Integer(18); _sage_const_109 = Integer(109); _sage_const_99 = Integer(99); _sage_const_100 = Integer(100); _sage_const_91 = Integer(91); _sage_const_90 = Integer(90); _sage_const_104 = Integer(104); _sage_const_107 = Integer(107); _sage_const_458 = Integer(458); _sage_const_455 = Integer(455); _sage_const_451 = Integer(451); _sage_const_525 = Integer(525); _sage_const_521 = Integer(521); _sage_const_97 = Integer(97); _sage_const_9999 = Integer(9999); _sage_const_64 = Integer(64); _sage_const_136 = Integer(136); _sage_const_63 = Integer(63); _sage_const_60 = Integer(60); _sage_const_68 = Integer(68); _sage_const_420 = Integer(420); _sage_const_426 = Integer(426); _sage_const_484 = Integer(484); _sage_const_253 = Integer(253); _sage_const_100000 = Integer(100000); _sage_const_122 = Integer(122); _sage_const_77 = Integer(77); _sage_const_127 = Integer(127); _sage_const_125 = Integer(125); _sage_const_78 = Integer(78); _sage_const_113 = Integer(113); _sage_const_639 = Integer(639); _sage_const_433 = Integer(433); _sage_const_712 = Integer(712); _sage_const_42 = Integer(42); _sage_const_47 = Integer(47); _sage_const_49 = Integer(49); _sage_const_154 = Integer(154); _sage_const_151 = Integer(151); _sage_const_642 = Integer(642); _sage_const_36 = Integer(36); _sage_const_158 = Integer(158); _sage_const_75 = Integer(75); _sage_const_463 = Integer(463); _sage_const_58 = Integer(58); _sage_const_54 = Integer(54); _sage_const_683 = Integer(683); _sage_const_51 = Integer(51); _sage_const_389 = Integer(389); _sage_const_413 = Integer(413); _sage_const_146 = Integer(146); _sage_const_651 = Integer(651); _sage_const_656 = Integer(656); _sage_const_3 = Integer(3); _sage_const_2 = Integer(2); _sage_const_1 = Integer(1); _sage_const_0 = Integer(0); _sage_const_7 = Integer(7); _sage_const_6 = Integer(6); _sage_const_5 = Integer(5); _sage_const_4 = Integer(4); _sage_const_9 = Integer(9); _sage_const_8 = Integer(8); _sage_const_22 = Integer(22); _sage_const_23 = Integer(23); _sage_const_20 = Integer(20); _sage_const_21 = Integer(21); _sage_const_667 = Integer(667); _sage_const_175 = Integer(175); _sage_const_0p4 = RealNumber('0.4'); _sage_const_709 = Integer(709); _sage_const_178 = Integer(178); _sage_const_519 = Integer(519); _sage_const_518 = Integer(518); _sage_const_351 = Integer(351); _sage_const_448 = Integer(448); _sage_const_355 = Integer(355); _sage_const_512 = Integer(512); _sage_const_2018 = Integer(2018); _sage_const_39 = Integer(39); _sage_const_38 = Integer(38); _sage_const_685 = Integer(685); _sage_const_35 = Integer(35); _sage_const_130 = Integer(130); _sage_const_161 = Integer(161); _sage_const_671 = Integer(671)## This file (sagetex.sagetex.sage) was *autogenerated* from sagetex.tex with sagetex.sty version 2015/08/26 v3.0-92d9f7a.
7
import sagetex
8
_st_ = sagetex.SageTeXProcessor('sagetex', version='2015/08/26 v3.0-92d9f7a', version_check=True)
9
try:
10
_st_.current_tex_line = _sage_const_35
11
_st_.inline(_sage_const_0 , latex(_sage_const_2 +_sage_const_2 ))
12
except:
13
_st_.goboom(_sage_const_35 )
14
try:
15
_st_.current_tex_line = _sage_const_36
16
_st_.inline(_sage_const_1 , latex(mod(_sage_const_2018 , _sage_const_100 )))
17
except:
18
_st_.goboom(_sage_const_36 )
19
try:
20
_st_.current_tex_line = _sage_const_38
21
_st_.inline(_sage_const_2 , latex(Integer(mod(_sage_const_2018 , _sage_const_100 ))**_sage_const_21 ))
22
except:
23
_st_.goboom(_sage_const_38 )
24
try:
25
_st_.current_tex_line = _sage_const_39
26
_st_.inline(_sage_const_3 , latex(_sage_const_2018 %_sage_const_42 ))
27
except:
28
_st_.goboom(_sage_const_39 )
29
_st_.current_tex_line = _sage_const_42
30
_st_.blockbegin()
31
try:
32
_sage_const_1 +_sage_const_1
33
var('a,b,c')
34
eqn = [a+b*c==_sage_const_1 , b-a*c==_sage_const_0 , a+b==_sage_const_5 ]
35
s = solve(eqn, a,b,c)
36
except:
37
_st_.goboom(_sage_const_47 )
38
_st_.blockend()
39
try:
40
_st_.current_tex_line = _sage_const_49
41
_st_.inline(_sage_const_4 , latex(eqn))
42
except:
43
_st_.goboom(_sage_const_49 )
44
try:
45
_st_.current_tex_line = _sage_const_51
46
_st_.inline(_sage_const_5 , latex(s[_sage_const_0 ]))
47
except:
48
_st_.goboom(_sage_const_51 )
49
try:
50
_st_.current_tex_line = _sage_const_54
51
_st_.inline(_sage_const_6 , latex(s[_sage_const_1 ]))
52
except:
53
_st_.goboom(_sage_const_54 )
54
_st_.current_tex_line = _sage_const_58
55
_st_.blockbegin()
56
try:
57
E = EllipticCurve("37a")
58
except:
59
_st_.goboom(_sage_const_60 )
60
_st_.blockend()
61
try:
62
_st_.current_tex_line = _sage_const_63
63
_st_.inline(_sage_const_7 , latex(E))
64
except:
65
_st_.goboom(_sage_const_63 )
66
try:
67
_st_.current_tex_line = _sage_const_64
68
_st_.inline(_sage_const_8 , latex(E.discriminant()))
69
except:
70
_st_.goboom(_sage_const_64 )
71
_st_.current_tex_line = _sage_const_68
72
_st_.blockbegin()
73
try:
74
try:
75
E = load('E2')
76
except IOError:
77
E = EllipticCurve([_sage_const_1 ,_sage_const_2 ,_sage_const_3 ,_sage_const_4 ,_sage_const_5 ])
78
E.anlist(_sage_const_100000 )
79
E.save('E2')
80
except:
81
_st_.goboom(_sage_const_75 )
82
_st_.blockend()
83
try:
84
_st_.current_tex_line = _sage_const_77
85
_st_.inline(_sage_const_9 , latex(E))
86
except:
87
_st_.goboom(_sage_const_77 )
88
try:
89
_st_.current_tex_line = _sage_const_78
90
_st_.inline(_sage_const_10 , latex(E.anlist(_sage_const_100000 )[_sage_const_9999 ]))
91
except:
92
_st_.goboom(_sage_const_78 )
93
_st_.current_tex_line = _sage_const_81
94
_st_.blockbegin()
95
try:
96
e = _sage_const_2
97
e = _sage_const_3 *e + _sage_const_1
98
except:
99
_st_.goboom(_sage_const_84 )
100
_st_.blockend()
101
try:
102
_st_.current_tex_line = _sage_const_85
103
_st_.inline(_sage_const_11 , latex(e))
104
except:
105
_st_.goboom(_sage_const_85 )
106
_st_.current_tex_line = _sage_const_87
107
_st_.blockbegin()
108
try:
109
var('x')
110
__tmp__=var("x"); f = symbolic_expression(log(sin(x)/x)).function(x)
111
except:
112
_st_.goboom(_sage_const_90 )
113
_st_.blockend()
114
try:
115
_st_.current_tex_line = _sage_const_91
116
_st_.inline(_sage_const_12 , latex( f.taylor(x, _sage_const_0 , _sage_const_10 ) ))
117
except:
118
_st_.goboom(_sage_const_91 )
119
try:
120
_st_.current_tex_line = _sage_const_97
121
_st_.plot(_sage_const_0 , format='notprovided', _p_=E.plot(-_sage_const_3 ,_sage_const_3 ))
122
except:
123
_st_.goboom(_sage_const_97 )
124
_st_.current_tex_line = _sage_const_99
125
_st_.blockbegin()
126
try:
127
# the var line is unecessary unless you've defined x to be something
128
# other than a symbolic variable
129
var('x')
130
__tmp__=var("x"); f = symbolic_expression(-x**_sage_const_3 +_sage_const_3 *x**_sage_const_2 +_sage_const_7 *x-_sage_const_4 ).function(x)
131
except:
132
_st_.goboom(_sage_const_104 )
133
_st_.blockend()
134
_st_.current_tex_line = _sage_const_107
135
_st_.blockbegin()
136
try:
137
p = plot(f, x, -_sage_const_5 , _sage_const_5 )
138
except:
139
_st_.goboom(_sage_const_109 )
140
_st_.blockend()
141
try:
142
_st_.current_tex_line = _sage_const_113
143
_st_.plot(_sage_const_1 , format='notprovided', _p_=p)
144
except:
145
_st_.goboom(_sage_const_113 )
146
try:
147
_st_.current_tex_line = _sage_const_118
148
_st_.plot(_sage_const_2 , format='notprovided', _p_=p, axes=False)
149
except:
150
_st_.goboom(_sage_const_118 )
151
_st_.current_tex_line = _sage_const_122
152
_st_.blockbegin()
153
try:
154
f = maxima('sin(x)^2*exp(x)')
155
g = f.integrate('x')
156
except:
157
_st_.goboom(_sage_const_125 )
158
_st_.blockend()
159
_st_.current_tex_line = _sage_const_127
160
_st_.blockbegin()
161
try:
162
# g is a Maxima thingy, it needs to get converted into a Sage object
163
plot1 = plot(g.sage(),x,-_sage_const_1 ,_sage_const_2 *pi)
164
except:
165
_st_.goboom(_sage_const_130 )
166
_st_.blockend()
167
try:
168
_st_.current_tex_line = _sage_const_136
169
_st_.plot(_sage_const_3 , format='png', _p_=plot1)
170
except:
171
_st_.goboom(_sage_const_136 )
172
try:
173
_st_.current_tex_line = _sage_const_146
174
_st_.plot(_sage_const_4 , format='notprovided', _p_=plot1 + plot(f.sage(),x,-_sage_const_1 ,_sage_const_2 *pi,rgbcolor=hue(_sage_const_0p4 )), figsize=[_sage_const_1 ,_sage_const_2 ])
175
except:
176
_st_.goboom(_sage_const_146 )
177
_st_.current_tex_line = _sage_const_151
178
_st_.blockbegin()
179
try:
180
p = plot(x, _sage_const_0 , _sage_const_1 ) + circle((_sage_const_0 ,_sage_const_0 ), _sage_const_1 )
181
p.set_aspect_ratio(_sage_const_1 )
182
except:
183
_st_.goboom(_sage_const_154 )
184
_st_.blockend()
185
try:
186
_st_.current_tex_line = _sage_const_158
187
_st_.plot(_sage_const_5 , format='notprovided', _p_=p)
188
except:
189
_st_.goboom(_sage_const_158 )
190
_st_.current_tex_line = _sage_const_161
191
_st_.blockbegin()
192
try:
193
s = _sage_const_7
194
s2 = _sage_const_2 **s
195
P = GF(_sage_const_2 )['x']; (x,) = P._first_ngens(1)
196
M = matrix(parent(x),s2)
197
for i in range(s2):
198
p = (_sage_const_1 +x)**i
199
pc = p.coefficients(sparse=False)
200
a = pc.count(_sage_const_1 )
201
for j in range(a):
202
idx = pc.index(_sage_const_1 )
203
M[i,idx+j] = pc.pop(idx)
204
205
matrixprogram = matrix_plot(M,cmap='Greys')
206
except:
207
_st_.goboom(_sage_const_175 )
208
_st_.blockend()
209
try:
210
_st_.current_tex_line = _sage_const_178
211
_st_.plot(_sage_const_6 , format='notprovided', _p_=matrixprogram)
212
except:
213
_st_.goboom(_sage_const_178 )
214
try:
215
_st_.current_tex_line = _sage_const_181
216
_st_.inline(_sage_const_13 , latex(var('x')))
217
except:
218
_st_.goboom(_sage_const_181 )
219
try:
220
_st_.current_tex_line = _sage_const_253
221
_st_.inline(_sage_const_14 , latex(var('x')))
222
except:
223
_st_.goboom(_sage_const_253 )
224
_st_.current_tex_line = _sage_const_337
225
_st_.blockbegin()
226
try:
227
x, y = var('x y')
228
except:
229
_st_.goboom(_sage_const_339 )
230
_st_.blockend()
231
try:
232
_st_.current_tex_line = _sage_const_345
233
_st_.plot(_sage_const_7 , format='notprovided', _p_=plot3d(sin(pi*(x**_sage_const_2 +y**_sage_const_2 ))/_sage_const_2 ,(x,-_sage_const_1 ,_sage_const_1 ),(y,-_sage_const_1 ,_sage_const_1 )))
234
except:
235
_st_.goboom(_sage_const_345 )
236
_st_.current_tex_line = _sage_const_349
237
_st_.blockbegin()
238
try:
239
G = graphs.CubeGraph(_sage_const_5 )
240
except:
241
_st_.goboom(_sage_const_351 )
242
_st_.blockend()
243
try:
244
_st_.current_tex_line = _sage_const_355
245
_st_.plot(_sage_const_8 , format='png', _p_=G.plot3d())
246
except:
247
_st_.goboom(_sage_const_355 )
248
print 'SageTeX paused on sagetex.tex line 365'
249
"""
250
try:
251
_st_.current_tex_line = 367
252
_st_.inline(15, latex(factor(2^325 + 1)))
253
except:
254
_st_.goboom(367)
255
_st_.current_tex_line = 370
256
_st_.blockbegin()
257
try:
258
import time
259
time.sleep(15)
260
except:
261
_st_.goboom(373)
262
_st_.blockend()
263
try:
264
_st_.current_tex_line = 375
265
_st_.plot(9, format='notprovided', _p_=plot(2*sin(x^2) + x^2, (x, 0, 5)))
266
except:
267
_st_.goboom(375)
268
"""
269
print 'SageTeX unpaused on sagetex.tex line 377'
270
_st_.current_tex_line = _sage_const_389
271
_st_.blockbegin()
272
try:
273
def pascals_triangle(n):
274
# start of the table
275
s = [r"\begin{tabular}{cc|" + "r" * (n+_sage_const_1 ) + "}"]
276
s.append(r" & & $k$: & \\")
277
# second row, with k values:
278
s.append(r" & ")
279
for k in (ellipsis_range(_sage_const_0 ,Ellipsis,n)):
280
s.append("& {0} ".format(k))
281
s.append(r"\\")
282
# the n = 0 row:
283
s.append(r"\hline" + "\n" + r"$n$: & 0 & 1 & \\")
284
# now the rest of the rows
285
for r in (ellipsis_range(_sage_const_1 ,Ellipsis,n)):
286
s.append(" & {0} ".format(r))
287
for k in (ellipsis_range(_sage_const_0 ,Ellipsis,r)):
288
s.append("& {0} ".format(binomial(r, k)))
289
s.append(r"\\")
290
# add the last line and return
291
s.append(r"\end{tabular}")
292
return ''.join(s)
293
294
# how big should the table be?
295
n = _sage_const_8
296
except:
297
_st_.goboom(_sage_const_413 )
298
_st_.blockend()
299
try:
300
_st_.current_tex_line = _sage_const_420
301
_st_.inline(_sage_const_16 , pascals_triangle(n))
302
except:
303
_st_.goboom(_sage_const_420 )
304
try:
305
_st_.current_tex_line = _sage_const_426
306
_st_.doctest(_sage_const_17 , r"""
307
sage: 2+2
308
4
309
sage: print 'middle'
310
middle
311
sage: factor(x^2 + 2*x + 1)
312
(x + 1)^2
313
""", globals(), locals(), False)
314
except:
315
_st_.goboom(_sage_const_433 )
316
try:
317
_st_.current_tex_line = _sage_const_448
318
_st_.doctest(_sage_const_18 , r"""
319
sage: print 'middle'
320
middle
321
""", globals(), locals(), True)
322
except:
323
_st_.goboom(_sage_const_451 )
324
try:
325
_st_.current_tex_line = _sage_const_455
326
_st_.doctest(_sage_const_19 , r"""
327
sage: is_prime(57)
328
toothpaste
329
""", globals(), locals(), True)
330
except:
331
_st_.goboom(_sage_const_458 )
332
try:
333
_st_.current_tex_line = _sage_const_463
334
_st_.doctest(_sage_const_20 , r"""
335
sage: gcd([5656565656,
336
....: 4747474747,
337
....: 123456789])
338
1
339
sage: mystr = '''my
340
....: string
341
....: has
342
....: several
343
....: lines.'''
344
sage: len(mystr)
345
28
346
sage: def f(a):
347
....: '''This function is really quite nice,
348
....: although perhaps not very useful.'''
349
....: print "f called with a = ", a
350
....: y = integrate(SR(cyclotomic_polynomial(10)) + a, x)
351
....: return y + 1
352
sage: f(x)
353
f called with a = x
354
1/5*x^5 - 1/4*x^4 + 1/3*x^3 + x + 1
355
""", globals(), locals(), False)
356
except:
357
_st_.goboom(_sage_const_484 )
358
try:
359
_st_.current_tex_line = _sage_const_512
360
_st_.doctest(_sage_const_21 , r"""
361
sage: 1; 2; a=4; 3; a
362
1
363
2
364
3
365
4
366
""", globals(), locals(), False)
367
except:
368
_st_.goboom(_sage_const_518 )
369
try:
370
_st_.current_tex_line = _sage_const_519
371
_st_.inline(_sage_const_22 , latex(a))
372
except:
373
_st_.goboom(_sage_const_519 )
374
try:
375
_st_.current_tex_line = _sage_const_521
376
_st_.doctest(_sage_const_23 , r"""
377
sage: f(a)
378
f called with a = 4
379
1/5*x^5 - 1/4*x^4 + 1/3*x^3 - 1/2*x^2 + 5*x + 1
380
""", globals(), locals(), False)
381
except:
382
_st_.goboom(_sage_const_525 )
383
try:
384
_st_.current_tex_line = _sage_const_622
385
_st_.commandline(_sage_const_0 , r"""
386
sage: 1+1
387
sage: is_prime(57)
388
sage: if is_prime(57):
389
....: print 'prime'
390
....: else:
391
....: print 'composite'
392
""", globals(), locals(), True)
393
except:
394
_st_.goboom(_sage_const_629 )
395
try:
396
_st_.current_tex_line = _sage_const_639
397
_st_.commandline(_sage_const_1 , r"""
398
sage: x = 2010; len(x.divisors())
399
sage: print 'Hola, mundo!'
400
""", globals(), locals(), True)
401
except:
402
_st_.goboom(_sage_const_642 )
403
try:
404
_st_.current_tex_line = _sage_const_651
405
_st_.commandline(_sage_const_2 , r"""
406
sage: l = matrix([[1,0,0],[3/5,1,0],[-2/5,-2,1]])
407
sage: d = diagonal_matrix([15, -1, 4]) #@\label{diagonal}
408
sage: u = matrix([[1,0,1/3],[0,1,2],[0,0,1]]) #@\label{anotherlabel} \# foo
409
sage: l*d*u # this is a comment
410
""", globals(), locals(), True)
411
except:
412
_st_.goboom(_sage_const_656 )
413
try:
414
_st_.current_tex_line = _sage_const_667
415
_st_.commandline(_sage_const_3 , r"""
416
sage: l*d*u
417
sage: x = var('x')
418
sage: (1-cos(x)^2).trig_simplify()
419
""", globals(), locals(), False)
420
except:
421
_st_.goboom(_sage_const_671 )
422
try:
423
_st_.current_tex_line = _sage_const_683
424
_st_.commandline(_sage_const_4 , r"""
425
sage: pi.n(100)
426
""", globals(), locals(), True)
427
except:
428
_st_.goboom(_sage_const_685 )
429
try:
430
_st_.current_tex_line = _sage_const_693
431
_st_.commandline(_sage_const_5 , r"""
432
sage: plot(sin(x), (x, 0, 2*pi))
433
""", globals(), locals(), True)
434
except:
435
_st_.goboom(_sage_const_695 )
436
try:
437
_st_.current_tex_line = _sage_const_709
438
_st_.commandline(_sage_const_6 , r"""
439
sage: factor(x^2 + 2*x + 1)
440
(x + 999)^2
441
""", globals(), locals(), True)
442
except:
443
_st_.goboom(_sage_const_712 )
444
_st_.endofdoc()
445
446
447