CoCalc Shared Files10. Sagetex / P3b.sagetex.sage
Authors: Ivica Nakić, Vedran Čačić
1## -*- encoding: utf-8 -*-
2## This file (P3b.sagetex.sage) was *autogenerated* from P3b.tex with sagetex.sty version 2015/08/26 v3.0-92d9f7a.
3import sagetex
4_st_ = sagetex.SageTeXProcessor('P3b', version='2015/08/26 v3.0-92d9f7a', version_check=True)
5_st_.current_tex_line = 4
6_st_.blockbegin()
7try:
8 4 * (10 // 4) + 10 % 4 == 10
9 3^2*4 + 2%5
10 sqrt(3.4)
11 sin(pi/3)
12 exp(2)
13 sin(10).n(digits=5)
14 N(sin(10),digits=10)
15 sqrt(pi).numerical_approx()
16 numerical_approx(pi, prec=200)
17except:
18 _st_.goboom(14)
19_st_.blockend()
20try:
21 _st_.current_tex_line = 2
22 _st_.commandline(0, r"""
23    sage: a = 5
24    sage: type(a)
25""", globals(), locals(), True)
26except:
27 _st_.goboom(5)
28try:
29 _st_.current_tex_line = 6
30 _st_.commandline(1, r"""
31    sage: a = 5/3
32    sage: type(a)
33""", globals(), locals(), True)
34except:
35 _st_.goboom(9)
36try:
37 _st_.current_tex_line = 10
38 _st_.commandline(2, r"""
39    sage: a = 'hello'
40    sage: type(a)
41""", globals(), locals(), True)
42except:
43 _st_.goboom(13)
44_st_.current_tex_line = 3
45_st_.blockbegin()
46try:
47     x = var('x')
48     solve(x^2 + 3*x + 2, x)
49except:
50 _st_.goboom(6)
51_st_.blockend()
52try:
53 _st_.current_tex_line = 7
54 _st_.inline(0, latex(solve(x^2 + 3*x + 2, x)))
55except:
56 _st_.goboom(7)
57_st_.current_tex_line = 10
58_st_.blockbegin()
59try:
60     x, b, c = var('x b c')
61     solve([x^2 + b*x + c == 0],x)
62except:
63 _st_.goboom(13)
64_st_.blockend()
65try:
66 _st_.current_tex_line = 14
67 _st_.inline(1, latex(solve([x^2 + b*x + c == 0],x)))
68except:
69 _st_.goboom(14)
70_st_.current_tex_line = 3
71_st_.blockbegin()
72try:
73   var('x y p q')
74   eq1 = p+q==9
75   eq2 = q*y+p*x==-6
76   eq3 = q*y^2+p*x^2==24
77   solve([eq1,eq2,eq3,p==1],p,q,x,y)
78except:
79 _st_.goboom(9)
80_st_.blockend()
81_st_.current_tex_line = 10
82_st_.blockbegin()
83try:
84   s = solve([eq1,eq2,eq3,p==1],p,q,x,y)
85except:
86 _st_.goboom(12)
87_st_.blockend()
88try:
89 _st_.current_tex_line = 13
90 _st_.inline(2, latex(s[0]))
91except:
92 _st_.goboom(13)
93try:
94 _st_.current_tex_line = 13
95 _st_.inline(3, latex(s[1]))
96except:
97 _st_.goboom(13)
98try:
99 _st_.current_tex_line = 3
100 _st_.commandline(3, r"""
101    sage: phi = var('phi')
102    sage: find_root(cos(phi)==sin(phi),0,pi/2)
103""", globals(), locals(), True)
104except:
105 _st_.goboom(6)
106try:
107 _st_.current_tex_line = 8
108 _st_.commandline(4, r"""
109    sage: solve(x^2+x-1 > 0, x)
110""", globals(), locals(), True)
111except:
112 _st_.goboom(10)
113_st_.current_tex_line = 5
114_st_.blockbegin()
115try:
116     s = (x^3+2*x+1).roots(x)
117except:
118 _st_.goboom(7)
119_st_.blockend()
120try:
121 _st_.current_tex_line = 11
122 _st_.inline(4, latex(s[0]))
123except:
124 _st_.goboom(11)
125try:
126 _st_.current_tex_line = 11
127 _st_.inline(5, latex(s[1]))
128except:
129 _st_.goboom(11)
130try:
131 _st_.current_tex_line = 11
132 _st_.inline(6, latex(s[2]))
133except:
134 _st_.goboom(11)
135try:
136 _st_.current_tex_line = 11
137 _st_.inline(4, latex(s[0]))
138except:
139 _st_.goboom(11)
140try:
141 _st_.current_tex_line = 11
142 _st_.inline(5, latex(s[1]))
143except:
144 _st_.goboom(11)
145try:
146 _st_.current_tex_line = 11
147 _st_.inline(6, latex(s[2]))
148except:
149 _st_.goboom(11)
150try:
151 _st_.current_tex_line = 5
152 _st_.inline(7, latex((x^3+2*x+1).roots(x, ring=RR)))
153except:
154 _st_.goboom(5)
155_st_.current_tex_line = 9
156_st_.blockbegin()
157try:
158     s = (x^3+2*x+1).roots(x, ring=CC)
159except:
160 _st_.goboom(11)
161_st_.blockend()
162try:
163 _st_.current_tex_line = 13
164 _st_.inline(8, latex(s[0]))
165except:
166 _st_.goboom(13)
167try:
168 _st_.current_tex_line = 13
169 _st_.inline(9, latex(s[1]))
170except:
171 _st_.goboom(13)
172try:
173 _st_.current_tex_line = 13
174 _st_.inline(10, latex(s[2]))
175except:
176 _st_.goboom(13)
177try:
178 _st_.current_tex_line = 2
179 _st_.commandline(5, r"""
180    sage: diff(sin(x^2), x, 4)
181""", globals(), locals(), True)
182except:
183 _st_.goboom(4)
184try:
185 _st_.current_tex_line = 5
186 _st_.commandline(6, r"""
187    sage: x, y = var('x,y')
188    sage: f = x^2 + 17*y^2
189    sage: f.diff(y)
190""", globals(), locals(), True)
191except:
192 _st_.goboom(9)
193try:
194 _st_.current_tex_line = 2
195 _st_.commandline(7, r"""
196    sage: integral(x*sin(x^2), x)
197    sage: integral(x/(x^2+1), x, 0, 1)
198""", globals(), locals(), True)
199except:
200 _st_.goboom(5)
201try:
202 _st_.current_tex_line = 8
203 _st_.commandline(8, r"""
204  sage: f = 1/((1+x)*(x-1))
205  sage: f.partial_fraction(x)
206""", globals(), locals(), True)
207except:
208 _st_.goboom(11)
209try:
210 _st_.current_tex_line = 2
211 _st_.commandline(9, r"""
212  sage: simplify(arccos(sin(pi/3)))
213  sage: simplify(exp(i*pi/6))
214""", globals(), locals(), True)
215except:
216 _st_.goboom(5)
217try:
218 _st_.current_tex_line = 6
219 _st_.commandline(10, r"""
220  sage: a = var('a')
221  sage: y = cos(x+a) * (x+1)
222  sage: y.subs(a=-x)
223  sage: y.subs(x=pi/2, a=pi/3)
224""", globals(), locals(), True)
225except:
226 _st_.goboom(11)
227try:
228 _st_.current_tex_line = 2
229 _st_.commandline(11, r"""
230  sage: y, z = var('y, z')
231  sage: f = x^3 + y^2 + z
232  sage: f.subs_expr(x^3 == y^2, z==1)
233""", globals(), locals(), True)
234except:
235 _st_.goboom(6)
236try:
237 _st_.current_tex_line = 7
238 _st_.commandline(12, r"""
239  sage: f(x)=(2*x+1)^3
240  sage: f(-3)
241  sage: f.expand()
242""", globals(), locals(), True)
243except:
244 _st_.goboom(11)
245try:
246 _st_.current_tex_line = 12
247 _st_.commandline(13, r"""
248  sage: ((x+y+sin(x))^2).expand().collect(sin(x))
249""", globals(), locals(), True)
250except:
251 _st_.goboom(14)
252try:
253 _st_.current_tex_line = 2
254 _st_.commandline(14, r"""
255  sage: u = sin(x) + x*cos(y)
256  sage: v = u.function(x, y)
257  sage: v
258""", globals(), locals(), True)
259except:
260 _st_.goboom(6)
261try:
262 _st_.current_tex_line = 7
263 _st_.commandline(15, r"""
264  sage: f = (e^x-1) / (1+e^(x/2))
265  sage: f.simplify_exp()
266""", globals(), locals(), True)
267except:
268 _st_.goboom(10)
269try:
270 _st_.current_tex_line = 11
271 _st_.commandline(16, r"""
272  sage: f = cos(x)^6 + sin(x)^6 + 3 * sin(x)^2 * cos(x)^2
273  sage: f.simplify_trig()
274""", globals(), locals(), True)
275except:
276 _st_.goboom(14)
277try:
278 _st_.current_tex_line = 2
279 _st_.commandline(17, r"""
280  sage: f = cos(x)^6
281  sage: f.reduce_trig()
282  sage: f = sin(5 * x)
283  sage: f.expand_trig()
284  sage: n = var('n')
285  sage: f = factorial(n+1)/factorial(n)
286  sage: f.simplify_factorial()
287  sage: f = sqrt(abs(x)^2)
289""", globals(), locals(), True)
290except:
291 _st_.goboom(12)
292try:
293 _st_.current_tex_line = 2
294 _st_.commandline(18, r"""
295  sage: assume(x > 0)
296  sage: bool(sqrt(x^2) == x)
297  sage: forget(x > 0)
298  sage: bool(sqrt(x^2) == x)
299  sage: n = var('n')
300  sage: assume(n, 'integer')
301  sage: sin(n*pi).simplify()
302""", globals(), locals(), True)
303except:
304 _st_.goboom(10)
305try:
306 _st_.current_tex_line = 3
307 _st_.commandline(19, r"""
308  sage: t = var('t')
309  sage: x = function('x',t)
310  sage: DE = diff(x, t) + x - 1
311  sage: desolve(DE, [x,t])
312""", globals(), locals(), True)
313except:
314 _st_.goboom(8)
315try:
316 _st_.current_tex_line = 9
317 _st_.commandline(20, r"""
318  sage: x = var('x')
319  sage: y = function('y', x)
320  sage: desolve(diff(y,x,x) + x*diff(y,x) + y == 0, y, [0,0,1])
321""", globals(), locals(), True)
322except:
323 _st_.goboom(13)
324try:
325 _st_.current_tex_line = 2
326 _st_.commandline(21, r"""
327  sage: k, n = var('k, n')
328  sage: sum(k, k, 1, n).factor()
329  sage: sum(k * binomial(n, k), k, 0, n)
330  sage: n, k, y = var('n, k, y')
331  sage: sum(binomial(n,k) * x^k * y^(n-k), k, 0, n)
332  sage: a, q, k, n = var('a, q, k, n')
333  sage: sum(a*q^k, k, 0, n)
334""", globals(), locals(), True)
335except:
336 _st_.goboom(10)
337try:
338 _st_.current_tex_line = 2
339 _st_.commandline(22, r"""
340  sage: a, q, k, n = var('a, q, k, n')
341  sage: sum(a*q^k, k, 0, n)
342  sage: assume(abs(q) < 1)
343  sage: sum(a*q^k, k, 0, infinity)
344""", globals(), locals(), True)
345except:
346 _st_.goboom(7)
347try:
348 _st_.current_tex_line = 2
349 _st_.commandline(23, r"""
350  sage: limit((x**(1/3) - 2) / ((x + 19)**(1/3) - 3), x = 8)
351  sage: f(x) = (cos(pi/4-x)-tan(x))/(1-sin(pi/4 + x))
352  sage: limit(f(x), x = pi/4)
353  sage: limit(f(x), x = pi/4, dir='minus')
354  sage: limit(f(x), x = pi/4, dir='plus')
355  sage: u(n) = n^100 / 100^n
356  sage: limit(u(n), n=infinity)
357""", globals(), locals(), True)
358except:
359 _st_.goboom(10)
360try:
361 _st_.current_tex_line = 2
362 _st_.commandline(24, r"""
363  sage: taylor((1+arctan(x))**(1/x), x, 0, 3)
364  sage: (ln(2*sin(x))).series(x==pi/6, 3)
365  sage: (ln(2*sin(x))).series(x==pi/6, 3).truncate()
366  sage: f = arctan(x).series(x, 10)
367  sage: f
368  sage: (16*f.subs(x==1/5) - 4*f.subs(x==1/239)).n()
369""", globals(), locals(), True)
370except:
371 _st_.goboom(9)
372try:
373 _st_.current_tex_line = 7
374 _st_.inline(11, latex(matrix([[1, 2], [3,4]])^2))
375except:
376 _st_.goboom(7)
377try:
378 _st_.current_tex_line = 7
379 _st_.plot(0, format='png', _p_=plot(sin(x), 0, pi), axes=False)
380except:
381 _st_.goboom(7)
382_st_.current_tex_line = 12
383_st_.blockbegin()
384try:
385         var('x')
386         f(x) = sin(x) - 1
387         g(x) = log(x)
388         h(x) = diff(f(x) * g(x), x)
389except:
390 _st_.goboom(17)
391_st_.blockend()
392try:
393 _st_.current_tex_line = 9
394 _st_.inline(12, latex(h(2)))
395except:
396 _st_.goboom(9)
397try:
398 _st_.current_tex_line = 11
399 _st_.commandline(25, r"""
400       sage: 1+1
401       sage: factor(x^2 + 2*x + 1)
402""", globals(), locals(), True)
403except:
404 _st_.goboom(14)
405_st_.endofdoc()
406