Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download
Views: 1932
1
r"""
2
This file was *autogenerated* from P3b.tex with sagetex.sty
3
version 2015/08/26 v3.0-92d9f7a. It contains the contents of all the
4
sageexample environments from P3b.tex. You should be able to
5
doctest this file with "sage -t P3b_doctest.sage".
6
7
It is always safe to delete this file; it is not used in typesetting your
8
document.
9
10
Sage commandline, line 2::
11
12
sage: a = 5
13
sage: type(a)
14
15
Sage commandline, line 6::
16
17
sage: a = 5/3
18
sage: type(a)
19
20
Sage commandline, line 10::
21
22
sage: a = 'hello'
23
sage: type(a)
24
25
Sage commandline, line 3::
26
27
sage: phi = var('phi')
28
sage: find_root(cos(phi)==sin(phi),0,pi/2)
29
30
Sage commandline, line 8::
31
32
sage: solve(x^2+x-1 > 0, x)
33
34
Sage commandline, line 2::
35
36
sage: diff(sin(x^2), x, 4)
37
38
Sage commandline, line 5::
39
40
sage: x, y = var('x,y')
41
sage: f = x^2 + 17*y^2
42
sage: f.diff(y)
43
44
Sage commandline, line 2::
45
46
sage: integral(x*sin(x^2), x)
47
sage: integral(x/(x^2+1), x, 0, 1)
48
49
Sage commandline, line 8::
50
51
sage: f = 1/((1+x)*(x-1))
52
sage: f.partial_fraction(x)
53
54
Sage commandline, line 2::
55
56
sage: simplify(arccos(sin(pi/3)))
57
sage: simplify(exp(i*pi/6))
58
59
Sage commandline, line 6::
60
61
sage: a = var('a')
62
sage: y = cos(x+a) * (x+1)
63
sage: y.subs(a=-x)
64
sage: y.subs(x=pi/2, a=pi/3)
65
66
Sage commandline, line 2::
67
68
sage: y, z = var('y, z')
69
sage: f = x^3 + y^2 + z
70
sage: f.subs_expr(x^3 == y^2, z==1)
71
72
Sage commandline, line 7::
73
74
sage: f(x)=(2*x+1)^3
75
sage: f(-3)
76
sage: f.expand()
77
78
Sage commandline, line 12::
79
80
sage: ((x+y+sin(x))^2).expand().collect(sin(x))
81
82
Sage commandline, line 2::
83
84
sage: u = sin(x) + x*cos(y)
85
sage: v = u.function(x, y)
86
sage: v
87
88
Sage commandline, line 7::
89
90
sage: f = (e^x-1) / (1+e^(x/2))
91
sage: f.simplify_exp()
92
93
Sage commandline, line 11::
94
95
sage: f = cos(x)^6 + sin(x)^6 + 3 * sin(x)^2 * cos(x)^2
96
sage: f.simplify_trig()
97
98
Sage commandline, line 2::
99
100
sage: f = cos(x)^6
101
sage: f.reduce_trig()
102
sage: f = sin(5 * x)
103
sage: f.expand_trig()
104
sage: n = var('n')
105
sage: f = factorial(n+1)/factorial(n)
106
sage: f.simplify_factorial()
107
sage: f = sqrt(abs(x)^2)
108
sage: f.simplify_radical()
109
110
Sage commandline, line 2::
111
112
sage: assume(x > 0)
113
sage: bool(sqrt(x^2) == x)
114
sage: forget(x > 0)
115
sage: bool(sqrt(x^2) == x)
116
sage: n = var('n')
117
sage: assume(n, 'integer')
118
sage: sin(n*pi).simplify()
119
120
Sage commandline, line 3::
121
122
sage: t = var('t')
123
sage: x = function('x',t)
124
sage: DE = diff(x, t) + x - 1
125
sage: desolve(DE, [x,t])
126
127
Sage commandline, line 9::
128
129
sage: x = var('x')
130
sage: y = function('y', x)
131
sage: desolve(diff(y,x,x) + x*diff(y,x) + y == 0, y, [0,0,1])
132
133
Sage commandline, line 2::
134
135
sage: k, n = var('k, n')
136
sage: sum(k, k, 1, n).factor()
137
sage: sum(k * binomial(n, k), k, 0, n)
138
sage: n, k, y = var('n, k, y')
139
sage: sum(binomial(n,k) * x^k * y^(n-k), k, 0, n)
140
sage: a, q, k, n = var('a, q, k, n')
141
sage: sum(a*q^k, k, 0, n)
142
143
Sage commandline, line 2::
144
145
sage: a, q, k, n = var('a, q, k, n')
146
sage: sum(a*q^k, k, 0, n)
147
sage: assume(abs(q) < 1)
148
sage: sum(a*q^k, k, 0, infinity)
149
150
Sage commandline, line 2::
151
152
sage: limit((x**(1/3) - 2) / ((x + 19)**(1/3) - 3), x = 8)
153
sage: f(x) = (cos(pi/4-x)-tan(x))/(1-sin(pi/4 + x))
154
sage: limit(f(x), x = pi/4)
155
sage: limit(f(x), x = pi/4, dir='minus')
156
sage: limit(f(x), x = pi/4, dir='plus')
157
sage: u(n) = n^100 / 100^n
158
sage: limit(u(n), n=infinity)
159
160
Sage commandline, line 2::
161
162
sage: taylor((1+arctan(x))**(1/x), x, 0, 3)
163
sage: (ln(2*sin(x))).series(x==pi/6, 3)
164
sage: (ln(2*sin(x))).series(x==pi/6, 3).truncate()
165
sage: f = arctan(x).series(x, 10)
166
sage: f
167
sage: (16*f.subs(x==1/5) - 4*f.subs(x==1/239)).n()
168
169
Sage commandline, line 11::
170
171
sage: 1+1
172
sage: factor(x^2 + 2*x + 1)
173
174
"""
175
176