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