CoCalc Shared Files10. Sagetex / P3b.sagetex.sageOpen in CoCalc with one click!
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.
3
import 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()
7
try:
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)
17
except:
18
_st_.goboom(14)
19
_st_.blockend()
20
try:
21
_st_.current_tex_line = 2
22
_st_.commandline(0, r"""
23
sage: a = 5
24
sage: type(a)
25
""", globals(), locals(), True)
26
except:
27
_st_.goboom(5)
28
try:
29
_st_.current_tex_line = 6
30
_st_.commandline(1, r"""
31
sage: a = 5/3
32
sage: type(a)
33
""", globals(), locals(), True)
34
except:
35
_st_.goboom(9)
36
try:
37
_st_.current_tex_line = 10
38
_st_.commandline(2, r"""
39
sage: a = 'hello'
40
sage: type(a)
41
""", globals(), locals(), True)
42
except:
43
_st_.goboom(13)
44
_st_.current_tex_line = 3
45
_st_.blockbegin()
46
try:
47
x = var('x')
48
solve(x^2 + 3*x + 2, x)
49
except:
50
_st_.goboom(6)
51
_st_.blockend()
52
try:
53
_st_.current_tex_line = 7
54
_st_.inline(0, latex(solve(x^2 + 3*x + 2, x)))
55
except:
56
_st_.goboom(7)
57
_st_.current_tex_line = 10
58
_st_.blockbegin()
59
try:
60
x, b, c = var('x b c')
61
solve([x^2 + b*x + c == 0],x)
62
except:
63
_st_.goboom(13)
64
_st_.blockend()
65
try:
66
_st_.current_tex_line = 14
67
_st_.inline(1, latex(solve([x^2 + b*x + c == 0],x)))
68
except:
69
_st_.goboom(14)
70
_st_.current_tex_line = 3
71
_st_.blockbegin()
72
try:
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)
78
except:
79
_st_.goboom(9)
80
_st_.blockend()
81
_st_.current_tex_line = 10
82
_st_.blockbegin()
83
try:
84
s = solve([eq1,eq2,eq3,p==1],p,q,x,y)
85
except:
86
_st_.goboom(12)
87
_st_.blockend()
88
try:
89
_st_.current_tex_line = 13
90
_st_.inline(2, latex(s[0]))
91
except:
92
_st_.goboom(13)
93
try:
94
_st_.current_tex_line = 13
95
_st_.inline(3, latex(s[1]))
96
except:
97
_st_.goboom(13)
98
try:
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)
104
except:
105
_st_.goboom(6)
106
try:
107
_st_.current_tex_line = 8
108
_st_.commandline(4, r"""
109
sage: solve(x^2+x-1 > 0, x)
110
""", globals(), locals(), True)
111
except:
112
_st_.goboom(10)
113
_st_.current_tex_line = 5
114
_st_.blockbegin()
115
try:
116
s = (x^3+2*x+1).roots(x)
117
except:
118
_st_.goboom(7)
119
_st_.blockend()
120
try:
121
_st_.current_tex_line = 11
122
_st_.inline(4, latex(s[0]))
123
except:
124
_st_.goboom(11)
125
try:
126
_st_.current_tex_line = 11
127
_st_.inline(5, latex(s[1]))
128
except:
129
_st_.goboom(11)
130
try:
131
_st_.current_tex_line = 11
132
_st_.inline(6, latex(s[2]))
133
except:
134
_st_.goboom(11)
135
try:
136
_st_.current_tex_line = 11
137
_st_.inline(4, latex(s[0]))
138
except:
139
_st_.goboom(11)
140
try:
141
_st_.current_tex_line = 11
142
_st_.inline(5, latex(s[1]))
143
except:
144
_st_.goboom(11)
145
try:
146
_st_.current_tex_line = 11
147
_st_.inline(6, latex(s[2]))
148
except:
149
_st_.goboom(11)
150
try:
151
_st_.current_tex_line = 5
152
_st_.inline(7, latex((x^3+2*x+1).roots(x, ring=RR)))
153
except:
154
_st_.goboom(5)
155
_st_.current_tex_line = 9
156
_st_.blockbegin()
157
try:
158
s = (x^3+2*x+1).roots(x, ring=CC)
159
except:
160
_st_.goboom(11)
161
_st_.blockend()
162
try:
163
_st_.current_tex_line = 13
164
_st_.inline(8, latex(s[0]))
165
except:
166
_st_.goboom(13)
167
try:
168
_st_.current_tex_line = 13
169
_st_.inline(9, latex(s[1]))
170
except:
171
_st_.goboom(13)
172
try:
173
_st_.current_tex_line = 13
174
_st_.inline(10, latex(s[2]))
175
except:
176
_st_.goboom(13)
177
try:
178
_st_.current_tex_line = 2
179
_st_.commandline(5, r"""
180
sage: diff(sin(x^2), x, 4)
181
""", globals(), locals(), True)
182
except:
183
_st_.goboom(4)
184
try:
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)
191
except:
192
_st_.goboom(9)
193
try:
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)
199
except:
200
_st_.goboom(5)
201
try:
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)
207
except:
208
_st_.goboom(11)
209
try:
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)
215
except:
216
_st_.goboom(5)
217
try:
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)
225
except:
226
_st_.goboom(11)
227
try:
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)
234
except:
235
_st_.goboom(6)
236
try:
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)
243
except:
244
_st_.goboom(11)
245
try:
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)
250
except:
251
_st_.goboom(14)
252
try:
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)
259
except:
260
_st_.goboom(6)
261
try:
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)
267
except:
268
_st_.goboom(10)
269
try:
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)
275
except:
276
_st_.goboom(14)
277
try:
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)
288
sage: f.simplify_radical()
289
""", globals(), locals(), True)
290
except:
291
_st_.goboom(12)
292
try:
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)
303
except:
304
_st_.goboom(10)
305
try:
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)
313
except:
314
_st_.goboom(8)
315
try:
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)
322
except:
323
_st_.goboom(13)
324
try:
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)
335
except:
336
_st_.goboom(10)
337
try:
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)
345
except:
346
_st_.goboom(7)
347
try:
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)
358
except:
359
_st_.goboom(10)
360
try:
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)
370
except:
371
_st_.goboom(9)
372
try:
373
_st_.current_tex_line = 7
374
_st_.inline(11, latex(matrix([[1, 2], [3,4]])^2))
375
except:
376
_st_.goboom(7)
377
try:
378
_st_.current_tex_line = 7
379
_st_.plot(0, format='png', _p_=plot(sin(x), 0, pi), axes=False)
380
except:
381
_st_.goboom(7)
382
_st_.current_tex_line = 12
383
_st_.blockbegin()
384
try:
385
var('x')
386
f(x) = sin(x) - 1
387
g(x) = log(x)
388
h(x) = diff(f(x) * g(x), x)
389
except:
390
_st_.goboom(17)
391
_st_.blockend()
392
try:
393
_st_.current_tex_line = 9
394
_st_.inline(12, latex(h(2)))
395
except:
396
_st_.goboom(9)
397
try:
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)
403
except:
404
_st_.goboom(14)
405
_st_.endofdoc()
406