Examples of using latex in cocalc
## -*- encoding: utf-8 -*-12# This file was *autogenerated* from the file sagetex.sagetex.sage3from sage.all_cmdline import * # import sage library45_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.6import sagetex7_st_ = sagetex.SageTeXProcessor('sagetex', version='2015/08/26 v3.0-92d9f7a', version_check=True)8try:9_st_.current_tex_line = _sage_const_3510_st_.inline(_sage_const_0 , latex(_sage_const_2 +_sage_const_2 ))11except:12_st_.goboom(_sage_const_35 )13try:14_st_.current_tex_line = _sage_const_3615_st_.inline(_sage_const_1 , latex(mod(_sage_const_2018 , _sage_const_100 )))16except:17_st_.goboom(_sage_const_36 )18try:19_st_.current_tex_line = _sage_const_3820_st_.inline(_sage_const_2 , latex(Integer(mod(_sage_const_2018 , _sage_const_100 ))**_sage_const_21 ))21except:22_st_.goboom(_sage_const_38 )23try:24_st_.current_tex_line = _sage_const_3925_st_.inline(_sage_const_3 , latex(_sage_const_2018 %_sage_const_42 ))26except:27_st_.goboom(_sage_const_39 )28_st_.current_tex_line = _sage_const_4229_st_.blockbegin()30try:31_sage_const_1 +_sage_const_132var('a,b,c')33eqn = [a+b*c==_sage_const_1 , b-a*c==_sage_const_0 , a+b==_sage_const_5 ]34s = solve(eqn, a,b,c)35except:36_st_.goboom(_sage_const_47 )37_st_.blockend()38try:39_st_.current_tex_line = _sage_const_4940_st_.inline(_sage_const_4 , latex(eqn))41except:42_st_.goboom(_sage_const_49 )43try:44_st_.current_tex_line = _sage_const_5145_st_.inline(_sage_const_5 , latex(s[_sage_const_0 ]))46except:47_st_.goboom(_sage_const_51 )48try:49_st_.current_tex_line = _sage_const_5450_st_.inline(_sage_const_6 , latex(s[_sage_const_1 ]))51except:52_st_.goboom(_sage_const_54 )53_st_.current_tex_line = _sage_const_5854_st_.blockbegin()55try:56E = EllipticCurve("37a")57except:58_st_.goboom(_sage_const_60 )59_st_.blockend()60try:61_st_.current_tex_line = _sage_const_6362_st_.inline(_sage_const_7 , latex(E))63except:64_st_.goboom(_sage_const_63 )65try:66_st_.current_tex_line = _sage_const_6467_st_.inline(_sage_const_8 , latex(E.discriminant()))68except:69_st_.goboom(_sage_const_64 )70_st_.current_tex_line = _sage_const_6871_st_.blockbegin()72try:73try:74E = load('E2')75except IOError:76E = EllipticCurve([_sage_const_1 ,_sage_const_2 ,_sage_const_3 ,_sage_const_4 ,_sage_const_5 ])77E.anlist(_sage_const_100000 )78E.save('E2')79except:80_st_.goboom(_sage_const_75 )81_st_.blockend()82try:83_st_.current_tex_line = _sage_const_7784_st_.inline(_sage_const_9 , latex(E))85except:86_st_.goboom(_sage_const_77 )87try:88_st_.current_tex_line = _sage_const_7889_st_.inline(_sage_const_10 , latex(E.anlist(_sage_const_100000 )[_sage_const_9999 ]))90except:91_st_.goboom(_sage_const_78 )92_st_.current_tex_line = _sage_const_8193_st_.blockbegin()94try:95e = _sage_const_296e = _sage_const_3 *e + _sage_const_197except:98_st_.goboom(_sage_const_84 )99_st_.blockend()100try:101_st_.current_tex_line = _sage_const_85102_st_.inline(_sage_const_11 , latex(e))103except:104_st_.goboom(_sage_const_85 )105_st_.current_tex_line = _sage_const_87106_st_.blockbegin()107try:108var('x')109__tmp__=var("x"); f = symbolic_expression(log(sin(x)/x)).function(x)110except:111_st_.goboom(_sage_const_90 )112_st_.blockend()113try:114_st_.current_tex_line = _sage_const_91115_st_.inline(_sage_const_12 , latex( f.taylor(x, _sage_const_0 , _sage_const_10 ) ))116except:117_st_.goboom(_sage_const_91 )118try:119_st_.current_tex_line = _sage_const_97120_st_.plot(_sage_const_0 , format='notprovided', _p_=E.plot(-_sage_const_3 ,_sage_const_3 ))121except:122_st_.goboom(_sage_const_97 )123_st_.current_tex_line = _sage_const_99124_st_.blockbegin()125try:126# the var line is unecessary unless you've defined x to be something127# other than a symbolic variable128var('x')129__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)130except:131_st_.goboom(_sage_const_104 )132_st_.blockend()133_st_.current_tex_line = _sage_const_107134_st_.blockbegin()135try:136p = plot(f, x, -_sage_const_5 , _sage_const_5 )137except:138_st_.goboom(_sage_const_109 )139_st_.blockend()140try:141_st_.current_tex_line = _sage_const_113142_st_.plot(_sage_const_1 , format='notprovided', _p_=p)143except:144_st_.goboom(_sage_const_113 )145try:146_st_.current_tex_line = _sage_const_118147_st_.plot(_sage_const_2 , format='notprovided', _p_=p, axes=False)148except:149_st_.goboom(_sage_const_118 )150_st_.current_tex_line = _sage_const_122151_st_.blockbegin()152try:153f = maxima('sin(x)^2*exp(x)')154g = f.integrate('x')155except:156_st_.goboom(_sage_const_125 )157_st_.blockend()158_st_.current_tex_line = _sage_const_127159_st_.blockbegin()160try:161# g is a Maxima thingy, it needs to get converted into a Sage object162plot1 = plot(g.sage(),x,-_sage_const_1 ,_sage_const_2 *pi)163except:164_st_.goboom(_sage_const_130 )165_st_.blockend()166try:167_st_.current_tex_line = _sage_const_136168_st_.plot(_sage_const_3 , format='png', _p_=plot1)169except:170_st_.goboom(_sage_const_136 )171try:172_st_.current_tex_line = _sage_const_146173_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 ])174except:175_st_.goboom(_sage_const_146 )176_st_.current_tex_line = _sage_const_151177_st_.blockbegin()178try:179p = plot(x, _sage_const_0 , _sage_const_1 ) + circle((_sage_const_0 ,_sage_const_0 ), _sage_const_1 )180p.set_aspect_ratio(_sage_const_1 )181except:182_st_.goboom(_sage_const_154 )183_st_.blockend()184try:185_st_.current_tex_line = _sage_const_158186_st_.plot(_sage_const_5 , format='notprovided', _p_=p)187except:188_st_.goboom(_sage_const_158 )189_st_.current_tex_line = _sage_const_161190_st_.blockbegin()191try:192s = _sage_const_7193s2 = _sage_const_2 **s194P = GF(_sage_const_2 )['x']; (x,) = P._first_ngens(1)195M = matrix(parent(x),s2)196for i in range(s2):197p = (_sage_const_1 +x)**i198pc = p.coefficients(sparse=False)199a = pc.count(_sage_const_1 )200for j in range(a):201idx = pc.index(_sage_const_1 )202M[i,idx+j] = pc.pop(idx)203204matrixprogram = matrix_plot(M,cmap='Greys')205except:206_st_.goboom(_sage_const_175 )207_st_.blockend()208try:209_st_.current_tex_line = _sage_const_178210_st_.plot(_sage_const_6 , format='notprovided', _p_=matrixprogram)211except:212_st_.goboom(_sage_const_178 )213try:214_st_.current_tex_line = _sage_const_181215_st_.inline(_sage_const_13 , latex(var('x')))216except:217_st_.goboom(_sage_const_181 )218try:219_st_.current_tex_line = _sage_const_253220_st_.inline(_sage_const_14 , latex(var('x')))221except:222_st_.goboom(_sage_const_253 )223_st_.current_tex_line = _sage_const_337224_st_.blockbegin()225try:226x, y = var('x y')227except:228_st_.goboom(_sage_const_339 )229_st_.blockend()230try:231_st_.current_tex_line = _sage_const_345232_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 )))233except:234_st_.goboom(_sage_const_345 )235_st_.current_tex_line = _sage_const_349236_st_.blockbegin()237try:238G = graphs.CubeGraph(_sage_const_5 )239except:240_st_.goboom(_sage_const_351 )241_st_.blockend()242try:243_st_.current_tex_line = _sage_const_355244_st_.plot(_sage_const_8 , format='png', _p_=G.plot3d())245except:246_st_.goboom(_sage_const_355 )247print 'SageTeX paused on sagetex.tex line 365'248"""249try:250_st_.current_tex_line = 367251_st_.inline(15, latex(factor(2^325 + 1)))252except:253_st_.goboom(367)254_st_.current_tex_line = 370255_st_.blockbegin()256try:257import time258time.sleep(15)259except:260_st_.goboom(373)261_st_.blockend()262try:263_st_.current_tex_line = 375264_st_.plot(9, format='notprovided', _p_=plot(2*sin(x^2) + x^2, (x, 0, 5)))265except:266_st_.goboom(375)267"""268print 'SageTeX unpaused on sagetex.tex line 377'269_st_.current_tex_line = _sage_const_389270_st_.blockbegin()271try:272def pascals_triangle(n):273# start of the table274s = [r"\begin{tabular}{cc|" + "r" * (n+_sage_const_1 ) + "}"]275s.append(r" & & $k$: & \\")276# second row, with k values:277s.append(r" & ")278for k in (ellipsis_range(_sage_const_0 ,Ellipsis,n)):279s.append("& {0} ".format(k))280s.append(r"\\")281# the n = 0 row:282s.append(r"\hline" + "\n" + r"$n$: & 0 & 1 & \\")283# now the rest of the rows284for r in (ellipsis_range(_sage_const_1 ,Ellipsis,n)):285s.append(" & {0} ".format(r))286for k in (ellipsis_range(_sage_const_0 ,Ellipsis,r)):287s.append("& {0} ".format(binomial(r, k)))288s.append(r"\\")289# add the last line and return290s.append(r"\end{tabular}")291return ''.join(s)292293# how big should the table be?294n = _sage_const_8295except:296_st_.goboom(_sage_const_413 )297_st_.blockend()298try:299_st_.current_tex_line = _sage_const_420300_st_.inline(_sage_const_16 , pascals_triangle(n))301except:302_st_.goboom(_sage_const_420 )303try:304_st_.current_tex_line = _sage_const_426305_st_.doctest(_sage_const_17 , r"""306sage: 2+23074308sage: print 'middle'309middle310sage: factor(x^2 + 2*x + 1)311(x + 1)^2312""", globals(), locals(), False)313except:314_st_.goboom(_sage_const_433 )315try:316_st_.current_tex_line = _sage_const_448317_st_.doctest(_sage_const_18 , r"""318sage: print 'middle'319middle320""", globals(), locals(), True)321except:322_st_.goboom(_sage_const_451 )323try:324_st_.current_tex_line = _sage_const_455325_st_.doctest(_sage_const_19 , r"""326sage: is_prime(57)327toothpaste328""", globals(), locals(), True)329except:330_st_.goboom(_sage_const_458 )331try:332_st_.current_tex_line = _sage_const_463333_st_.doctest(_sage_const_20 , r"""334sage: gcd([5656565656,335....: 4747474747,336....: 123456789])3371338sage: mystr = '''my339....: string340....: has341....: several342....: lines.'''343sage: len(mystr)34428345sage: def f(a):346....: '''This function is really quite nice,347....: although perhaps not very useful.'''348....: print "f called with a = ", a349....: y = integrate(SR(cyclotomic_polynomial(10)) + a, x)350....: return y + 1351sage: f(x)352f called with a = x3531/5*x^5 - 1/4*x^4 + 1/3*x^3 + x + 1354""", globals(), locals(), False)355except:356_st_.goboom(_sage_const_484 )357try:358_st_.current_tex_line = _sage_const_512359_st_.doctest(_sage_const_21 , r"""360sage: 1; 2; a=4; 3; a3611362236333644365""", globals(), locals(), False)366except:367_st_.goboom(_sage_const_518 )368try:369_st_.current_tex_line = _sage_const_519370_st_.inline(_sage_const_22 , latex(a))371except:372_st_.goboom(_sage_const_519 )373try:374_st_.current_tex_line = _sage_const_521375_st_.doctest(_sage_const_23 , r"""376sage: f(a)377f called with a = 43781/5*x^5 - 1/4*x^4 + 1/3*x^3 - 1/2*x^2 + 5*x + 1379""", globals(), locals(), False)380except:381_st_.goboom(_sage_const_525 )382try:383_st_.current_tex_line = _sage_const_622384_st_.commandline(_sage_const_0 , r"""385sage: 1+1386sage: is_prime(57)387sage: if is_prime(57):388....: print 'prime'389....: else:390....: print 'composite'391""", globals(), locals(), True)392except:393_st_.goboom(_sage_const_629 )394try:395_st_.current_tex_line = _sage_const_639396_st_.commandline(_sage_const_1 , r"""397sage: x = 2010; len(x.divisors())398sage: print 'Hola, mundo!'399""", globals(), locals(), True)400except:401_st_.goboom(_sage_const_642 )402try:403_st_.current_tex_line = _sage_const_651404_st_.commandline(_sage_const_2 , r"""405sage: l = matrix([[1,0,0],[3/5,1,0],[-2/5,-2,1]])406sage: d = diagonal_matrix([15, -1, 4]) #@\label{diagonal}407sage: u = matrix([[1,0,1/3],[0,1,2],[0,0,1]]) #@\label{anotherlabel} \# foo408sage: l*d*u # this is a comment409""", globals(), locals(), True)410except:411_st_.goboom(_sage_const_656 )412try:413_st_.current_tex_line = _sage_const_667414_st_.commandline(_sage_const_3 , r"""415sage: l*d*u416sage: x = var('x')417sage: (1-cos(x)^2).trig_simplify()418""", globals(), locals(), False)419except:420_st_.goboom(_sage_const_671 )421try:422_st_.current_tex_line = _sage_const_683423_st_.commandline(_sage_const_4 , r"""424sage: pi.n(100)425""", globals(), locals(), True)426except:427_st_.goboom(_sage_const_685 )428try:429_st_.current_tex_line = _sage_const_693430_st_.commandline(_sage_const_5 , r"""431sage: plot(sin(x), (x, 0, 2*pi))432""", globals(), locals(), True)433except:434_st_.goboom(_sage_const_695 )435try:436_st_.current_tex_line = _sage_const_709437_st_.commandline(_sage_const_6 , r"""438sage: factor(x^2 + 2*x + 1)439(x + 999)^2440""", globals(), locals(), True)441except:442_st_.goboom(_sage_const_712 )443_st_.endofdoc()444445446447