import sagetex
_st_ = sagetex.SageTeXProcessor('sagetex', version='2015/08/26 v3.0-92d9f7a', version_check=True)
try:
_st_.current_tex_line = 35
_st_.inline(0, latex(2+2))
except:
_st_.goboom(35)
try:
_st_.current_tex_line = 36
_st_.inline(1, latex(mod(2018, 100)))
except:
_st_.goboom(36)
try:
_st_.current_tex_line = 38
_st_.inline(2, latex(Integer(mod(2018, 100))^21))
except:
_st_.goboom(38)
try:
_st_.current_tex_line = 39
_st_.inline(3, latex(2018%42))
except:
_st_.goboom(39)
_st_.current_tex_line = 42
_st_.blockbegin()
try:
1+1
var('a,b,c')
eqn = [a+b*c==1, b-a*c==0, a+b==5]
s = solve(eqn, a,b,c)
except:
_st_.goboom(47)
_st_.blockend()
try:
_st_.current_tex_line = 49
_st_.inline(4, latex(eqn))
except:
_st_.goboom(49)
try:
_st_.current_tex_line = 51
_st_.inline(5, latex(s[0]))
except:
_st_.goboom(51)
try:
_st_.current_tex_line = 54
_st_.inline(6, latex(s[1]))
except:
_st_.goboom(54)
_st_.current_tex_line = 58
_st_.blockbegin()
try:
E = EllipticCurve("37a")
except:
_st_.goboom(60)
_st_.blockend()
try:
_st_.current_tex_line = 63
_st_.inline(7, latex(E))
except:
_st_.goboom(63)
try:
_st_.current_tex_line = 64
_st_.inline(8, latex(E.discriminant()))
except:
_st_.goboom(64)
_st_.current_tex_line = 68
_st_.blockbegin()
try:
try:
E = load('E2')
except IOError:
E = EllipticCurve([1,2,3,4,5])
E.anlist(100000)
E.save('E2')
except:
_st_.goboom(75)
_st_.blockend()
try:
_st_.current_tex_line = 77
_st_.inline(9, latex(E))
except:
_st_.goboom(77)
try:
_st_.current_tex_line = 78
_st_.inline(10, latex(E.anlist(100000)[9999]))
except:
_st_.goboom(78)
_st_.current_tex_line = 81
_st_.blockbegin()
try:
e = 2
e = 3*e + 1
except:
_st_.goboom(84)
_st_.blockend()
try:
_st_.current_tex_line = 85
_st_.inline(11, latex(e))
except:
_st_.goboom(85)
_st_.current_tex_line = 87
_st_.blockbegin()
try:
var('x')
f(x) = log(sin(x)/x)
except:
_st_.goboom(90)
_st_.blockend()
try:
_st_.current_tex_line = 91
_st_.inline(12, latex( f.taylor(x, 0, 10) ))
except:
_st_.goboom(91)
try:
_st_.current_tex_line = 97
_st_.plot(0, format='notprovided', _p_=E.plot(-3,3))
except:
_st_.goboom(97)
_st_.current_tex_line = 99
_st_.blockbegin()
try:
var('x')
f(x) = -x^3+3*x^2+7*x-4
except:
_st_.goboom(104)
_st_.blockend()
_st_.current_tex_line = 107
_st_.blockbegin()
try:
p = plot(f, x, -5, 5)
except:
_st_.goboom(109)
_st_.blockend()
try:
_st_.current_tex_line = 113
_st_.plot(1, format='notprovided', _p_=p)
except:
_st_.goboom(113)
try:
_st_.current_tex_line = 118
_st_.plot(2, format='notprovided', _p_=p, axes=False)
except:
_st_.goboom(118)
_st_.current_tex_line = 122
_st_.blockbegin()
try:
f = maxima('sin(x)^2*exp(x)')
g = f.integrate('x')
except:
_st_.goboom(125)
_st_.blockend()
_st_.current_tex_line = 127
_st_.blockbegin()
try:
plot1 = plot(g.sage(),x,-1,2*pi)
except:
_st_.goboom(130)
_st_.blockend()
try:
_st_.current_tex_line = 136
_st_.plot(3, format='png', _p_=plot1)
except:
_st_.goboom(136)
try:
_st_.current_tex_line = 146
_st_.plot(4, format='notprovided', _p_=plot1 + plot(f.sage(),x,-1,2*pi,rgbcolor=hue(0.4)), figsize=[1,2])
except:
_st_.goboom(146)
_st_.current_tex_line = 151
_st_.blockbegin()
try:
p = plot(x, 0, 1) + circle((0,0), 1)
p.set_aspect_ratio(1)
except:
_st_.goboom(154)
_st_.blockend()
try:
_st_.current_tex_line = 158
_st_.plot(5, format='notprovided', _p_=p)
except:
_st_.goboom(158)
_st_.current_tex_line = 161
_st_.blockbegin()
try:
s = 7
s2 = 2^s
P.<x> = GF(2)[]
M = matrix(parent(x),s2)
for i in range(s2):
p = (1+x)^i
pc = p.coefficients(sparse=False)
a = pc.count(1)
for j in range(a):
idx = pc.index(1)
M[i,idx+j] = pc.pop(idx)
matrixprogram = matrix_plot(M,cmap='Greys')
except:
_st_.goboom(175)
_st_.blockend()
try:
_st_.current_tex_line = 178
_st_.plot(6, format='notprovided', _p_=matrixprogram)
except:
_st_.goboom(178)
try:
_st_.current_tex_line = 181
_st_.inline(13, latex(var('x')))
except:
_st_.goboom(181)
try:
_st_.current_tex_line = 253
_st_.inline(14, latex(var('x')))
except:
_st_.goboom(253)
_st_.current_tex_line = 337
_st_.blockbegin()
try:
x, y = var('x y')
except:
_st_.goboom(339)
_st_.blockend()
try:
_st_.current_tex_line = 345
_st_.plot(7, format='notprovided', _p_=plot3d(sin(pi*(x^2+y^2))/2,(x,-1,1),(y,-1,1)))
except:
_st_.goboom(345)
_st_.current_tex_line = 349
_st_.blockbegin()
try:
G = graphs.CubeGraph(5)
except:
_st_.goboom(351)
_st_.blockend()
try:
_st_.current_tex_line = 355
_st_.plot(8, format='png', _p_=G.plot3d())
except:
_st_.goboom(355)
print 'SageTeX paused on sagetex.tex line 365'
"""
try:
_st_.current_tex_line = 367
_st_.inline(15, latex(factor(2^325 + 1)))
except:
_st_.goboom(367)
_st_.current_tex_line = 370
_st_.blockbegin()
try:
import time
time.sleep(15)
except:
_st_.goboom(373)
_st_.blockend()
try:
_st_.current_tex_line = 375
_st_.plot(9, format='notprovided', _p_=plot(2*sin(x^2) + x^2, (x, 0, 5)))
except:
_st_.goboom(375)
"""
print 'SageTeX unpaused on sagetex.tex line 377'
_st_.current_tex_line = 389
_st_.blockbegin()
try:
def pascals_triangle(n):
s = [r"\begin{tabular}{cc|" + "r" * (n+1) + "}"]
s.append(r" & & $k$: & \\")
s.append(r" & ")
for k in [0..n]:
s.append("& {0} ".format(k))
s.append(r"\\")
s.append(r"\hline" + "\n" + r"$n$: & 0 & 1 & \\")
for r in [1..n]:
s.append(" & {0} ".format(r))
for k in [0..r]:
s.append("& {0} ".format(binomial(r, k)))
s.append(r"\\")
s.append(r"\end{tabular}")
return ''.join(s)
n = 8
except:
_st_.goboom(413)
_st_.blockend()
try:
_st_.current_tex_line = 420
_st_.inline(16, pascals_triangle(n))
except:
_st_.goboom(420)
try:
_st_.current_tex_line = 426
_st_.doctest(17, r"""
sage: 2+2
4
sage: print 'middle'
middle
sage: factor(x^2 + 2*x + 1)
(x + 1)^2
""", globals(), locals(), False)
except:
_st_.goboom(433)
try:
_st_.current_tex_line = 448
_st_.doctest(18, r"""
sage: print 'middle'
middle
""", globals(), locals(), True)
except:
_st_.goboom(451)
try:
_st_.current_tex_line = 455
_st_.doctest(19, r"""
sage: is_prime(57)
toothpaste
""", globals(), locals(), True)
except:
_st_.goboom(458)
try:
_st_.current_tex_line = 463
_st_.doctest(20, r"""
sage: gcd([5656565656,
....: 4747474747,
....: 123456789])
1
sage: mystr = '''my
....: string
....: has
....: several
....: lines.'''
sage: len(mystr)
28
sage: def f(a):
....: '''This function is really quite nice,
....: although perhaps not very useful.'''
....: print "f called with a = ", a
....: y = integrate(SR(cyclotomic_polynomial(10)) + a, x)
....: return y + 1
sage: f(x)
f called with a = x
1/5*x^5 - 1/4*x^4 + 1/3*x^3 + x + 1
""", globals(), locals(), False)
except:
_st_.goboom(484)
try:
_st_.current_tex_line = 512
_st_.doctest(21, r"""
sage: 1; 2; a=4; 3; a
1
2
3
4
""", globals(), locals(), False)
except:
_st_.goboom(518)
try:
_st_.current_tex_line = 519
_st_.inline(22, latex(a))
except:
_st_.goboom(519)
try:
_st_.current_tex_line = 521
_st_.doctest(23, r"""
sage: f(a)
f called with a = 4
1/5*x^5 - 1/4*x^4 + 1/3*x^3 - 1/2*x^2 + 5*x + 1
""", globals(), locals(), False)
except:
_st_.goboom(525)
try:
_st_.current_tex_line = 622
_st_.commandline(0, r"""
sage: 1+1
sage: is_prime(57)
sage: if is_prime(57):
....: print 'prime'
....: else:
....: print 'composite'
""", globals(), locals(), True)
except:
_st_.goboom(629)
try:
_st_.current_tex_line = 639
_st_.commandline(1, r"""
sage: x = 2010; len(x.divisors())
sage: print 'Hola, mundo!'
""", globals(), locals(), True)
except:
_st_.goboom(642)
try:
_st_.current_tex_line = 651
_st_.commandline(2, r"""
sage: l = matrix([[1,0,0],[3/5,1,0],[-2/5,-2,1]])
sage: d = diagonal_matrix([15, -1, 4]) #@\label{diagonal}
sage: u = matrix([[1,0,1/3],[0,1,2],[0,0,1]]) #@\label{anotherlabel} \# foo
sage: l*d*u # this is a comment
""", globals(), locals(), True)
except:
_st_.goboom(656)
try:
_st_.current_tex_line = 667
_st_.commandline(3, r"""
sage: l*d*u
sage: x = var('x')
sage: (1-cos(x)^2).trig_simplify()
""", globals(), locals(), False)
except:
_st_.goboom(671)
try:
_st_.current_tex_line = 683
_st_.commandline(4, r"""
sage: pi.n(100)
""", globals(), locals(), True)
except:
_st_.goboom(685)
try:
_st_.current_tex_line = 693
_st_.commandline(5, r"""
sage: plot(sin(x), (x, 0, 2*pi))
""", globals(), locals(), True)
except:
_st_.goboom(695)
try:
_st_.current_tex_line = 709
_st_.commandline(6, r"""
sage: factor(x^2 + 2*x + 1)
(x + 999)^2
""", globals(), locals(), True)
except:
_st_.goboom(712)
_st_.endofdoc()