2^{38} \cdot 3^{18} \cdot 5^{9} \cdot 7^{5} \cdot 11^{3} \cdot 13^{3} \cdot 17^{2} \cdot 19^{2} \cdot 23 \cdot 29 \cdot 31 \cdot 37
rF U¦# Worksheet 'talk' (2007-01-16 at 03:53)
sage: %sagex
sage: def is2pow(unsigned int n):
... while n != 0 and n%2 == 0:
... n = n >> 1
... return n == 1
rG U‚# Worksheet 'talk' (2007-01-16 at 03:53)
sage: time v = [n for n in range(10^5) if is2pow(n)]
CPU time: 0.04 s, Wall time: 0.07 srH UŒ# Worksheet 'talk' (2007-01-16 at 03:54)
sage: def is2pow(n):
... while n != 0 and n%2 == 0:
... n = n >> 1
... return n == 1
rI U¯# Worksheet 'talk' (2007-01-16 at 03:54)
sage: %sagex
sage: def is2pow_compiled(unsigned int n):
... while n != 0 and n%2 == 0:
... n = n >> 1
... return n == 1
rJ U‚# Worksheet 'talk' (2007-01-16 at 03:54)
sage: time v = [n for n in range(10^5) if is2pow(n)]
CPU time: 3.39 s, Wall time: 4.54 srK U‹# Worksheet 'talk' (2007-01-16 at 03:54)
sage: time v = [n for n in range(10^5) if is2pow_compiled(n)]
CPU time: 0.04 s, Wall time: 0.04 srL U…# Worksheet 'talk' (2007-01-16 at 03:55)
sage: v
[1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536]rM Uã# Worksheet 'talk' (2007-01-16 at 03:55)
sage: time v = [n for n in range(10^5) if is2pow_compiled(n)]; v
[1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536]
CPU time: 0.04 s, Wall time: 0.05 srN UÚ# Worksheet 'talk' (2007-01-16 at 03:55)
sage: time v = [n for n in range(10^5) if is2pow(n)]; v
[1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536]
CPU time: 3.29 s, Wall time: 3.39 srO UA# Worksheet 'talk' (2007-01-16 at 03:56)
sage: a = gp('2+3'); a
5rP UA# Worksheet 'talk' (2007-01-16 at 03:56)
sage: a = gp('2+3'); a
5rQ U6# Worksheet 'talk' (2007-01-16 at 03:57)
sage: a^3
125rR U]# Worksheet 'talk' (2007-01-16 at 03:57)
sage: type(a)
rS U6# Worksheet 'talk' (2007-01-16 at 04:03)
sage: 2 + 2
4rT U[# Worksheet 'talk' (2007-01-16 at 04:03)
sage: prime_range(20)
[2, 3, 5, 7, 11, 13, 17, 19]rU U6# Worksheet 'talk' (2007-01-16 at 04:03)
sage: 2 ^ 3
8rV UD# Worksheet 'talk' (2007-01-16 at 04:03)
sage: %python
sage: 2 ^ 3
1rW UP# Worksheet 'talk' (2007-01-16 at 04:03)
sage: factorial(20)
2432902008176640000rX Uõ# Worksheet 'talk' (2007-01-16 at 04:03)
sage: show(factor( factorial(40) ))
2^{38} \cdot 3^{18} \cdot 5^{9} \cdot 7^{5} \cdot 11^{3} \cdot 13^{3} \cdot 17^{2} \cdot 19^{2} \cdot 23 \cdot 29 \cdot 31 \cdot 37
rY U¡# Worksheet 'talk' (2007-01-16 at 04:03)
sage: m = matrix(5,5, range(25)); m
[ 0 1 2 3 4]
[ 5 6 7 8 9]
[10 11 12 13 14]
[15 16 17 18 19]
[20 21 22 23 24]rZ Uˆ# Worksheet 'talk' (2007-01-16 at 04:03)
sage: f = m.charpoly(); show(f)
x^{5} - 60x^{4} - 250x^{3}
r[ Uƒ# Worksheet 'talk' (2007-01-16 at 04:03)
sage: show(factor(f))
(x^{2} - 60x - 250) \cdot x^{3}
r\ Uî# Worksheet 'talk' (2007-01-16 at 04:03)
sage: m = matrix(5,5, range(25)); show(m)
\left(\begin{array}{rrrrr}
0&1&2&3&4\\
5&6&7&8&9\\
10&11&12&13&14\\
15&16&17&18&19\\
20&21&22&23&24
\end{array}\right)
r] U‹# Worksheet 'talk' (2007-01-16 at 04:03)
sage: f = m.charpoly('T'); show(f)
T^{5} - 60T^{4} - 250T^{3}
r^ Uƒ# Worksheet 'talk' (2007-01-16 at 04:03)
sage: show(factor(f))
(T^{2} - 60T - 250) \cdot T^{3}
r_ UÈ# Worksheet 'talk' (2007-01-16 at 04:04)
sage: m = matrix(5,5,[randint(10) for _ in range(25)]); show(m)
Traceback (most recent call last):
...
TypeError: randint() takes exactly 3 arguments (2 given)r` T # Worksheet 'talk' (2007-01-16 at 04:04)
sage: m = matrix(5,5,[randint(-10,10) for _ in range(25)]); show(m)
\left(\begin{array}{rrrrr}
0&-7&-8&-6&7\\
-8&-8&0&-2&1\\
-2&-4&7&0&-6\\
5&8&-4&0&5\\
3&-3&2&0&7
\end{array}\right)
ra U£# Worksheet 'talk' (2007-01-16 at 04:04)
sage: f = m.charpoly('T'); show(f)
T^{5} - 6T^{4} - 95T^{3} + 497T^{2} + 589T - 12256
rb U˜# Worksheet 'talk' (2007-01-16 at 04:04)
sage: show(factor(f))
(T^{5} - 6T^{4} - 95T^{3} + 497T^{2} + 589T - 12256)
rc Uö# Worksheet 'talk' (2007-01-16 at 04:04)
sage: m = matrix(5,5,[randint(0,1) for _ in range(25)]); show(m)
\left(\begin{array}{rrrrr}
0&1&1&1&1\\
1&1&0&0&1\\
0&0&0&0&1\\
0&0&0&0&0\\
0&0&1&1&0
\end{array}\right)
rd U“# Worksheet 'talk' (2007-01-16 at 04:04)
sage: f = m.charpoly('T'); show(f)
T^{5} - T^{4} - 2T^{3} + T^{2} + T
re U—# Worksheet 'talk' (2007-01-16 at 04:04)
sage: show(factor(f))
(T - 1) \cdot T \cdot (T + 1) \cdot (T^{2} - T - 1)
rf Uö# Worksheet 'talk' (2007-01-16 at 04:04)
sage: m = matrix(5,5,[randint(0,1) for _ in range(25)]); show(m)
\left(\begin{array}{rrrrr}
1&0&0&1&0\\
0&1&0&0&1\\
1&0&0&0&1\\
1&1&1&0&0\\
0&1&1&1&0
\end{array}\right)
rg U™# Worksheet 'talk' (2007-01-16 at 04:04)
sage: f = m.charpoly('T'); show(f)
T^{5} - 2T^{4} - 2T^{3} + T^{2} + 5T - 2
rh UŽ# Worksheet 'talk' (2007-01-16 at 04:04)
sage: show(factor(f))
(T^{5} - 2T^{4} - 2T^{3} + T^{2} + 5T - 2)
ri Uö# Worksheet 'talk' (2007-01-16 at 04:04)
sage: m = matrix(5,5,[randint(0,1) for _ in range(25)]); show(m)
\left(\begin{array}{rrrrr}
0&0&1&0&0\\
1&0&0&1&1\\
0&1&1&1&1\\
0&0&0&1&1\\
0&1&1&0&0
\end{array}\right)
rj U# Worksheet 'talk' (2007-01-16 at 04:04)
sage: f = m.charpoly('T'); show(f)
T^{5} - 2T^{4} - T^{3} - T^{2}
rk Uˆ# Worksheet 'talk' (2007-01-16 at 04:04)
sage: show(factor(f))
T^{2} \cdot (T^{3} - 2T^{2} - T - 1)
rl U‡# Worksheet 'interface' (2007-01-16 at 04:06)
sage: parent(a)
Traceback (most recent call last):
...
NameError: name 'a' is not definedrm Uƒ# Worksheet 'interface' (2007-01-16 at 04:06)
sage: 5 + a
Traceback (most recent call last):
...
NameError: name 'a' is not definedrn UF# Worksheet 'interface' (2007-01-16 at 04:06)
sage: a = gp('2+3'); a
5ro U;# Worksheet 'interface' (2007-01-16 at 04:06)
sage: a^3
125rp Ub# Worksheet 'interface' (2007-01-16 at 04:06)
sage: type(a)
rq UQ# Worksheet 'interface' (2007-01-16 at 04:06)
sage: parent(a)
GP/PARI interpreterrr U<# Worksheet 'interface' (2007-01-16 at 04:06)
sage: 5 + a
10rs US# Worksheet 'interface' (2007-01-16 at 04:06)
sage: parent(5+a)
GP/PARI interpreterrt UF# Worksheet 'interface' (2007-01-16 at 04:06)
sage: pari(5) + gp(5)
10ru Uk# Worksheet 'interface' (2007-01-16 at 04:06)
sage: parent(pari(5) + gp(5))
Interface to the PARI C libraryrv US# Worksheet 'interface' (2007-01-16 at 04:06)
sage: parent(5+a)
GP/PARI interpreterrw UE# Worksheet 'interface' (2007-01-16 at 04:06)
sage: gap(5) + gp(5)
10rx UN# Worksheet 'interface' (2007-01-16 at 04:06)
sage: parent(gap(5) + gp(5))
Gapry U^# Worksheet 'interface' (2007-01-16 at 04:06)
sage: parent(gp(5) + gap(5))
GP/PARI interpreterrz UN# Worksheet 'interface' (2007-01-16 at 04:06)
sage: parent(gap(5) + gp(5))
Gapr{ UT# Worksheet 'interface' (2007-01-16 at 04:07)
sage: a = gp('x^3 - y^3'); a
x^3 - y^3r| UY# Worksheet 'interface' (2007-01-16 at 04:07)
sage: a^3
x^9 - 3*y^3*x^6 + 3*y^6*x^3 - y^9r} Ub# Worksheet 'interface' (2007-01-16 at 04:07)
sage: type(a)
r~ UQ# Worksheet 'interface' (2007-01-16 at 04:07)
sage: parent(a)
GP/PARI interpreterr T # Worksheet 'interface' (2007-01-16 at 04:07)
sage: a.factor()
Traceback (most recent call last):
...
TypeError: Error executing code in GP/PARI:
CODE:
sage[22]=factor(sage[20]);
GP/PARI ERROR:
*** factor: sorry, factor for general polynomials is not yet implemented.r€ U‹# Worksheet 'interface' (2007-01-16 at 04:07)
sage: sage_eval(a)
Traceback (most recent call last):
...
TypeError: source must be a string.r U–# Worksheet 'interface' (2007-01-16 at 04:07)
sage: b = sage_eval(str(a)); b
Traceback (most recent call last):
...
NameError: name 'y' is not definedr‚ U°# Worksheet 'interface' (2007-01-16 at 04:07)
sage: R. = QQ[x,y]
sage: b = R(a)
Traceback (most recent call last):
...
TypeError: unable to convert x^3 - y^3 to a rationalrƒ UZ# Worksheet 'interface' (2007-01-16 at 04:07)
sage: R. = QQ[x,y]
sage: b = R(str(a))
r„ U]# Worksheet 'interface' (2007-01-16 at 04:07)
sage: b.factor()
(-1*y + x) * (y^2 + x*y + x^2)r… UH# Worksheet 'sieve' (2007-01-16 at 04:09)
sage: show(sieve_step(1,100))
r† UH# Worksheet 'sieve' (2007-01-16 at 04:09)
sage: show(sieve_step(2,100))
r‡ UH# Worksheet 'sieve' (2007-01-16 at 04:09)
sage: show(sieve_step(3,100))
rˆ UH# Worksheet 'sieve' (2007-01-16 at 04:09)
sage: show(sieve_step(5,100))
r‰ UH# Worksheet 'sieve' (2007-01-16 at 04:09)
sage: show(sieve_step(7,100))
rŠ UI# Worksheet 'sieve' (2007-01-16 at 04:09)
sage: show(sieve_step(11,100))
r‹ U•# Worksheet 'sieve' (2007-01-16 at 04:09)
sage: s = [sieve_step(p,100) for p in [2,3,5,7]]
sage: G = graphics_array(s, 2,2)
sage: G.show(axes=False)
rŒ T‰ # Worksheet 'sieve' (2007-01-16 at 04:10)
sage: %hideall
sage: #auto
sage:
sage: def number_grid(c, box_args={}, font_args={},offset=0):
... """
... INPUT:
... c -- list of length n^2, where n is an integer.
... The entries of c are RGB colors.
... box_args -- additional arguments passed to box.
... font_args -- all additional arguments are passed
... to the text function, e.g., fontsize.
... offset -- use to fine tune text placement in the squares
...
... OUTPUT:
... Graphics -- a plot of a grid that illustrates
... those n^2 numbers colored according to c.
... """
... try:
... n = square_root(ZZ(len(c)))
... except ArithmeticError:
... raise ArithmeticError, "c must have square length"
... G = Graphics()
... k = 0
... for j in reversed(range(n)):
... for i in range(n):
... col = c[int(k)]
... R = line([(i,j),(i+1,j),(i+1,j+1),(i,j+1),(i,j)], thickness=.2, **box_args)
... P = polygon([(i,j),(i+1,j),(i+1,j+1),(i,j+1),(i,j)], rgbcolor=col, **box_args)
... G += P + R
... if col != (1,1,1):
... G += text(str(k+1), (i+.5+offset,j+.5), **font_args)
... k += 1
... G.axes(False)
... G.range(0,n,0,n)
... return G
CPU time: 0.00 s, Wall time: 0.00 sr T‰ # Worksheet 'sieve' (2007-01-16 at 04:10)
sage: %hideall
sage: #auto
sage:
sage: def number_grid(c, box_args={}, font_args={},offset=0):
... """
... INPUT:
... c -- list of length n^2, where n is an integer.
... The entries of c are RGB colors.
... box_args -- additional arguments passed to box.
... font_args -- all additional arguments are passed
... to the text function, e.g., fontsize.
... offset -- use to fine tune text placement in the squares
...
... OUTPUT:
... Graphics -- a plot of a grid that illustrates
... those n^2 numbers colored according to c.
... """
... try:
... n = square_root(ZZ(len(c)))
... except ArithmeticError:
... raise ArithmeticError, "c must have square length"
... G = Graphics()
... k = 0
... for j in reversed(range(n)):
... for i in range(n):
... col = c[int(k)]
... R = line([(i,j),(i+1,j),(i+1,j+1),(i,j+1),(i,j)], thickness=.2, **box_args)
... P = polygon([(i,j),(i+1,j),(i+1,j+1),(i,j+1),(i,j)], rgbcolor=col, **box_args)
... G += P + R
... if col != (1,1,1):
... G += text(str(k+1), (i+.5+offset,j+.5), **font_args)
... k += 1
... G.axes(False)
... G.range(0,n,0,n)
... return G
CPU time: 0.00 s, Wall time: 0.00 srŽ Uš# Worksheet 'sieve' (2007-01-16 at 04:10)
sage: show(sieve_step(1,100))
Traceback (most recent call last):
...
NameError: name 'sieve_step' is not definedr Uš# Worksheet 'sieve' (2007-01-16 at 04:10)
sage: show(sieve_step(2,100))
Traceback (most recent call last):
...
NameError: name 'sieve_step' is not definedr T‰ # Worksheet 'sieve' (2007-01-16 at 04:11)
sage: %hideall
sage: #auto
sage:
sage: def number_grid(c, box_args={}, font_args={},offset=0):
... """
... INPUT:
... c -- list of length n^2, where n is an integer.
... The entries of c are RGB colors.
... box_args -- additional arguments passed to box.
... font_args -- all additional arguments are passed
... to the text function, e.g., fontsize.
... offset -- use to fine tune text placement in the squares
...
... OUTPUT:
... Graphics -- a plot of a grid that illustrates
... those n^2 numbers colored according to c.
... """
... try:
... n = square_root(ZZ(len(c)))
... except ArithmeticError:
... raise ArithmeticError, "c must have square length"
... G = Graphics()
... k = 0
... for j in reversed(range(n)):
... for i in range(n):
... col = c[int(k)]
... R = line([(i,j),(i+1,j),(i+1,j+1),(i,j+1),(i,j)], thickness=.2, **box_args)
... P = polygon([(i,j),(i+1,j),(i+1,j+1),(i,j+1),(i,j)], rgbcolor=col, **box_args)
... G += P + R
... if col != (1,1,1):
... G += text(str(k+1), (i+.5+offset,j+.5), **font_args)
... k += 1
... G.axes(False)
... G.range(0,n,0,n)
... return G
CPU time: 0.00 s, Wall time: 0.00 sr‘ T€ # Worksheet 'sieve' (2007-01-16 at 04:11)
sage: %hideall
sage: #auto
sage:
sage: def sieve_step(p, n, gone=(1,1,1), prime=(1,0,0), \
... multiple=(.6,.6,.6), remaining=(.9,.9,.9),
... fontsize=11,offset=0):
... """
... Return graphics that illustrates sieving out
... multiples of p. Numbers that are a nontrivial
... multiple of primes < p are shown in the gone color.
... Numbers that are a multiple of p are shown in
... a different color. The number p is shown in
... yet a third color.
...
... INPUT:
... p -- a prime (or 1, in which case all points are colored "remaining")
... n -- a SQUARE integer
... gone -- rgb color for integers that have been sieved out
... prime -- rgb color for p
... multiple -- rgb color for multiples of p
... remaining -- rgb color for integers that have not been sieved out yet
... and are not multiples of p.
... """
... if p == 1:
... c = [remaining]*n
... else:
... exclude = prod(prime_range(p)) # exclude multiples of primes < p
... c = []
... for k in range(1,n+1):
... if k <= p and is_prime(k):
... c.append(prime)
... elif k == 1 or (gcd(k,exclude) != 1 and not is_prime(k)):
... c.append(gone)
... elif k%p == 0:
... c.append(multiple)
... else:
... c.append(remaining)
... # end for
... # end if
... return number_grid(c,{},{'fontsize':fontsize},offset=offset)
CPU time: 0.00 s, Wall time: 0.00 sr’ UH# Worksheet 'sieve' (2007-01-16 at 04:11)
sage: show(sieve_step(1,100))
r“ UH# Worksheet 'sieve' (2007-01-16 at 04:11)
sage: show(sieve_step(2,100))
r” UH# Worksheet 'sieve' (2007-01-16 at 04:11)
sage: show(sieve_step(3,100))
r• UH# Worksheet 'sieve' (2007-01-16 at 04:11)
sage: show(sieve_step(5,100))
r– UH# Worksheet 'sieve' (2007-01-16 at 04:11)
sage: show(sieve_step(7,100))
r— UI# Worksheet 'sieve' (2007-01-16 at 04:11)
sage: show(sieve_step(11,100))
r˜ U•# Worksheet 'sieve' (2007-01-16 at 04:11)
sage: s = [sieve_step(p,100) for p in [2,3,5,7]]
sage: G = graphics_array(s, 2,2)
sage: G.show(axes=False)
r™ US# Worksheet 'sieve' (2007-01-16 at 04:11)
sage: show(sieve_step(2,400,fontsize=6))
rš UT# Worksheet 'sieve' (2007-01-16 at 04:11)
sage: show(sieve_step(13,400,fontsize=6))
r› U6# Worksheet 'talk' (2007-01-16 at 04:49)
sage: 2 + 2
4rœ U[# Worksheet 'talk' (2007-01-16 at 04:49)
sage: prime_range(20)
[2, 3, 5, 7, 11, 13, 17, 19]r U6# Worksheet 'talk' (2007-01-16 at 04:49)
sage: 2 ^ 3
8rž UD# Worksheet 'talk' (2007-01-16 at 04:49)
sage: %python
sage: 2 ^ 3
1rŸ UP# Worksheet 'talk' (2007-01-16 at 04:49)
sage: factorial(20)
2432902008176640000r Uõ# Worksheet 'talk' (2007-01-16 at 04:49)
sage: show(factor( factorial(40) ))
2^{38} \cdot 3^{18} \cdot 5^{9} \cdot 7^{5} \cdot 11^{3} \cdot 13^{3} \cdot 17^{2} \cdot 19^{2} \cdot 23 \cdot 29 \cdot 31 \cdot 37
r¡ Uö# Worksheet 'talk' (2007-01-16 at 04:49)
sage: m = matrix(5,5,[randint(0,1) for _ in range(25)]); show(m)
\left(\begin{array}{rrrrr}
1&0&1&0&0\\
1&0&1&0&1\\
0&0&0&1&0\\
1&0&1&0&0\\
1&0&1&1&1
\end{array}\right)
r¢ U‡# Worksheet 'talk' (2007-01-16 at 04:49)
sage: f = m.charpoly('T'); show(f)
T^{5} - 2T^{4} + T^{2}
r£ U# Worksheet 'talk' (2007-01-16 at 04:49)
sage: show(factor(f))
(T - 1) \cdot T^{2} \cdot (T^{2} - T - 1)
r¤ Ur# Worksheet 'features' (2007-01-16 at 04:49)
sage: show(plot(sin(x),-pi,6*pi,rgbcolor=(0.5,0,0.5)),figsize=[8,3])
r¥ T # Worksheet 'features' (2007-01-16 at 04:49)
sage: %hide
sage: t = Tachyon(xres=700, yres=500, camera_center=(2,7,4), look_at=(2,0,0), raydepth=4)
sage: t.light((10,3,2), 1, (1,1,1))
sage: t.light((10,-3,2), 1, (1,1,1))
sage: t.texture('black', color=(0,0,0))
sage: t.texture('red', color=(1,0,0))
sage: t.texture('grey', color=(.9,.9,.9))
sage: t.plane((0,0,0),(0,0,1),'grey')
sage: t.cylinder((0,0,0),(1,0,0),.01,'black')
sage: t.cylinder((0,0,0),(0,1,0),.01,'black')
sage: E = EllipticCurve('37a'); show(E)
sage: P = E([0,0])
sage: Q = P
sage: n = 60
sage: for i in range(n):
... Q = Q + P
... c = i/n + .1
... t.texture('r%s'%i,color=(float(i/n),0,0))
... t.sphere((Q[0], -Q[1], .01), .04, 'r%s'%i)
...
sage: show(t)
y^2 + y = x^3 - x
r¦ U# Worksheet 'riemann' (2007-01-16 at 04:51)
sage: #auto
sage: def f(x):
... return x / log(x)
...
sage: def p(x):
... return prime_pi(x)
r§ T # Worksheet 'riemann' (2007-01-16 at 04:51)
sage: xmax = 20
sage: G = plot(f, 2,xmax, linestyle='--', label='x/log(x)') + \
... plot(Li,2,xmax, plot_points=30, plot_division=0, label='Li(x)') + \
... plot(p, 2,xmax, label='P(X)', rgbcolor=(1,0,0))
...
sage: G.show(xmax=xmax)
r¨ T # Worksheet 'riemann' (2007-01-16 at 04:51)
sage: xmax = 500
sage: G = plot(f, 2,xmax, linestyle='--', label='x/log(x)') + \
... plot(Li,2,xmax, plot_points=30, plot_division=0, label='Li(x)') + \
... plot(p, 2,xmax, label='P(X)', rgbcolor=(1,0,0))
...
sage: G.show(xmax=xmax)
r© T # Worksheet 'riemann' (2007-01-16 at 04:51)
sage: xmax = 20000
sage: G = plot(f, 2,xmax, linestyle='--', label='x/log(x)') + \
... plot(Li,2,xmax, plot_points=30, plot_division=0, label='Li(x)') + \
... plot(p, 2,xmax, label='P(X)', rgbcolor=(1,0,0))
...
sage: G.show(xmax=xmax)
rª U6# Worksheet 'talk' (2007-01-16 at 11:11)
sage: 2 + 2
4r« U6# Worksheet 'talk' (2007-01-16 at 11:11)
sage: 2 + 2
4r¬ U6# Worksheet 'talk' (2007-01-16 at 11:11)
sage: 2 + 3
5r U[# Worksheet 'talk' (2007-01-16 at 11:11)
sage: prime_range(20)
[2, 3, 5, 7, 11, 13, 17, 19]r® U6# Worksheet 'talk' (2007-01-16 at 11:12)
sage: 2 ^ 3
8r¯ UD# Worksheet 'talk' (2007-01-16 at 11:12)
sage: %python
sage: 2 ^ 3
1r° UP# Worksheet 'talk' (2007-01-16 at 11:12)
sage: factorial(20)
2432902008176640000r± Uõ# Worksheet 'talk' (2007-01-16 at 11:12)
sage: show(factor( factorial(40) ))
2^{38} \cdot 3^{18} \cdot 5^{9} \cdot 7^{5} \cdot 11^{3} \cdot 13^{3} \cdot 17^{2} \cdot 19^{2} \cdot 23 \cdot 29 \cdot 31 \cdot 37
r² Uö# Worksheet 'talk' (2007-01-16 at 11:12)
sage: m = matrix(5,5,[randint(0,1) for _ in range(25)]); show(m)
\left(\begin{array}{rrrrr}
1&1&0&0&0\\
0&0&1&0&0\\
0&0&1&1&0\\
0&0&1&0&0\\
1&1&0&1&0
\end{array}\right)
r³ U‡# Worksheet 'talk' (2007-01-16 at 11:12)
sage: f = m.charpoly('T'); show(f)
T^{5} - 2T^{4} + T^{2}
r´ U# Worksheet 'talk' (2007-01-16 at 11:12)
sage: show(factor(f))
(T - 1) \cdot T^{2} \cdot (T^{2} - T - 1)
rµ T‰ # Worksheet 'sieve' (2007-01-16 at 11:12)
sage: %hideall
sage: #auto
sage:
sage: def number_grid(c, box_args={}, font_args={},offset=0):
... """
... INPUT:
... c -- list of length n^2, where n is an integer.
... The entries of c are RGB colors.
... box_args -- additional arguments passed to box.
... font_args -- all additional arguments are passed
... to the text function, e.g., fontsize.
... offset -- use to fine tune text placement in the squares
...
... OUTPUT:
... Graphics -- a plot of a grid that illustrates
... those n^2 numbers colored according to c.
... """
... try:
... n = square_root(ZZ(len(c)))
... except ArithmeticError:
... raise ArithmeticError, "c must have square length"
... G = Graphics()
... k = 0
... for j in reversed(range(n)):
... for i in range(n):
... col = c[int(k)]
... R = line([(i,j),(i+1,j),(i+1,j+1),(i,j+1),(i,j)], thickness=.2, **box_args)
... P = polygon([(i,j),(i+1,j),(i+1,j+1),(i,j+1),(i,j)], rgbcolor=col, **box_args)
... G += P + R
... if col != (1,1,1):
... G += text(str(k+1), (i+.5+offset,j+.5), **font_args)
... k += 1
... G.axes(False)
... G.range(0,n,0,n)
... return G
CPU time: 0.00 s, Wall time: 0.00 sr¶ T€ # Worksheet 'sieve' (2007-01-16 at 11:12)
sage: %hideall
sage: #auto
sage:
sage: def sieve_step(p, n, gone=(1,1,1), prime=(1,0,0), \
... multiple=(.6,.6,.6), remaining=(.9,.9,.9),
... fontsize=11,offset=0):
... """
... Return graphics that illustrates sieving out
... multiples of p. Numbers that are a nontrivial
... multiple of primes < p are shown in the gone color.
... Numbers that are a multiple of p are shown in
... a different color. The number p is shown in
... yet a third color.
...
... INPUT:
... p -- a prime (or 1, in which case all points are colored "remaining")
... n -- a SQUARE integer
... gone -- rgb color for integers that have been sieved out
... prime -- rgb color for p
... multiple -- rgb color for multiples of p
... remaining -- rgb color for integers that have not been sieved out yet
... and are not multiples of p.
... """
... if p == 1:
... c = [remaining]*n
... else:
... exclude = prod(prime_range(p)) # exclude multiples of primes < p
... c = []
... for k in range(1,n+1):
... if k <= p and is_prime(k):
... c.append(prime)
... elif k == 1 or (gcd(k,exclude) != 1 and not is_prime(k)):
... c.append(gone)
... elif k%p == 0:
... c.append(multiple)
... else:
... c.append(remaining)
... # end for
... # end if
... return number_grid(c,{},{'fontsize':fontsize},offset=offset)
CPU time: 0.00 s, Wall time: 0.00 sr· UH# Worksheet 'sieve' (2007-01-16 at 11:12)
sage: show(sieve_step(1,100))
r¸ UH# Worksheet 'sieve' (2007-01-16 at 11:12)
sage: show(sieve_step(1,100))
r¹ UH# Worksheet 'sieve' (2007-01-16 at 11:13)
sage: show(sieve_step(2,100))
rº UH# Worksheet 'sieve' (2007-01-16 at 11:13)
sage: show(sieve_step(1,100))
r» UH# Worksheet 'sieve' (2007-01-16 at 11:13)
sage: show(sieve_step(2,100))
r¼ UH# Worksheet 'sieve' (2007-01-16 at 11:13)
sage: show(sieve_step(3,100))
r½ UH# Worksheet 'sieve' (2007-01-16 at 11:13)
sage: show(sieve_step(5,100))
r¾ UH# Worksheet 'sieve' (2007-01-16 at 11:14)
sage: show(sieve_step(7,100))
r¿ UI# Worksheet 'sieve' (2007-01-16 at 11:14)
sage: show(sieve_step(11,100))
rÀ U•# Worksheet 'sieve' (2007-01-16 at 11:14)
sage: s = [sieve_step(p,100) for p in [2,3,5,7]]
sage: G = graphics_array(s, 2,2)
sage: G.show(axes=False)
rÁ UT# Worksheet 'interface' (2007-01-16 at 11:30)
sage: a = gp('x^3 - y^3'); a
x^3 - y^3r U?# Worksheet 'interface' (2007-01-16 at 11:30)
sage: a
x^3 - y^3rà Ub# Worksheet 'interface' (2007-01-16 at 11:30)
sage: type(a)
rÄ UQ# Worksheet 'interface' (2007-01-16 at 11:30)
sage: parent(a)
GP/PARI interpreterrÅ T # Worksheet 'interface' (2007-01-16 at 11:30)
sage: a.factor()
Traceback (most recent call last):
...
TypeError: Error executing code in GP/PARI:
CODE:
sage[2]=factor(sage[1]);
GP/PARI ERROR:
*** factor: sorry, factor for general polynomials is not yet implemented.rÆ UZ# Worksheet 'interface' (2007-01-16 at 11:30)
sage: R. = QQ[x,y]
sage: b = R(str(a))
rÇ U]# Worksheet 'interface' (2007-01-16 at 11:30)
sage: b.factor()
(-1*y + x) * (y^2 + x*y + x^2)rÈ UT# Worksheet 'interface' (2007-01-16 at 11:39)
sage: a = gp('x^3 - y^3'); a
x^3 - y^3rÉ U?# Worksheet 'interface' (2007-01-16 at 11:39)
sage: a
x^3 - y^3rÊ Ub# Worksheet 'interface' (2007-01-16 at 11:39)
sage: type(a)
rË UQ# Worksheet 'interface' (2007-01-16 at 11:39)
sage: parent(a)
GP/PARI interpreterrÌ UT# Worksheet 'interface' (2007-01-16 at 11:39)
sage: a = gp('x^3 - y^3'); a
x^3 - y^3rÍ U?# Worksheet 'interface' (2007-01-16 at 11:39)
sage: a
x^3 - y^3rÎ Ub# Worksheet 'interface' (2007-01-16 at 11:39)
sage: type(a)
rÏ UQ# Worksheet 'interface' (2007-01-16 at 11:39)
sage: parent(a)
GP/PARI interpreterrÐ T # Worksheet 'interface' (2007-01-16 at 11:39)
sage: a.factor()
Traceback (most recent call last):
...
TypeError: Error executing code in GP/PARI:
CODE:
sage[5]=factor(sage[4]);
GP/PARI ERROR:
*** factor: sorry, factor for general polynomials is not yet implemented.rÑ UZ# Worksheet 'interface' (2007-01-16 at 11:39)
sage: R. = QQ[x,y]
sage: b = R(str(a))
rÒ U]# Worksheet 'interface' (2007-01-16 at 11:39)
sage: b.factor()
(-1*y + x) * (y^2 + x*y + x^2)rÓ U/# Worksheet 'interface' (2007-01-16 at 11:39)
rÔ T # Worksheet 'bernoulli' (2007-01-16 at 12:00)
sage: time bernoulli(10^4)
-211595838046290940721792738040989085665429357988608368792530057574963977461347659806060988412665049378263206010619011705021028593325296217651385927185658068328963543023779613882052256977186230979132745800171383704596841985854242995142873592500747065854779015122240428012255687613284177651255774757047931080059741927443045700873077308529026131284714239112011242912285115288580651936754872068059186057890381422381552365672295636936897632669791887088510748161499...rÕ Uq# Worksheet 'bernoulli' (2007-01-16 at 12:00)
sage: time a = bernoulli(10^4)
CPU time: 0.19 s, Wall time: 0.19 srÖ UE# Worksheet 'bernoulli' (2007-01-16 at 12:00)
sage: len(str(a))
27706r× Uƒ# Worksheet 'bernoulli' (2007-01-16 at 12:00)
sage: time v = bernoulli_mod_p(next_prime(10^4))
CPU time: 0.06 s, Wall time: 0.13 srØ U…# Worksheet 'bernoulli' (2007-01-16 at 12:00)
sage: time v = bernoulli_mod_p(next_prime(2*10^5))
CPU time: 1.59 s, Wall time: 1.66 srÙ U# Worksheet 'bernoulli' (2007-01-16 at 12:00)
sage: v[:10]
[1, 33334, 113335, 4762, 113335, 51516, 177072, 33335, 7444, 183767]rÚ U[# Worksheet 'bernoulli' (2007-01-16 at 12:01)
sage: bernoulli(2) % next_prime(2*10^5)
33334rÛ eU_Notebook__defaultsrÜ }rÝ (Ucell_output_colorrÞ U#0000EErß Umax_history_lengthrà MôUcell_input_colorrá U#0000000râ Uword_wrap_colsrã KPuU_Notebook__worksheet_dirrä Usage_notebook/worksheetsrå U_Notebook__history_countræ K U_Notebook__log_serverrç ‰U_Notebook__filenamerè Usage_notebook/nb.sobjré U_Notebook__default_worksheetrê j¦ U_Notebook__server_logrë ]rì U_Notebook__next_worksheet_idrí KU_Notebook__kill_idlerî K U_Notebook__systemrï NU_Notebook__show_debugrð ‰U_Notebook__dirrñ U
sage_notebookrò U_Notebook__authró U:U_Notebook__colorrô NU_Notebook__object_dirrõ Usage_notebook/objectsrö U_default_filenamer÷ U:/Users/was/talks/2007-01-15-sage-cse/sage_notebook/nb.sobjrø U_Notebook__splashpagerù ‰ub.