import sagetex
_st_ = sagetex.SageTeXProcessor('P3b', version='2015/08/26 v3.0-92d9f7a', version_check=True)
_st_.current_tex_line = 4
_st_.blockbegin()
try:
4 * (10 // 4) + 10 % 4 == 10
3^2*4 + 2%5
sqrt(3.4)
sin(pi/3)
exp(2)
sin(10).n(digits=5)
N(sin(10),digits=10)
sqrt(pi).numerical_approx()
numerical_approx(pi, prec=200)
except:
_st_.goboom(14)
_st_.blockend()
try:
_st_.current_tex_line = 2
_st_.commandline(0, r"""
sage: a = 5
sage: type(a)
""", globals(), locals(), True)
except:
_st_.goboom(5)
try:
_st_.current_tex_line = 6
_st_.commandline(1, r"""
sage: a = 5/3
sage: type(a)
""", globals(), locals(), True)
except:
_st_.goboom(9)
try:
_st_.current_tex_line = 10
_st_.commandline(2, r"""
sage: a = 'hello'
sage: type(a)
""", globals(), locals(), True)
except:
_st_.goboom(13)
_st_.current_tex_line = 3
_st_.blockbegin()
try:
x = var('x')
solve(x^2 + 3*x + 2, x)
except:
_st_.goboom(6)
_st_.blockend()
try:
_st_.current_tex_line = 7
_st_.inline(0, latex(solve(x^2 + 3*x + 2, x)))
except:
_st_.goboom(7)
_st_.current_tex_line = 10
_st_.blockbegin()
try:
x, b, c = var('x b c')
solve([x^2 + b*x + c == 0],x)
except:
_st_.goboom(13)
_st_.blockend()
try:
_st_.current_tex_line = 14
_st_.inline(1, latex(solve([x^2 + b*x + c == 0],x)))
except:
_st_.goboom(14)
_st_.current_tex_line = 3
_st_.blockbegin()
try:
var('x y p q')
eq1 = p+q==9
eq2 = q*y+p*x==-6
eq3 = q*y^2+p*x^2==24
solve([eq1,eq2,eq3,p==1],p,q,x,y)
except:
_st_.goboom(9)
_st_.blockend()
_st_.current_tex_line = 10
_st_.blockbegin()
try:
s = solve([eq1,eq2,eq3,p==1],p,q,x,y)
except:
_st_.goboom(12)
_st_.blockend()
try:
_st_.current_tex_line = 13
_st_.inline(2, latex(s[0]))
except:
_st_.goboom(13)
try:
_st_.current_tex_line = 13
_st_.inline(3, latex(s[1]))
except:
_st_.goboom(13)
try:
_st_.current_tex_line = 3
_st_.commandline(3, r"""
sage: phi = var('phi')
sage: find_root(cos(phi)==sin(phi),0,pi/2)
""", globals(), locals(), True)
except:
_st_.goboom(6)
try:
_st_.current_tex_line = 8
_st_.commandline(4, r"""
sage: solve(x^2+x-1 > 0, x)
""", globals(), locals(), True)
except:
_st_.goboom(10)
_st_.current_tex_line = 5
_st_.blockbegin()
try:
s = (x^3+2*x+1).roots(x)
except:
_st_.goboom(7)
_st_.blockend()
try:
_st_.current_tex_line = 11
_st_.inline(4, latex(s[0]))
except:
_st_.goboom(11)
try:
_st_.current_tex_line = 11
_st_.inline(5, latex(s[1]))
except:
_st_.goboom(11)
try:
_st_.current_tex_line = 11
_st_.inline(6, latex(s[2]))
except:
_st_.goboom(11)
try:
_st_.current_tex_line = 11
_st_.inline(4, latex(s[0]))
except:
_st_.goboom(11)
try:
_st_.current_tex_line = 11
_st_.inline(5, latex(s[1]))
except:
_st_.goboom(11)
try:
_st_.current_tex_line = 11
_st_.inline(6, latex(s[2]))
except:
_st_.goboom(11)
try:
_st_.current_tex_line = 5
_st_.inline(7, latex((x^3+2*x+1).roots(x, ring=RR)))
except:
_st_.goboom(5)
_st_.current_tex_line = 9
_st_.blockbegin()
try:
s = (x^3+2*x+1).roots(x, ring=CC)
except:
_st_.goboom(11)
_st_.blockend()
try:
_st_.current_tex_line = 13
_st_.inline(8, latex(s[0]))
except:
_st_.goboom(13)
try:
_st_.current_tex_line = 13
_st_.inline(9, latex(s[1]))
except:
_st_.goboom(13)
try:
_st_.current_tex_line = 13
_st_.inline(10, latex(s[2]))
except:
_st_.goboom(13)
try:
_st_.current_tex_line = 2
_st_.commandline(5, r"""
sage: diff(sin(x^2), x, 4)
""", globals(), locals(), True)
except:
_st_.goboom(4)
try:
_st_.current_tex_line = 5
_st_.commandline(6, r"""
sage: x, y = var('x,y')
sage: f = x^2 + 17*y^2
sage: f.diff(y)
""", globals(), locals(), True)
except:
_st_.goboom(9)
try:
_st_.current_tex_line = 2
_st_.commandline(7, r"""
sage: integral(x*sin(x^2), x)
sage: integral(x/(x^2+1), x, 0, 1)
""", globals(), locals(), True)
except:
_st_.goboom(5)
try:
_st_.current_tex_line = 8
_st_.commandline(8, r"""
sage: f = 1/((1+x)*(x-1))
sage: f.partial_fraction(x)
""", globals(), locals(), True)
except:
_st_.goboom(11)
try:
_st_.current_tex_line = 2
_st_.commandline(9, r"""
sage: simplify(arccos(sin(pi/3)))
sage: simplify(exp(i*pi/6))
""", globals(), locals(), True)
except:
_st_.goboom(5)
try:
_st_.current_tex_line = 6
_st_.commandline(10, r"""
sage: a = var('a')
sage: y = cos(x+a) * (x+1)
sage: y.subs(a=-x)
sage: y.subs(x=pi/2, a=pi/3)
""", globals(), locals(), True)
except:
_st_.goboom(11)
try:
_st_.current_tex_line = 2
_st_.commandline(11, r"""
sage: y, z = var('y, z')
sage: f = x^3 + y^2 + z
sage: f.subs_expr(x^3 == y^2, z==1)
""", globals(), locals(), True)
except:
_st_.goboom(6)
try:
_st_.current_tex_line = 7
_st_.commandline(12, r"""
sage: f(x)=(2*x+1)^3
sage: f(-3)
sage: f.expand()
""", globals(), locals(), True)
except:
_st_.goboom(11)
try:
_st_.current_tex_line = 12
_st_.commandline(13, r"""
sage: ((x+y+sin(x))^2).expand().collect(sin(x))
""", globals(), locals(), True)
except:
_st_.goboom(14)
try:
_st_.current_tex_line = 2
_st_.commandline(14, r"""
sage: u = sin(x) + x*cos(y)
sage: v = u.function(x, y)
sage: v
""", globals(), locals(), True)
except:
_st_.goboom(6)
try:
_st_.current_tex_line = 7
_st_.commandline(15, r"""
sage: f = (e^x-1) / (1+e^(x/2))
sage: f.simplify_exp()
""", globals(), locals(), True)
except:
_st_.goboom(10)
try:
_st_.current_tex_line = 11
_st_.commandline(16, r"""
sage: f = cos(x)^6 + sin(x)^6 + 3 * sin(x)^2 * cos(x)^2
sage: f.simplify_trig()
""", globals(), locals(), True)
except:
_st_.goboom(14)
try:
_st_.current_tex_line = 2
_st_.commandline(17, r"""
sage: f = cos(x)^6
sage: f.reduce_trig()
sage: f = sin(5 * x)
sage: f.expand_trig()
sage: n = var('n')
sage: f = factorial(n+1)/factorial(n)
sage: f.simplify_factorial()
sage: f = sqrt(abs(x)^2)
sage: f.simplify_radical()
""", globals(), locals(), True)
except:
_st_.goboom(12)
try:
_st_.current_tex_line = 2
_st_.commandline(18, r"""
sage: assume(x > 0)
sage: bool(sqrt(x^2) == x)
sage: forget(x > 0)
sage: bool(sqrt(x^2) == x)
sage: n = var('n')
sage: assume(n, 'integer')
sage: sin(n*pi).simplify()
""", globals(), locals(), True)
except:
_st_.goboom(10)
try:
_st_.current_tex_line = 3
_st_.commandline(19, r"""
sage: t = var('t')
sage: x = function('x',t)
sage: DE = diff(x, t) + x - 1
sage: desolve(DE, [x,t])
""", globals(), locals(), True)
except:
_st_.goboom(8)
try:
_st_.current_tex_line = 9
_st_.commandline(20, r"""
sage: x = var('x')
sage: y = function('y', x)
sage: desolve(diff(y,x,x) + x*diff(y,x) + y == 0, y, [0,0,1])
""", globals(), locals(), True)
except:
_st_.goboom(13)
try:
_st_.current_tex_line = 2
_st_.commandline(21, r"""
sage: k, n = var('k, n')
sage: sum(k, k, 1, n).factor()
sage: sum(k * binomial(n, k), k, 0, n)
sage: n, k, y = var('n, k, y')
sage: sum(binomial(n,k) * x^k * y^(n-k), k, 0, n)
sage: a, q, k, n = var('a, q, k, n')
sage: sum(a*q^k, k, 0, n)
""", globals(), locals(), True)
except:
_st_.goboom(10)
try:
_st_.current_tex_line = 2
_st_.commandline(22, r"""
sage: a, q, k, n = var('a, q, k, n')
sage: sum(a*q^k, k, 0, n)
sage: assume(abs(q) < 1)
sage: sum(a*q^k, k, 0, infinity)
""", globals(), locals(), True)
except:
_st_.goboom(7)
try:
_st_.current_tex_line = 2
_st_.commandline(23, r"""
sage: limit((x**(1/3) - 2) / ((x + 19)**(1/3) - 3), x = 8)
sage: f(x) = (cos(pi/4-x)-tan(x))/(1-sin(pi/4 + x))
sage: limit(f(x), x = pi/4)
sage: limit(f(x), x = pi/4, dir='minus')
sage: limit(f(x), x = pi/4, dir='plus')
sage: u(n) = n^100 / 100^n
sage: limit(u(n), n=infinity)
""", globals(), locals(), True)
except:
_st_.goboom(10)
try:
_st_.current_tex_line = 2
_st_.commandline(24, r"""
sage: taylor((1+arctan(x))**(1/x), x, 0, 3)
sage: (ln(2*sin(x))).series(x==pi/6, 3)
sage: (ln(2*sin(x))).series(x==pi/6, 3).truncate()
sage: f = arctan(x).series(x, 10)
sage: f
sage: (16*f.subs(x==1/5) - 4*f.subs(x==1/239)).n()
""", globals(), locals(), True)
except:
_st_.goboom(9)
try:
_st_.current_tex_line = 7
_st_.inline(11, latex(matrix([[1, 2], [3,4]])^2))
except:
_st_.goboom(7)
try:
_st_.current_tex_line = 7
_st_.plot(0, format='png', _p_=plot(sin(x), 0, pi), axes=False)
except:
_st_.goboom(7)
_st_.current_tex_line = 12
_st_.blockbegin()
try:
var('x')
f(x) = sin(x) - 1
g(x) = log(x)
h(x) = diff(f(x) * g(x), x)
except:
_st_.goboom(17)
_st_.blockend()
try:
_st_.current_tex_line = 9
_st_.inline(12, latex(h(2)))
except:
_st_.goboom(9)
try:
_st_.current_tex_line = 11
_st_.commandline(25, r"""
sage: 1+1
sage: factor(x^2 + 2*x + 1)
""", globals(), locals(), True)
except:
_st_.goboom(14)
_st_.endofdoc()