Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download

Examples of using latex in cocalc

Views: 1132
1
r"""
2
This file was *autogenerated* from sagetex.tex with sagetex.sty
3
version 2015/08/26 v3.0-92d9f7a. It contains the contents of all the
4
sageexample environments from sagetex.tex. You should be able to
5
doctest this file with "sage -t sagetex_doctest.sage".
6
7
It is always safe to delete this file; it is not used in typesetting your
8
document.
9
10
Sage example, line 426::
11
12
sage: 2+2
13
4
14
sage: print 'middle'
15
middle
16
sage: factor(x^2 + 2*x + 1)
17
(x + 1)^2
18
19
Sage example, line 448::
20
21
sage: print 'middle'
22
middle
23
24
Sage example, line 455::
25
26
sage: is_prime(57)
27
toothpaste
28
29
Sage example, line 463::
30
31
sage: gcd([5656565656,
32
....: 4747474747,
33
....: 123456789])
34
1
35
sage: mystr = '''my
36
....: string
37
....: has
38
....: several
39
....: lines.'''
40
sage: len(mystr)
41
28
42
sage: def f(a):
43
....: '''This function is really quite nice,
44
....: although perhaps not very useful.'''
45
....: print "f called with a = ", a
46
....: y = integrate(SR(cyclotomic_polynomial(10)) + a, x)
47
....: return y + 1
48
sage: f(x)
49
f called with a = x
50
1/5*x^5 - 1/4*x^4 + 1/3*x^3 + x + 1
51
52
Sage example, line 512::
53
54
sage: 1; 2; a=4; 3; a
55
1
56
2
57
3
58
4
59
60
Sage example, line 521::
61
62
sage: f(a)
63
f called with a = 4
64
1/5*x^5 - 1/4*x^4 + 1/3*x^3 - 1/2*x^2 + 5*x + 1
65
66
Sage commandline, line 622::
67
68
sage: 1+1
69
sage: is_prime(57)
70
sage: if is_prime(57):
71
....: print 'prime'
72
....: else:
73
....: print 'composite'
74
75
Sage commandline, line 639::
76
77
sage: x = 2010; len(x.divisors())
78
sage: print 'Hola, mundo!'
79
80
Sage commandline, line 651::
81
82
sage: l = matrix([[1,0,0],[3/5,1,0],[-2/5,-2,1]])
83
sage: d = diagonal_matrix([15, -1, 4]) #@\label{diagonal}
84
sage: u = matrix([[1,0,1/3],[0,1,2],[0,0,1]]) #@\label{anotherlabel} \# foo
85
sage: l*d*u # this is a comment
86
87
Sage commandline, line 667::
88
89
sage: l*d*u
90
sage: x = var('x')
91
sage: (1-cos(x)^2).trig_simplify()
92
93
Sage commandline, line 683::
94
95
sage: pi.n(100)
96
97
Sage commandline, line 693::
98
99
sage: plot(sin(x), (x, 0, 2*pi))
100
101
Sage commandline, line 709::
102
103
sage: factor(x^2 + 2*x + 1)
104
(x + 999)^2
105
106
"""
107
108