csage.server.notebook.notebook Notebook q)q}q(U_Notebook__worksheetsq}q(U intro_to_sageq(csage.server.notebook.worksheet Worksheet qoq}q (U_Worksheet__filenameq U intro_to_sageq U_Worksheet__cellsq ]q (csage.server.notebook.cell TextCell qoq}q(U_TextCell__worksheetqhU_TextCell__textqT\

Intro to SAGE for Math Modeling Students

  1. I was in the Math Modeling Contest in 1993 and loved it





sage.math.washington.edu: The Hardware

http://modular.math.washington.edu/sage.html




sage.math.washington.edu: The Software

Mathematica

Maple

MATLAB

MAGMA

REDUCE

SAGE






SAGE: Software for Algebra and Geometry Experimentation

All Open Source

Allows one to use much software together

Has a LOT of functionality for certain types of problems.

How to install on your own computer

Graph theory -- comes up a lot in Math Modeling Contest, I guess

Numerical computation -- numpy

WIKI






qU _TextCell__idqMubaU_Worksheet__comp_is_runningqU_Worksheet__dirqU&sage_notebook/worksheets/intro_to_sageqU_Worksheet__attachedq}qU_Worksheet__passcodeqU 11G3BJNEUV/PkqU_Worksheet__queueq]qU_Worksheet__next_idqMU_Worksheet__passcryptqU_Worksheet__nameq U intro_to_sageq!U_Worksheet__saltq"U1169250859.428083q#U_Worksheet__notebookq$hU_Worksheet__idq%KU_Worksheet__systemq&NubUbiggraphq'(hoq(}q)(h Ubiggraphq*h ]q+((csage.server.notebook.cell Cell q,oq-}q.(U _Cell__inq/Ug = graphs.RandomGNP(30)q0U_Cell__introspect_htmlq1U!
q2U_Cell__worksheetq3h(U_Cell__completionsq4U_Cell__introspectq5U_Cell__out_htmlq6UU	_Cell__idq7M U_Cell__is_htmlq8U_before_preparseq9Usos.chdir("/Users/was/talks/2007-01-19-sage/2.0/sage_notebook/worksheets/biggraph/cells/0")
g = graphs.RandomGNP(30)q:U
_Cell__dirq;U)sage_notebook/worksheets/biggraph/cells/0q", line 1, in 
  File "/Users/was/talks/2007-01-19-sage/2.0/sage_notebook/worksheets/biggraph/code/1.py", line 6, in 
    exec compile(ur'g = graphs.RandomGNP(Integer(30))' + '\n', '', 'single')
  File "/Users/was/talks/2007-01-19-sage/2.0/", line 1, in 
    
TypeError: RandomGNP() takes at least 3 arguments (2 given)q>Uhas_new_outputq?U_Cell__sageq@csage.interfaces.sage0
reduce_load_Sage
qA)RqBU_Cell__versionqCKU_Cell__typeqDUwrapqEU_Cell__timeqFU_Cell__interruptedqGub(h,oqH}qI(h/Uh3h(h4h6Uh7M h;U)sage_notebook/worksheets/biggraph/cells/1qJh=Uh?hCKhDhEhGubeU_Worksheet__synchroqKKhhU!sage_notebook/worksheets/biggraphqLh}qMU/Users/was/.sage/init.sageqNGAjeshU
11G3BJNEUV/PkqOh]qPhM hh UbiggraphqQh"U1169257401.406394qRh$hU_Worksheet__next_block_idqSKh%KU_Worksheet__sageqThBh&NubU	_scratch_qU(hoqV}qW(h
U	_scratch_qXh]qY((hoqZ}q[(hhVhT

From SAGE 1.0 to SAGE 2.0

One year of hard work by over 30 people...






Leveraging the Internet

The SAGE Notebook

q\hM*ub(h,oq]}q^(h/U2 + 323q_h1U!
q`h3hVh4h5h6Uh7M+hFh8h9Ueos.chdir("/Users/was/talks/2007-01-19-sage/2.0/sage_notebook/worksheets/_scratch_/cells/811")
2 + 323qah;U,sage_notebook/worksheets/_scratch_/cells/811qbh=U
325

qch?hCKh@hA)RqdhDhEhGub(hoqe}qf(hhVhU&

Math typesetting (via jsmath)

qghM,ub(h,oqh}qi(h/U>jsmath(r'\int_{0}^{2\pi} \frac{\sin(x^2)}{\cos(\theta x)} dx')qjh1U!
qkh3hVh4h5h6Uh7M-hFh8h9Uos.chdir("/Users/was/talks/2007-01-19-sage/2.0/sage_notebook/worksheets/_scratch_/cells/813")
jsmath(r'\int_{0}^{2\pi} \frac{\sin(x^2)}{\cos(\theta x)} dx')qlh;U,sage_notebook/worksheets/_scratch_/cells/813qmh=U[
\int_{0}^{2\pi} \frac{\sin(x^2)}{\cos(\theta x)} dx
qnh?hCKh@hdhDhEhGub(h,oqo}qp(h/U%show(maxima('sin(x^2)').integrate(x))qqh1U!
qrh3hVh4h5h6Uh7M.hFh8h9Uos.chdir("/Users/was/talks/2007-01-19-sage/2.0/sage_notebook/worksheets/_scratch_/cells/814")
show(maxima('sin(x^2)').integrate(x))qsh;U,sage_notebook/worksheets/_scratch_/cells/814qth=T-
{{\sqrt{\pi}\,\left(\left(\sqrt{2}\,i+\sqrt{2}\right)\,\mathrm{erf} \left({{\left(\sqrt{2}\,i+\sqrt{2}\right)\,x}\over{2}}\right)+\left( \sqrt{2}\,i-\sqrt{2}\right)\,\mathrm{erf}\left({{\left(\sqrt{2}\,i- \sqrt{2}\right)\,x}\over{2}}\right)\right)}\over{8}}
quh?hCKh@hdhDhEhGub(hoqv}qw(hhVhUy

Moin Moin Wiki included standard with SAGE

Trivial to setup wiki pre-configured with math typesetting standard.qxhM/ub(h,oqy}qz(h/Uwiki()q{h1U!
q|h3hVh4h5h6Uh7M0hFh8h9Udos.chdir("/Users/was/talks/2007-01-19-sage/2.0/sage_notebook/worksheets/_scratch_/cells/816")
wiki()q}h;U,sage_notebook/worksheets/_scratch_/cells/816q~h=U
Serving on localhost:9000
localhost - - [19/Jan/2007 16:13:19] "GET / HTTP/1.1" 404 -
localhost - - [19/Jan/2007 16:13:20] "GET /MyStartingPage?action=edit HTTP/1.1" 200 -
localhost - - [19/Jan/2007 16:13:38] "POST /MyStartingPage HTTP/1.1" 200 -qh?hCKh@NhDhEhGub(hoq}q(hhVhU]

Twisted

http://twistedmatrix.com/trac/qhM1ub(h,oq}q(h/Uimport twisted help(twisted)qh3hVh4h6Uh7M2h;U,sage_notebook/worksheets/_scratch_/cells/818qh=THelp on package twisted: NAME twisted - Twisted: The Framework Of Your Internet. FILE /Users/was/s/local/lib/python2.5/site-packages/twisted/__init__.py PACKAGE CONTENTS _version application (package) conch (package) copyright cred (package) enterprise (package) im internet (package) lore (package) mail (package) manhole (package) names (package) news (package) persisted (package) plugin plugins (package) protocols (package) python (package) runner (package) scripts (package) spread (package) tap (package) test (package) trial (package) web (package) web2 (package) words (package) DATA __version__ = '2.5.0' version = Version('twisted', 2, 5, 0) VERSION 2.5.0qh?hCKh@NhDhEhGub(hoq}q(hhVhU

OpenSSL

The inclusion of OpenSSL will be the basis for security for the SAGE notebook and other SAGE related networking work. Also, it will be very useful for security education and research.qhM3ub(h,oq}q(h/Uimport OpenSSL help(OpenSSL)qh3hVh4h6Uh7M4h;U,sage_notebook/worksheets/_scratch_/cells/820qh=T$Help on package OpenSSL: NAME OpenSSL - pyOpenSSL - A simple wrapper around the OpenSSL library FILE /Users/was/s/local/lib/python2.5/site-packages/OpenSSL/__init__.py PACKAGE CONTENTS SSL crypto rand tsafe version DATA __version__ = '0.6' VERSION 0.6qh?hCKh@NhDhEhGub(hoq}q(hhVhUa




Combinatorics and Geometry

gfan -- Tropical Geometry

qhM5ub(h,oq}q(h/UaR. = QQ[] I = ideal(y^2*z - x^3 - x*z^2) show(I.groebner_fan().reduced_groebner_bases())qh3hVh4h6Uh7M6h;U,sage_notebook/worksheets/_scratch_/cells/822qh=U
\begin{array}{l}[\left[-1 y^{2}z + xz^{2} + x^{3}\right],\\ \left[y^{2}z - xz^{2} - x^{3}\right],\\ \left[-1 y^{2}z + xz^{2} + x^{3}\right]],\\ \end{array}
qh?hCKh@NhDhEhGub(hoq}q(hhVhU

Polymake

qhM7ub(h,oq}q(h/Usage: P = polymake.convex_hull([[1,0,0,0], [1,0,0,1], [1,0,1,0], [1,0,1,1], [1,1,0,0], [1,1,0,1], [1,1,1,0], [1,1,1,1]]) # optional: needs polymake sage: P.vertices()qh1U!
qh3hVh4h5h6Uh7M8hFh8h9T	os.chdir("/Users/was/talks/2007-01-19-sage/2.0/sage_notebook/worksheets/_scratch_/cells/824")
sage: P = polymake.convex_hull([[1,0,0,0], [1,0,0,1], [1,0,1,0], [1,0,1,1],  [1,1,0,0], [1,1,0,1], [1,1,1,0], [1,1,1,1]])     # optional: needs polymake
sage: P.vertices()qh;U,sage_notebook/worksheets/_scratch_/cells/824qh=Us
[(1, 0, 0, 0), (1, 0, 0, 1), (1, 0, 1, 0), (1, 0, 1, 1), (1, 1, 0, 0), (1, 1, 0, 1), (1, 1, 1, 0), (1, 1, 1, 1)]

qh?hCKh@hA)RqhDhEhGub(h,oq}q(h/Uh3hVh4h6Uh7M9h;U,sage_notebook/worksheets/_scratch_/cells/825qh=Uh?hCKh@NhDhEhGub(hoq}q(hhVhU

Lattice Polytopes

qhM:ub(h,oq}q(h/U5L = LatticePolytope(matrix(P.vertices())) L.npoints()qh1U!
qh3hVh4h5h6Uh7M;hFh8h9Uos.chdir("/Users/was/talks/2007-01-19-sage/2.0/sage_notebook/worksheets/_scratch_/cells/827")
L = LatticePolytope(matrix(P.vertices()))
L.npoints()qU_word_being_completedqUL.npoiqh;U,sage_notebook/worksheets/_scratch_/cells/827qh=T
Traceback (most recent call last):
  File "", line 1, in 
  File "/Users/was/talks/2007-01-19-sage/2.0/sage_notebook/worksheets/_scratch_/code/9.py", line 5, in 
    exec compile(ur'L.npoints()' + '\n', '', 'single')
  File "/Users/was/talks/2007-01-19-sage/2.0/sage_notebook/worksheets/_scratch_/cells/816/sage_wiki/", line 1, in 
    
  File "/Users/was/s/local/lib/python2.5/site-packages/sage/geometry/lattice_polytope.py", line 770, in npoints
    return self.points().ncols()
  File "/Users/was/s/local/lib/python2.5/site-packages/sage/geometry/lattice_polytope.py", line 872, in points
    self._points = read_palp_matrix(self.poly_x("p"))
  File "/Users/was/s/local/lib/python2.5/site-packages/sage/geometry/lattice_polytope.py", line 957, in poly_x
    return self._palp("poly.x -f" + keys)
  File "/Users/was/s/local/lib/python2.5/site-packages/sage/geometry/lattice_polytope.py", line 334, in _palp
    self, self.vertices(), result)
ValueError: Error executing "poly.x -fp" for the given polytope!
Polytope: A lattice polytope: 8-dimensional, 4 vertices.
Vertices:
[1 0 0 0]
[1 0 0 1]
[1 0 1 0]
[1 0 1 1]
[1 1 0 0]
[1 1 0 1]
[1 1 1 0]
[1 1 1 1]
Output:
qh?hCKh@hhDUhiddenqhGub(h,oq}q(h/UL.is_reflexive()qh3hVh4h6Uh7M<h;U,sage_notebook/worksheets/_scratch_/cells/828qh=UFalseqh?hCKh@NhDhEhGub(h,oq}q(h/U'k = graphs.CubeGraph(5)
print k
show(k)qh1U!
qh3hVh4h5h6UDqh7M=hFh8h9Uos.chdir("/Users/was/talks/2007-01-19-sage/2.0/sage_notebook/worksheets/_scratch_/cells/829")
k = graphs.CubeGraph(5)
print k
show(k)qhU
graphs.Cubqh;U,sage_notebook/worksheets/_scratch_/cells/829qh=U	
5-Cube

qh?hCKh@hhDhEhGub(hoq}q(hhVhUu

Graph Theory -- NetworkX






Number Theory

Many more basic functions

qhM>ub(h,oq}q(h/Usloane.A000110(23)qh1U!
qh3hVh4h5h6Uh7M?hFh8h9Upos.chdir("/Users/was/talks/2007-01-19-sage/2.0/sage_notebook/worksheets/_scratch_/cells/831")
sloane.A000110(23)qhUsloane.A000110qh;U,sage_notebook/worksheets/_scratch_/cells/831qh=U
44152005855084346

qh?hCKh@hhDhEhGub(hoq}q(hhVhU

FLINT

qhM@ub(h,oq}q(h/U?print "Coming soon... Will multiply polynomials very quickly."qh3hVh4h6Uh7MAh;U,sage_notebook/worksheets/_scratch_/cells/833qh=U7Coming soon... Will multiply polynomials very quickly.qh?hCKh@NhDhEhGub(hoq}q(hhVhU&

PARI

A stable 2.3.0 release.qhMBub(h,oq}q(h/U gp.version()qh3hVh4h6Uh7MCh;U,sage_notebook/worksheets/_scratch_/cells/835qh=U:((2, 3, 1), 'GP/PARI CALCULATOR Version 2.3.1 (released)')qh?hCKh@NhDhEhGub(h,oq}q(h/Ugp.qh3hVh4h6Uh7MDh;U,sage_notebook/worksheets/_scratch_/cells/836qh=Uh?hCKh@NhDhEhGub(hoq}q(hhVhU




Linear Algebra

SageX'ification

This was incredibly difficult! Required substantial improvements to Pyrex, design work, etc.qhMEub(h,oq}q(h/U$m = matrix(QQ,10,range(100)) type(m)qh1U!
qh3hVh4h5h6Uh7MFhFh8h9Uos.chdir("/Users/was/talks/2007-01-19-sage/2.0/sage_notebook/worksheets/_scratch_/cells/838")
m = matrix(QQ,10,range(100))
type(m)qh;U,sage_notebook/worksheets/_scratch_/cells/838qh=UC


qh?hCKh@hhDhEhGub(hoq}q(hhVhU

Asymptotically Fast Algorithms

David Harvey, Robert Bradshaw, me -- lots of work to write down general practical algorithms; not just proofs of concept.qhMGub(h,oq}q(h/Um.integer_kernel()qh1U!
qh3hVh4h5h6Uh7MHhFh8h9Upos.chdir("/Users/was/talks/2007-01-19-sage/2.0/sage_notebook/worksheets/_scratch_/cells/840")
m.integer_kernel()qhUm.integer_keqh;U,sage_notebook/worksheets/_scratch_/cells/840qh=TN
Free module of degree 10 and rank 8 over Integer Ring
Echelon basis matrix:
[ 1  0  0  0  0  0  0  0 -9  8]
[ 0  1  0  0  0  0  0  0 -8  7]
[ 0  0  1  0  0  0  0  0 -7  6]
[ 0  0  0  1  0  0  0  0 -6  5]
[ 0  0  0  0  1  0  0  0 -5  4]
[ 0  0  0  0  0  1  0  0 -4  3]
[ 0  0  0  0  0  0  1  0 -3  2]
[ 0  0  0  0  0  0  0  1 -2  1]

qh?hCKh@hhDhEhGub(hoq}q(hhVhU\

Numerical Linear Algebra -- several new choices

Numpy -- work of Travis OliphantqhMIub(h,oq}q(h/Uimport numpy numpy.random.qh1T:qh3hVh4h5]q(hUeh6Uh7MJhFh8h9Uxos.chdir("/Users/was/talks/2007-01-19-sage/2.0/sage_notebook/worksheets/_scratch_/cells/842") import numpy numpy.random.qhU numpy.random.qh;U,sage_notebook/worksheets/_scratch_/cells/842qh=U rh?hCKh@hhDhEhGub(hor}r(hhVhU7GSL integration into SAGE -- work mainly of Josh KantorrhMKub(h,or}r(h/U@n=1000 m = matrix(RDF,n,range(n^2)) print type(m) time n = m*m rh1U!
rh3hVh4h5h6Uh7MLhFh8h9Uos.chdir("/Users/was/talks/2007-01-19-sage/2.0/sage_notebook/worksheets/_scratch_/cells/844")
n=1000
m = matrix(RDF,n,range(n^2))
print type(m)
time n = m*mrh;U,sage_notebook/worksheets/_scratch_/cells/844r	h=Uh

Time: CPU 4.89 s, Wall: 5.40 s

r
h?hCKh@hhDhEhGub(hor}r(hhVhT8




Developer Tools

Arithmetic Architecture

  1. Came out of SAGE Days 2
  2. Has huge impact on speed of SAGE.
  3. Make using SAGE, adding classes, and understanding implicit coercion much clearer.
  4. Was incredibly hard to implement, but is now done.
r hMMub(h,or}r(h/U/a = 3; b = Mod(8,13) parent(a * b), parent(b*a)rh1U!
rh3hVh4h5h6Uh7MNhFh8h9Uos.chdir("/Users/was/talks/2007-01-19-sage/2.0/sage_notebook/worksheets/_scratch_/cells/846")
a = 3; b = Mod(8,13)
parent(a * b), parent(b*a)rh;U,sage_notebook/worksheets/_scratch_/cells/846rh=U;
(Ring of integers modulo 13, Ring of integers modulo 13)

rh?hCKh@hhDhEhGub(h,or}r(h/Ua._mul_rh3hVh4h6Uh7MOh;U,sage_notebook/worksheets/_scratch_/cells/847rh=Uh?hCKh@NhDhEhGub(hor}r(hhVhU

Pyrex --> SageX

rhMPub(h,or}r(h/UB%sagex v = [i*i for i from 0 <= i < 1000] v[2] += 5 print v[:10]rh1U!
rh3hVh4h5h6T__Users_was_talks_2007_01_19_sage_2_0_sage_notebook_worksheets__scratch__code_sage51_spyx.cr h7MQhFh8h9Uos.chdir("/Users/was/talks/2007-01-19-sage/2.0/sage_notebook/worksheets/_scratch_/cells/849")
%sagex

v  = [i*i for i from 0 <= i < 1000]
v[2] += 5
print v[:10]r!h;U,sage_notebook/worksheets/_scratch_/cells/849r"h=U'
[0, 1, 9, 9, 16, 25, 36, 49, 64, 81]

r#h?hCKh@hhDhEhGub(hor$}r%(hhVhU

Darcs --> Mercurial

  1. Darcs does not scale well; gets slow. Darcs is cool.
  2. Mercurial scales very well; is fast. Is much much different than Darcs.
r&hMRub(h,or'}r((h/Uhg_sage.r)h3hVh4h6Uh7MSh;U,sage_notebook/worksheets/_scratch_/cells/851r*h=Uh?hCKh@NhDhEhGub(hor+}r,(hhVhU

Trac -- bug and feature tracker

http://sage.math.washington.edu:9002/sage_trac




Graphics

2d Mathematica-like graphics

r-hMTub(h,or.}r/(h/Udef f(x): return x + sin(x)*cos(x) show(plot(f, -3, 2, hue=0.7)) def f(x,y): return cos(x^2 + y^2) show(contour_plot(f, (-4, 4), (-4, 4), contours=50, cmap="Spectral"))r0h1U!
r1h3hVh4h5h6U
r2h7MUhFh8h9Tos.chdir("/Users/was/talks/2007-01-19-sage/2.0/sage_notebook/worksheets/_scratch_/cells/853") def f(x): return x + sin(x)*cos(x) show(plot(f, -3, 2, hue=0.7)) def f(x,y): return cos(x^2 + y^2) show(contour_plot(f, (-4, 4), (-4, 4), contours=50, cmap="Spectral"))r3h;U,sage_notebook/worksheets/_scratch_/cells/853r4h=U r5h?hCKh@hhDhEhGub(hor6}r7(hhVhU

3d Raytracer included

r8hMVub(h,or9}r:(h/Tsage: t = Tachyon(xres=512,yres=512, camera_center=(2,0.5,0.5), look_at=(0.5,0.5,0.5), raydepth=4) sage: t.light((4,3,2), 0.2, (1,1,1)) sage: t.texture('t0', ambient=0.1, diffuse=0.9, specular=0.5, opacity=1.0, color=(1.0,0,0)) sage: t.texture('t1', ambient=0.1, diffuse=0.9, specular=0.3, opacity=1.0, color=(0,1.0,0)) sage: t.texture('t2', ambient=0.2, diffuse=0.7, specular=0.5, opacity=0.7, color=(0,0,1.0)) sage: k=0 sage: for i in range(100): ... k += 1 ... t.sphere((random(),random(), random()), random()/10, 't%s'%(k%3)) ... sage: t.save('sage.png')r;h1U!
r<h3hVh4h5h6UCr=h7MWhFh8h9Tos.chdir("/Users/was/talks/2007-01-19-sage/2.0/sage_notebook/worksheets/_scratch_/cells/855")
sage: t = Tachyon(xres=512,yres=512, camera_center=(2,0.5,0.5), look_at=(0.5,0.5,0.5), raydepth=4)
        sage: t.light((4,3,2), 0.2, (1,1,1))
        sage: t.texture('t0', ambient=0.1, diffuse=0.9, specular=0.5, opacity=1.0, color=(1.0,0,0))
        sage: t.texture('t1', ambient=0.1, diffuse=0.9, specular=0.3, opacity=1.0, color=(0,1.0,0))
        sage: t.texture('t2', ambient=0.2, diffuse=0.7, specular=0.5, opacity=0.7, color=(0,0,1.0))
        sage: k=0
        sage: for i in range(100):
        ...    k += 1
        ...    t.sphere((random(),random(), random()), random()/10, 't%s'%(k%3))
        ...
        sage: t.save('sage.png')r>h;U,sage_notebook/worksheets/_scratch_/cells/855r?h=U

r@h?hCKh@hhDhEhGub(horA}rB(hhVhUa




Cryptography

Hart's Optimized Portable Quadratic Sieve

rChMXub(h,orD}rE(h/U0time qsieve(next_prime(10^22)*next_prime(10^25))rFh3hVh4h6Uh7MYh;U,sage_notebook/worksheets/_scratch_/cells/857rGh=U`([10000000000000000000009, 10000000000000000000000013], '') CPU time: 0.02 s, Wall time: 0.81 srHh?hCKh@NhDhEhGub(horI}rJ(hhVhU

OpenSSL

rKhMZub(h,orL}rM(h/Uimport OpenSSL help(OpenSSL)rNh3hVh4h6Uh7M[h;U,sage_notebook/worksheets/_scratch_/cells/859rOh=T$Help on package OpenSSL: NAME OpenSSL - pyOpenSSL - A simple wrapper around the OpenSSL library FILE /Users/was/s/local/lib/python2.5/site-packages/OpenSSL/__init__.py PACKAGE CONTENTS SSL crypto rand tsafe version DATA __version__ = '0.6' VERSION 0.6rPh?hCKh@NhDhEhGub(horQ}rR(hhVhU%

David Kohel's Crypto Package

rShM\ub(h,orT}rU(h/Txsage: S = AlphabeticStrings() sage: E = SubstitutionCryptosystem(S) sage: E Substitution cryptosystem on Free alphabetic string monoid on A-Z sage: K = S([ 25-i for i in range(26) ]) sage: K ZYXWVUTSRQPONMLKJIHGFEDCBA sage: e = E(K) sage: m = S("THECATINTHEHAT") sage: e(m) GSVXZGRMGSVSZGrVh3hVh4h6Uh7M]h;U,sage_notebook/worksheets/_scratch_/cells/861rWh=UGSVXZGRMGSVSZGrXh?hCKh@NhDhEhGub(horY}rZ(hhVhU1

GMP-ECM: Elliptic Curve Factorization Packager[hM^ub(h,or\}r](h/U>time ecm.factor(602400691612422154516282778947806249229526581)r^h3hVh4h6Uh7M_h;U,sage_notebook/worksheets/_scratch_/cells/863r_h=UW[45949729863572179, 13109994191499930367061460439] CPU time: 0.01 s, Wall time: 1.64 sr`h?hCKh@NhDhEhGub(hora}rb(hhVhT0
>  
> f(p) = p^p -1
>  
> where p >= 47 is a prime number.
>  
> (for some p's > 47;, gp gave quickly the factorization
> but e.g . for p=47, or p=61, or ?
> gp sems to stay there forever !)
 
This code in SAGE (version 1.6) splits the p=47 case in about 10-15 minutes:
 
n=ZZ( (47^47-1)/(2*23*1693))
print n
print "----------\n\n"
print qsieve(n,block=True, verbose=True)
 
OUTPUT:
 
[255742492896763511474638530188876017, 194707033016099228267068299180244011637]
 
so f(47) = 2*23*1693*255742492896763511474638530188876017*194707033016099228267068299180244011637
 
This code does the same calculation in about 10 minutes also:
 
n=ZZ( (47^47-1)/(2*23*1693))
print n
print "----------\n\n"
print ecm.factor(n)
 
OUTPUT:
[255742492896763511474638530188876017, 194707033016099228267068299180244011637]
 
SAGE is freely available here: http://sage.math.washington.edu/sage/
It includes William Hart's new Quadratic Sieve (which is used for the
first calculation above), and GMP-ECM (which was used for the second
calculation).





A new focus on Calculus, Symbolic Computation, etc.

Clear GOAL: Directly take on Maple/Mathematica for educational application.

Currently going to use Maxima on backend, but maybe also use GIAC (?)

rchM`ub(h,ord}re(h/Uufrom sage.calculus.all import * f = sin(x)*cos(3*x) + cos(2*x) - sin(x)^2 show(f.trig_expand()) show(f.integral(x))rfh1U!
rgh3hVh4h5h6Uh7MahFh8h9Uos.chdir("/Users/was/talks/2007-01-19-sage/2.0/sage_notebook/worksheets/_scratch_/cells/865")
from sage.calculus.all import *

f = sin(x)*cos(3*x) + cos(2*x) - sin(x)^2
show(f.trig_expand())

show(f.integral(x))rhh;U,sage_notebook/worksheets/_scratch_/cells/865rih=T
\sin \left( x \right) \cdot \cos \left( x \right)^{3} - 3 \cdot \cos \left( x \right) \cdot \sin \left( x \right)^{2} - 2 \cdot \sin \left( x \right)^{2} + \cos \left( x \right)^{2}
\frac{-1 \cdot \cos \left( 4 \cdot x \right)}{8} + \frac{\sin \left( 2 \cdot x \right)}{2} - \frac{x - \frac{\sin \left( 2 \cdot x \right)}{2}}{2} + \frac{\cos \left( 2 \cdot x \right)}{4}
rjh?hCKh@hhDhEhGub(hork}rl(hhVhUc




Numerical Computation

We want to take on MATLAB.

GSL

rmhMbub(h,orn}ro(h/U+v = vector(CDF,range(2048)) time w=v.fft()rph3hVh4h6Uh7Mch;U,sage_notebook/worksheets/_scratch_/cells/867rqh=UTime: CPU 0.00 s, Wall: 0.00 srrh?hCKh@NhDhEhGub(hors}rt(hhVhT

Numpy

Very matlab like and powerful for a lot of work

SciPy

Optional SAGE package -- provides much more MATLAB like functionality.

WHAT WE REALLY NEED for Education

Integrated environment that is complete, easy to install, and "JUST WORKS". Scipy is not that. SAGE can be.




Distributed Computation

This is just getting going...

Yi Qiang's DSAGE

ruhMdub(h,orv}rw(h/U>dsage.[tab] ## doesn't exist yet, but will be very easy to userxh3hVh4h6Uh7Meh;U,sage_notebook/worksheets/_scratch_/cells/869ryh=Uh?hCKh@NhDhEhGub(horz}r{(hhVhT

Plans for lots of more, which will be a major goal for SAGE 3.0






Clear Decisions about Platform Support, etc

Supported Platforms

  1. Linux on AMD, x86, and Itanium: as a "monolithic build" only
  2. OS/X on PPC and Intel: as a "monolithic build" only
  3. Microsoft Windows: via Cygwin
  4. Solaris: will be attempted in March

Binary Distribution

http://sage.math.washington.edu/SAGEbin/
  1. Currently a precompiled tarball.
  2. Anybody can easily make a binary of their personal SAGE install with their optional packages preinstalled by typing
      sage -bdist name
    
  3. RPMS, DEBS, MSI's, DPKG will come when the time is right, i.e., when we are ready to have way more users than developers; this will be by the end of March.
r|hMfubehKKhhU"sage_notebook/worksheets/_scratch_r}h}r~U/Users/was/.sage/init.sagerGAjeshU 11G3BJNEUV/Pkrh]rhMgU_Worksheet__variablesr]r(U5L-sage.geometry.lattice_polytope.LatticePolytopeClassrU!P-sage.geometry.polytope.PolytoperU7SER-sage.calculus.calculus.SymbolicExpressionRing_classrUa-sage.rings.integer.IntegerrU'b-sage.rings.integer_mod.IntegerMod_intrU'cos-sage.calculus.calculus.Function_cosrU diff-functionrU+f-sage.calculus.calculus.SymbolicArithmeticrUi-intrUk-sage.rings.integer.IntegerrU?m-sage.matrix.matrix_real_double_dense.Matrix_real_double_denserU?n-sage.matrix.matrix_real_double_dense.Matrix_real_double_denserU numpy-modulerU'sec-sage.calculus.calculus.Function_secrU'sin-sage.calculus.calculus.Function_sinrU)t-sage.calculus.calculus.SymbolicVariablerUv-listrU var-functionrU)w-sage.calculus.calculus.SymbolicVariablerU)x-sage.calculus.calculus.SymbolicVariablerU)y-sage.calculus.calculus.SymbolicVariablerU)z-sage.calculus.calculus.SymbolicVariablerehh U _scratch_rh"U1169240003.063697rh$hhSK6h%KhThh&NubUtutr(hor}r(h Ututrh ]r((hor}r(hjhU?
Type
factor(2007)
below and press shift enter.rhM0ub(h,or}r(h/U factor(2007)rh3jh4h6Uh7M0h;U$sage_notebook/worksheets/tut/cells/7rh=U 3^2 * 223rh?hCKh@NhDhEhGub(hor}r(hjhUUExcellent. Now verify that the product of the integers in the factorization is 2007.rhM0ub(h,or}r(h/U 3^2 * 223rh3jh4h6Uh7M 0h;U$sage_notebook/worksheets/tut/cells/9rh=U2007rh?hCKh@NhDhEhGub(h,or}r(h/Uh3jh4h6Uh7M 0h;U%sage_notebook/worksheets/tut/cells/10rh=Uh?hCKh@NhDhEhGubehKKhhUsage_notebook/worksheets/tutrh}rU/Users/was/.sage/init.sagerGAjeshU 11G3BJNEUV/Pkrh]rhM 0j]rhh Ututrh"U1169259031.757327rh$hhSKh%KhThA)Rrh&NubuU_Notebook__historyr]r(U;# Worksheet '_scratch_' (2007-01-19 at 15:19) sage: 2 + 3 5rU# Worksheet '_scratch_' (2007-01-19 at 15:20) sage: jsmath(r'\int_{0}^{2\pi} \frac{\sin(x^2)}{\cos(\theta x)} dx')
\int_{0}^{2\pi} \frac{\sin(x^2)}{\cos(\theta x)} dx
rU# Worksheet '_scratch_' (2007-01-19 at 15:20) sage: jsmath(r'$$\int_{0}^{2\pi} \frac{\sin(x^2)}{\cos(\theta x)} dx$$')
$$\int_{0}^{2\pi} \frac{\sin(x^2)}{\cos(\theta x)} dx$$
rU# Worksheet '_scratch_' (2007-01-19 at 15:20) sage: jsmath(r'\int_{0}^{2\pi} \frac{\sin(x^2)}{\cos(\theta x)} dx')
\int_{0}^{2\pi} \frac{\sin(x^2)}{\cos(\theta x)} dx
rU# Worksheet '_scratch_' (2007-01-19 at 15:20) sage: jsmath(r'\displaystyle\int_{0}^{2\pi} \frac{\sin(x^2)}{\cos(\theta x)} dx')
\displaystyle\int_{0}^{2\pi} \frac{\sin(x^2)}{\cos(\theta x)} dx
rU# Worksheet '_scratch_' (2007-01-19 at 15:20) sage: jsmath(r'\int_{0}^{2\pi} \frac{\sin(x^2)}{\cos(\theta x)} dx')
\int_{0}^{2\pi} \frac{\sin(x^2)}{\cos(\theta x)} dx
rU;# Worksheet '_scratch_' (2007-01-19 at 15:20) sage: 2 + 3 5rU# Worksheet '_scratch_' (2007-01-19 at 15:21) sage: jsmath(r'\int_{0}^{2\pi} \frac{\sin(x^2)}{\cos(\theta x)} dx')
\int_{0}^{2\pi} \frac{\sin(x^2)}{\cos(\theta x)} dx
rT# Worksheet '_scratch_' (2007-01-19 at 15:21) sage: show(maxima('sin(x^2)').integrate(x))
{{\sqrt{\pi}\,\left(\left(\sqrt{2}\,i+\sqrt{2}\right)\,\mathrm{erf} \left({{\left(\sqrt{2}\,i+\sqrt{2}\right)\,x}\over{2}}\right)+\left( \sqrt{2}\,i-\sqrt{2}\right)\,\mathrm{erf}\left({{\left(\sqrt{2}\,i- \sqrt{2}\right)\,x}\over{2}}\right)\right)}\over{8}}
rU# Worksheet '_scratch_' (2007-01-19 at 15:21) sage: wiki() Traceback (most recent call last): ... RuntimeError: You can run only one server per process!rU# Worksheet '_scratch_' (2007-01-19 at 15:22) sage: import Twisted Traceback (most recent call last): ... ImportError: No module named TwistedrUC# Worksheet '_scratch_' (2007-01-19 at 15:22) sage: import twisted rUC# Worksheet '_scratch_' (2007-01-19 at 15:22) sage: import twisted rU_# Worksheet '_scratch_' (2007-01-19 at 15:23) sage: twisted.version Version('twisted', 2, 5, 0)rT&# Worksheet '_scratch_' (2007-01-19 at 15:23) sage: import twisted sage: help(twisted) Help on package twisted: NAME twisted - Twisted: The Framework Of Your Internet. FILE /Users/was/s/local/lib/python2.5/site-packages/twisted/__init__.py PACKAGE CONTENTS _version application (package) conch (package) copyright cred (package) enterprise (package) im internet (package) lore (package) mail (package) manhole (package) names (package) news (package) persisted (package) plugi...rUC# Worksheet '_scratch_' (2007-01-19 at 15:24) sage: import OpenSSL rT{# Worksheet '_scratch_' (2007-01-19 at 15:24) sage: import OpenSSL sage: help(OpenSSL) Help on package OpenSSL: NAME OpenSSL - pyOpenSSL - A simple wrapper around the OpenSSL library FILE /Users/was/s/local/lib/python2.5/site-packages/OpenSSL/__init__.py PACKAGE CONTENTS SSL crypto rand tsafe version DATA __version__ = '0.6' VERSION 0.6rT# Worksheet '_scratch_' (2007-01-19 at 15:26) sage: R. = QQ[] sage: I = ideal(y^2*z - x^3 - x*z^2) sage: I.groebner_fan().reduced_groebner_basis() Traceback (most recent call last): ... AttributeError: 'GroebnerFan' object has no attribute 'reduced_groebner_basis'rU# Worksheet '_scratch_' (2007-01-19 at 15:27) sage: R. = QQ[] sage: I = ideal(y^2*z - x^3 - x*z^2) sage: I.groebner_fan().reduced_groebner_bases() [[-1*y^2*z + x*z^2 + x^3], [y^2*z - x*z^2 - x^3], [-1*y^2*z + x*z^2 + x^3]]rT`# Worksheet '_scratch_' (2007-01-19 at 15:27) sage: R. = QQ[] sage: I = ideal(y^2*z - x^3 - x*z^2) sage: show(I.groebner_fan().reduced_groebner_bases())
\begin{array}{l}[\left[-1 y^{2}z + xz^{2} + x^{3}\right],\\ \left[y^{2}z - xz^{2} - x^{3}\right],\\ \left[-1 y^{2}z + xz^{2} + x^{3}\right]],\\ \end{array}
rTJ# Worksheet '_scratch_' (2007-01-19 at 15:28) sage: P = polymake.convex_hull([[1,0,0,0], [1,0,0,1], [1,0,1,0], [1,0,1,1], [1,1,0,0], [1,1,0,1], [1,1,1,0], [1,1,1,1]]) # optional: needs polymake sage: P.vertices() [(1, 0, 0, 0), (1, 0, 0, 1), (1, 0, 1, 0), (1, 0, 1, 1), (1, 1, 0, 0), (1, 1, 0, 1), (1, 1, 1, 0), (1, 1, 1, 1)]rTJ# Worksheet '_scratch_' (2007-01-19 at 15:28) sage: P = polymake.convex_hull([[1,0,0,0], [1,0,0,1], [1,0,1,0], [1,0,1,1], [1,1,0,0], [1,1,0,1], [1,1,1,0], [1,1,1,1]]) # optional: needs polymake sage: P.vertices() [(1, 0, 0, 0), (1, 0, 0, 1), (1, 0, 1, 0), (1, 0, 1, 1), (1, 1, 0, 0), (1, 1, 0, 1), (1, 1, 1, 0), (1, 1, 1, 1)]rTJ# Worksheet '_scratch_' (2007-01-19 at 15:28) sage: P = polymake.convex_hull([[1,0,0,0], [1,0,0,1], [1,0,1,0], [1,0,1,1], [1,1,0,0], [1,1,0,1], [1,1,1,0], [1,1,1,1]]) # optional: needs polymake sage: P.vertices() [(1, 0, 0, 0), (1, 0, 0, 1), (1, 0, 1, 0), (1, 0, 1, 1), (1, 1, 0, 0), (1, 1, 0, 1), (1, 1, 1, 0), (1, 1, 1, 1)]rTJ# Worksheet '_scratch_' (2007-01-19 at 15:28) sage: P = polymake.convex_hull([[1,0,0,0], [1,0,0,1], [1,0,1,0], [1,0,1,1], [1,1,0,0], [1,1,0,1], [1,1,1,0], [1,1,1,1]]) # optional: needs polymake sage: P.vertices() [(1, 0, 0, 0), (1, 0, 0, 1), (1, 0, 1, 0), (1, 0, 1, 1), (1, 1, 0, 0), (1, 1, 0, 1), (1, 1, 1, 0), (1, 1, 1, 1)]rT.# Worksheet '_scratch_' (2007-01-19 at 15:29) sage: L = LatticePolytope(P.vertices()) sage: L Traceback (most recent call last): ... TypeError: Cannot make a polytope from given data! Data: [(1, 0, 0, 0), (1, 0, 0, 1), (1, 0, 1, 0), (1, 0, 1, 1), (1, 1, 0, 0), (1, 1, 0, 1), (1, 1, 1, 0), (1, 1, 1, 1)]rU# Worksheet '_scratch_' (2007-01-19 at 15:29) sage: L = LatticePolytope(matrix(P.vertices())) sage: L A lattice polytope: 8-dimensional, 4 vertices.rU# Worksheet '_scratch_' (2007-01-19 at 15:29) sage: L = LatticePolytope(matrix(P.vertices())) sage: L A lattice polytope: 8-dimensional, 4 vertices.rU# Worksheet '_scratch_' (2007-01-19 at 15:29) sage: L.show() Traceback (most recent call last): ... ValueError: Polytope must have dimension 3!rU# Worksheet '_scratch_' (2007-01-19 at 15:29) sage: L.polar() Traceback (most recent call last): ... ValueError: The given polytope is not reflexive! Polytope: A lattice polytope: 8-dimensional, 4 vertices.rUJ# Worksheet '_scratch_' (2007-01-19 at 15:29) sage: L.is_reflexive() FalserU# Worksheet '_scratch_' (2007-01-19 at 15:30) sage: k = graphs.KrackhardtKiteGraph(); k Krackhardt Kite Graph: a simple graph on 10 verticesrU<# Worksheet '_scratch_' (2007-01-19 at 15:30) sage: show(k) rUf# Worksheet '_scratch_' (2007-01-19 at 15:30) sage: k = graphs.KrackhardtKiteGraph(); k sage: show(k) rU# Worksheet '_scratch_' (2007-01-19 at 15:30) sage: k = graphs.KrackhardtKiteGraph() sage: print k sage: show(k) Krackhardt Kite GraphrT# Worksheet '_scratch_' (2007-01-19 at 15:30) sage: primes_first_n(100) [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521...rU# Worksheet '_scratch_' (2007-01-19 at 15:30) sage: primes_first_n(30) [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113]rU_# Worksheet '_scratch_' (2007-01-19 at 15:30) sage: dimension_cusp_forms(GammaH(13,[1,-3]),2) 0rU_# Worksheet '_scratch_' (2007-01-19 at 15:30) sage: dimension_cusp_forms(GammaH(13,[1,-3]),3) 0rU_# Worksheet '_scratch_' (2007-01-19 at 15:30) sage: dimension_cusp_forms(GammaH(13,[1,-3]),5) 0rUa# Worksheet '_scratch_' (2007-01-19 at 15:30) sage: dimension_cusp_forms(GammaH(13,[1,-3]),10) 19rUY# Worksheet '_scratch_' (2007-01-19 at 15:31) sage: print "Coming soon..." Coming soon...rU# Worksheet '_scratch_' (2007-01-19 at 15:31) sage: print "Coming soon... Will multiply polynomials very quickly." Coming soon... Will multiply polynomials very quickly.rUI# Worksheet '_scratch_' (2007-01-19 at 15:31) sage: gp('version') versionrT# Worksheet '_scratch_' (2007-01-19 at 15:31) sage: gp('version()') Traceback (most recent call last): ... TypeError: Error executing code in GP/PARI: CODE: sage[2]=version(); GP/PARI ERROR: *** unused characters: sage[2]=version(); ^---rU{# Worksheet '_scratch_' (2007-01-19 at 15:31) sage: gp.version() ((2, 3, 1), 'GP/PARI CALCULATOR Version 2.3.1 (released)')rU{# Worksheet '_scratch_' (2007-01-19 at 15:31) sage: gp.version() ((2, 3, 1), 'GP/PARI CALCULATOR Version 2.3.1 (released)')rU# Worksheet '_scratch_' (2007-01-19 at 15:32) sage: m = matrix(QQ,3,range(9)) sage: type(m) rU# Worksheet '_scratch_' (2007-01-19 at 15:33) sage: m = matrix(QQ,3,range(9)) sage: type(m) rU# Worksheet '_scratch_' (2007-01-19 at 15:33) sage: m._multiply_strassen(m) Traceback (most recent call last): ... ValueError: cutoff must be at least 1rU~# Worksheet '_scratch_' (2007-01-19 at 15:33) sage: m._multiply_strassen(m,cutoff=1) [ 15 18 21] [ 42 54 66] [ 69 90 111]rU# Worksheet '_scratch_' (2007-01-19 at 15:33) sage: m = matrix(QQ,10,range(100)) sage: type(m) rT$# Worksheet '_scratch_' (2007-01-19 at 15:33) sage: m._multiply_strassen(m,cutoff=1) [ 2850 2895 2940 2985 3030 3075 3120 3165 3210 3255] [ 7350 7495 7640 7785 7930 8075 8220 8365 8510 8655] [11850 12095 12340 12585 12830 13075 13320 13565 13810 14055] [16350 16695 17040 17385 17730 18075 18420 18765 19110 19455] [20850 21295 21740 22185 22630 23075 23520 23965 24410 24855] [25350 25895 26440 26985 27530 28075 28620 29165 29710 30255] [29850 30495 31140 31785 32430 33075 33720 34365 35010 35655] [34350 35095 35840 36585 3...rUZ# Worksheet '_scratch_' (2007-01-19 at 15:35) sage: import numpy sage: numpy.BUFSIZE 10000rU# Worksheet '_scratch_' (2007-01-19 at 15:35) sage: m = matrix(RR,10,range(100)); type(m) rUh# Worksheet '_scratch_' (2007-01-19 at 15:35) sage: m = matrix(RR,10,range(100)); type(m) sage: n = m*m rUi# Worksheet '_scratch_' (2007-01-19 at 15:35) sage: m = matrix(RDF,10,range(100)); type(m) sage: n = m*m rU# Worksheet '_scratch_' (2007-01-19 at 15:35) sage: m = matrix(RDF,10,range(100)) sage: print type(m) sage: n = m*m rU# Worksheet '_scratch_' (2007-01-19 at 15:36) sage: m = matrix(RDF,10,range(100)) sage: print type(m) sage: n = m*m # uses GSL -- gnu scientific library rUI# Worksheet '_scratch_' (2007-01-19 at 15:37) sage: a = 3; b = Mod(8,13) rUW# Worksheet '_scratch_' (2007-01-19 at 15:38) sage: a = 3; b = Mod(8,13) sage: a * b 11rUw# Worksheet '_scratch_' (2007-01-19 at 15:38) sage: a = 3; b = Mod(8,13) sage: parent(a * b) Ring of integers modulo 13rU# Worksheet '_scratch_' (2007-01-19 at 15:38) sage: a = 3; b = Mod(8,13) sage: parent(a * b), parent(b*a) (Ring of integers modulo 13, Ring of integers modulo 13)rU# Worksheet '_scratch_' (2007-01-19 at 15:39) sage: %sagex sage: v = [i*i for i from 0 <= i < 1000] sage: v[2] += 5 sage: print v[:10] [0, 1, 9, 9, 16, 25, 36, 49, 64, 81]rU# Worksheet '_scratch_' (2007-01-19 at 15:41) sage: def f(x): ... return x^2 + sin(x)*cos(x) ... sage: show(plot(f, 0, 10, hue=0.2)) rU# Worksheet '_scratch_' (2007-01-19 at 15:41) sage: def f(x): ... return x^2 + sin(x)*cos(x) ... sage: show(plot(f, 0, 10, hue=0.7)) rU# Worksheet '_scratch_' (2007-01-19 at 15:41) sage: def f(x): ... return x^2 + sin(x)*cos(x) ... sage: show(plot(f, 0, 2, hue=0.7)) rU# Worksheet '_scratch_' (2007-01-19 at 15:41) sage: def f(x): ... return 1/x + sin(x)*cos(x) ... sage: show(plot(f, 1, 2, hue=0.7)) rU# Worksheet '_scratch_' (2007-01-19 at 15:42) sage: def f(x): ... return zeta(x) + sin(x)*cos(x) ... sage: show(plot(f, -3, 2, hue=0.7)) rU# Worksheet '_scratch_' (2007-01-19 at 15:42) sage: def f(x): ... return x + sin(x)*cos(x) ... sage: show(plot(f, -3, 2, hue=0.7)) rU# Worksheet '_scratch_' (2007-01-19 at 15:42) sage: def f(x): ... return x + sin(x)*cos(x) ... sage: show(plot(f, -3, 2, hue=0.7)) rU# Worksheet '_scratch_' (2007-01-19 at 15:43) sage: def f(x): ... return x + sin(x)*cos(x) ... sage: show(plot(f, -3, 2, hue=0.7)) sage: def f(x,y): ... return cos(x^2 + y^2) ... sage: show(contour_plot(f, (-4, 4), (-4, 4))) rU# Worksheet '_scratch_' (2007-01-19 at 15:43) sage: def f(x): ... return x + sin(x)*cos(x) ... sage: show(plot(f, -3, 2, hue=0.7)) sage: def f(x,y): ... return cos(x^2 + y^2) ... sage: show(contour_plot(f, (-4, 4), (-4, 4), contours=50)) rT# Worksheet '_scratch_' (2007-01-19 at 15:43) sage: def f(x): ... return x + sin(x)*cos(x) ... sage: show(plot(f, -3, 2, hue=0.7)) sage: def f(x,y): ... return cos(x^2 + y^2) ... sage: show(contour_plot(f, (-4, 4), (-4, 4), contours=50, cmap="Spectral")) rT# Worksheet '_scratch_' (2007-01-19 at 15:44) sage: t = Tachyon(xres=512,yres=512, camera_center=(2,0.5,0.5), look_at=(0.5,0.5,0.5), raydepth=4) sage: t.light((4,3,2), 0.2, (1,1,1)) sage: t.texture('t0', ambient=0.1, diffuse=0.9, specular=0.5, opacity=1.0, color=(1.0,0,0)) sage: t.texture('t1', ambient=0.1, diffuse=0.9, specular=0.3, opacity=1.0, color=(0,1.0,0)) sage: t.texture('t2', ambient=0.2, diffuse=0.7, specular=0.5, opacity=0.7, color=(0,0,1.0)) sage: k=0 sage: for i in range(100): ... k += 1 ... t.sphere((random(),random(), random()), random()/10, 't%s'%(k%3)) ... sage: t.save('sage.png') rU# Worksheet '_scratch_' (2007-01-19 at 15:44) sage: qsieve(next_prime(10^22)*next_prime(10^23)) ([10000000000000000000009, 100000000000000000000117], '')r U# Worksheet '_scratch_' (2007-01-19 at 15:44) sage: time qsieve(next_prime(10^22)*next_prime(10^25)) ([10000000000000000000009, 10000000000000000000000013], '') CPU time: 0.02 s, Wall time: 0.81 sr UC# Worksheet '_scratch_' (2007-01-19 at 15:45) sage: import OpenSSL r T{# Worksheet '_scratch_' (2007-01-19 at 15:45) sage: import OpenSSL sage: help(OpenSSL) Help on package OpenSSL: NAME OpenSSL - pyOpenSSL - A simple wrapper around the OpenSSL library FILE /Users/was/s/local/lib/python2.5/site-packages/OpenSSL/__init__.py PACKAGE CONTENTS SSL crypto rand tsafe version DATA __version__ = '0.6' VERSION 0.6r U# Worksheet '_scratch_' (2007-01-19 at 15:45) sage: A = AlphabeticStrings() sage: A.gens() (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z)r U# Worksheet '_scratch_' (2007-01-19 at 15:45) sage: A = AlphabeticStrings() sage: print A.gens() sage: A.0 * A.3^3 (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z) ADDDrU# Worksheet '_scratch_' (2007-01-19 at 15:45) sage: A = AlphabeticStrings() sage: print A.gens() sage: print A.0^2 * A.3^3 (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z) AADDDrU# Worksheet '_scratch_' (2007-01-19 at 15:46) sage: A = AlphabeticStrings() sage: print A.gens() sage: print A.0^2 * A.3^3 (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z) AADDDrT# Worksheet '_scratch_' (2007-01-19 at 15:46) sage: S = AlphabeticStrings() sage: E = SubstitutionCryptosystem(S) sage: E Substitution cryptosystem on Free alphabetic string monoid on A-Z sage: K = S([ 25-i for i in range(26) ]) sage: K ZYXWVUTSRQPONMLKJIHGFEDCBA sage: e = E(K) sage: m = S("THECATINTHEHAT") sage: e(m) GSVXZGRMGSVSZG GSVXZGRMGSVSZGrU# Worksheet '_scratch_' (2007-01-19 at 15:46) sage: ecm.factor(602400691612422154516282778947806249229526581) [45949729863572179, 13109994191499930367061460439]rU# Worksheet '_scratch_' (2007-01-19 at 15:46) sage: time ecm.factor(602400691612422154516282778947806249229526581) [45949729863572179, 13109994191499930367061460439] CPU time: 0.01 s, Wall time: 0.42 srU# Worksheet '_scratch_' (2007-01-19 at 15:46) sage: time ecm.factor(602400691612422154516282778947806249229526581) [45949729863572179, 13109994191499930367061460439] CPU time: 0.01 s, Wall time: 1.64 srU{# Worksheet '_scratch_' (2007-01-19 at 15:48) sage: from sage.calculus.all import * sage: f = sin(x) + cos(2*x) - sin(x)^2 rU# Worksheet '_scratch_' (2007-01-19 at 15:48) sage: from sage.calculus.all import * sage: f = sin(x) + cos(2*x) - sin(x)^2 sage: f.trig_simplify() cos(2*x) + sin(x) + cos(x)^2 - 1rT# Worksheet '_scratch_' (2007-01-19 at 15:49) sage: from sage.calculus.all import * sage: f = sin(x) + cos(2*x) - sin(x)^2 sage: show(f.trig_simplify())
\cos \left( 2 \cdot x \right) + \sin \left( x \right) + \cos \left( x \right)^{2} - 1
rT@# Worksheet '_scratch_' (2007-01-19 at 15:49) sage: from sage.calculus.all import * sage: f = sin(x)*cos(3*x) + cos(2*x) - sin(x)^2 sage: show(f.trig_simplify())
\sin \left( x \right) \cdot \cos \left( 3 \cdot x \right) + \cos \left( 2 \cdot x \right) + \cos \left( x \right)^{2} - 1
rTz# Worksheet '_scratch_' (2007-01-19 at 15:49) sage: from sage.calculus.all import * sage: f = sin(x)*cos(3*x) + cos(2*x) - sin(x)^2 sage: show(f.trig_expand())
\sin \left( x \right) \cdot \cos \left( x \right)^{3} - 3 \cdot \cos \left( x \right) \cdot \sin \left( x \right)^{2} - 2 \cdot \sin \left( x \right)^{2} + \cos \left( x \right)^{2}
rTv# Worksheet '_scratch_' (2007-01-19 at 15:49) sage: from sage.calculus.all import * sage: f = sin(x)*cos(3*x) + cos(2*x) - sin(x)^2 sage: show(f.trig_expand()) sage: show(f.integral(x))
\sin \left( x \right) \cdot \cos \left( x \right)^{3} - 3 \cdot \cos \left( x \right) \cdot \sin \left( x \right)^{2} - 2 \cdot \sin \left( x \right)^{2} + \cos \left( x \right)^{2}
\frac{-1 \cdot \cos \left( 4 \cdot x \right)}{8} + \frac{\sin \left( 2 \cdot x \right)}{2} - \frac{x - \frac{\sin \left( 2 \cdot x \right)}{2}}{2} + \frac{\cos \left( 2 \cdot x \right)}{4}
rU# Worksheet '_scratch_' (2007-01-19 at 15:49) sage: v = vector(CDF,1024,range(1024)) sage: time v.dft() Traceback (most recent call last): ... TypeError: 'sage.rings.integer.Integer' object is not iterablerU# Worksheet '_scratch_' (2007-01-19 at 15:50) sage: v = vector(CDF,range(1024)) sage: time v.dft() Traceback (most recent call last): ... AttributeError: 'sage.modules.complex_double_vector.ComplexDoubleVe' object has no attribute 'dft'rU# Worksheet '_scratch_' (2007-01-19 at 15:50) sage: v = vector(CDF,range(1024)) sage: time w=v.fft() Time: CPU 0.00 s, Wall: 0.00 srU# Worksheet '_scratch_' (2007-01-19 at 15:50) sage: v = vector(CDF,range(2048)) sage: time w=v.fft() Time: CPU 0.00 s, Wall: 0.00 srUf# Worksheet '_scratch_' (2007-01-19 at 15:50) sage: # very matlab like and powerful for a lot of work rU;# Worksheet '_scratch_' (2007-01-19 at 15:53) sage: 2 + 3 5r U# Worksheet '_scratch_' (2007-01-19 at 15:53) sage: jsmath(r'\int_{0}^{2\pi} \frac{\sin(x^2)}{\cos(\theta x)} dx')
\int_{0}^{2\pi} \frac{\sin(x^2)}{\cos(\theta x)} dx
r!T# Worksheet '_scratch_' (2007-01-19 at 15:54) sage: show(maxima('sin(x^2)').integrate(x))
{{\sqrt{\pi}\,\left(\left(\sqrt{2}\,i+\sqrt{2}\right)\,\mathrm{erf} \left({{\left(\sqrt{2}\,i+\sqrt{2}\right)\,x}\over{2}}\right)+\left( \sqrt{2}\,i-\sqrt{2}\right)\,\mathrm{erf}\left({{\left(\sqrt{2}\,i- \sqrt{2}\right)\,x}\over{2}}\right)\right)}\over{8}}
r"U# Worksheet '_scratch_' (2007-01-19 at 16:01) sage: k = graphs.KrackhardtKiteGraph() sage: print k sage: show(k) Krackhardt Kite Graphr#U;# Worksheet '_scratch_' (2007-01-19 at 16:11) sage: 2 + 3 5r$U?# Worksheet '_scratch_' (2007-01-19 at 16:12) sage: 2 + 323 325r%U# Worksheet '_scratch_' (2007-01-19 at 16:12) sage: jsmath(r'\int_{0}^{2\pi} \frac{\sin(x^2)}{\cos(\theta x)} dx')
\int_{0}^{2\pi} \frac{\sin(x^2)}{\cos(\theta x)} dx
r&T# Worksheet '_scratch_' (2007-01-19 at 16:12) sage: show(maxima('sin(x^2)').integrate(x))
{{\sqrt{\pi}\,\left(\left(\sqrt{2}\,i+\sqrt{2}\right)\,\mathrm{erf} \left({{\left(\sqrt{2}\,i+\sqrt{2}\right)\,x}\over{2}}\right)+\left( \sqrt{2}\,i-\sqrt{2}\right)\,\mathrm{erf}\left({{\left(\sqrt{2}\,i- \sqrt{2}\right)\,x}\over{2}}\right)\right)}\over{8}}
r'U# Worksheet '_scratch_' (2007-01-19 at 16:12) sage: wiki() Traceback (most recent call last): ... RuntimeError: You can run only one server per process!r(TJ# Worksheet '_scratch_' (2007-01-19 at 16:19) sage: P = polymake.convex_hull([[1,0,0,0], [1,0,0,1], [1,0,1,0], [1,0,1,1], [1,1,0,0], [1,1,0,1], [1,1,1,0], [1,1,1,1]]) # optional: needs polymake sage: P.vertices() [(1, 0, 0, 0), (1, 0, 0, 1), (1, 0, 1, 0), (1, 0, 1, 1), (1, 1, 0, 0), (1, 1, 0, 1), (1, 1, 1, 0), (1, 1, 1, 1)]r)U# Worksheet '_scratch_' (2007-01-19 at 16:19) sage: L = LatticePolytope(matrix(P.vertices())) sage: L A lattice polytope: 8-dimensional, 4 vertices.r*T# Worksheet '_scratch_' (2007-01-19 at 16:19) sage: L = LatticePolytope(matrix(P.vertices())) sage: L.nef_partitions() Traceback (most recent call last): ... ValueError: The given polytope is not reflexive! Polytope: A lattice polytope: 8-dimensional, 4 vertices.r+Tr# Worksheet '_scratch_' (2007-01-19 at 16:19) sage: L = LatticePolytope(matrix(P.vertices())) sage: L.npoints() Traceback (most recent call last): ... ValueError: Error executing "poly.x -fp" for the given polytope! Polytope: A lattice polytope: 8-dimensional, 4 vertices. Vertices: [1 0 0 0] [1 0 0 1] [1 0 1 0] [1 0 1 1] [1 1 0 0] [1 1 0 1] [1 1 1 0] [1 1 1 1] Output:r,U# Worksheet '_scratch_' (2007-01-19 at 16:21) sage: k = graphs.KrackhardtKiteGraph() sage: print k sage: show(k) Krackhardt Kite Graphr-Un# Worksheet '_scratch_' (2007-01-19 at 16:21) sage: k = graphs.CubeGraph(5) sage: print k sage: show(k) 5-Cuber.Ua# Worksheet '_scratch_' (2007-01-19 at 16:22) sage: dimension_cusp_forms(GammaH(13,[1,-3]),10) 19r/U# Worksheet '_scratch_' (2007-01-19 at 16:24) sage: dimension_cusp_forms(GammaH(13,[1,-3]),10) sage: sloane.A000110 Sequence of Bell numbersr0UH# Worksheet '_scratch_' (2007-01-19 at 16:24) sage: sloane.A000110(5) 52r1UU# Worksheet '_scratch_' (2007-01-19 at 16:24) sage: sloane.A000110(20) 51724158235372r2UX# Worksheet '_scratch_' (2007-01-19 at 16:24) sage: sloane.A000110(23) 44152005855084346r3U# Worksheet '_scratch_' (2007-01-19 at 16:30) sage: m = matrix(QQ,10,range(100)) sage: type(m) r4T# Worksheet '_scratch_' (2007-01-19 at 16:32) sage: m.integer_kernel() Free module of degree 10 and rank 8 over Integer Ring Echelon basis matrix: [ 1 0 0 0 0 0 0 0 -9 8] [ 0 1 0 0 0 0 0 0 -8 7] [ 0 0 1 0 0 0 0 0 -7 6] [ 0 0 0 1 0 0 0 0 -6 5] [ 0 0 0 0 1 0 0 0 -5 4] [ 0 0 0 0 0 1 0 0 -4 3] [ 0 0 0 0 0 0 1 0 -3 2] [ 0 0 0 0 0 0 0 1 -2 1]r5UA# Worksheet '_scratch_' (2007-01-19 at 16:33) sage: import numpy r6U# Worksheet '_scratch_' (2007-01-19 at 16:34) sage: m = matrix(RDF,10,range(100)) sage: print type(m) sage: n = m*m # uses GSL -- gnu scientific library r7U# Worksheet '_scratch_' (2007-01-19 at 16:34) sage: m = matrix(RDF,10,range(100)) sage: print type(m) sage: time n = m*m # uses GSL -- gnu scientific library r8U# Worksheet '_scratch_' (2007-01-19 at 16:35) sage: m = matrix(RDF,10,range(100)) sage: print type(m) sage: time n = m*m Time: CPU 0.00 s, Wall: 0.00 sr9U# Worksheet '_scratch_' (2007-01-19 at 16:35) sage: n=100 sage: m = matrix(RDF,n,range(n^2)) sage: print type(m) sage: time n = m*m Time: CPU 0.00 s, Wall: 0.00 sr:U# Worksheet '_scratch_' (2007-01-19 at 16:35) sage: n=1000 sage: m = matrix(RDF,n,range(n^2)) sage: print type(m) sage: time n = m*m Time: CPU 4.89 s, Wall: 5.40 sr;U# Worksheet '_scratch_' (2007-01-19 at 16:37) sage: a = 3; b = Mod(8,13) sage: parent(a * b), parent(b*a) (Ring of integers modulo 13, Ring of integers modulo 13)r<U# Worksheet '_scratch_' (2007-01-19 at 16:39) sage: %sagex sage: v = [i*i for i from 0 <= i < 1000] sage: v[2] += 5 sage: print v[:10] [0, 1, 9, 9, 16, 25, 36, 49, 64, 81]r=T# Worksheet '_scratch_' (2007-01-19 at 16:46) sage: def f(x): ... return x + sin(x)*cos(x) ... sage: show(plot(f, -3, 2, hue=0.7)) sage: def f(x,y): ... return cos(x^2 + y^2) ... sage: show(contour_plot(f, (-4, 4), (-4, 4), contours=50, cmap="Spectral")) r>T# Worksheet '_scratch_' (2007-01-19 at 16:46) sage: t = Tachyon(xres=512,yres=512, camera_center=(2,0.5,0.5), look_at=(0.5,0.5,0.5), raydepth=4) sage: t.light((4,3,2), 0.2, (1,1,1)) sage: t.texture('t0', ambient=0.1, diffuse=0.9, specular=0.5, opacity=1.0, color=(1.0,0,0)) sage: t.texture('t1', ambient=0.1, diffuse=0.9, specular=0.3, opacity=1.0, color=(0,1.0,0)) sage: t.texture('t2', ambient=0.2, diffuse=0.7, specular=0.5, opacity=0.7, color=(0,0,1.0)) sage: k=0 sage: for i in range(100): ... k += 1 ... t.sphere((random(),random(), random()), random()/10, 't%s'%(k%3)) ... sage: t.save('sage.png') r?Tv# Worksheet '_scratch_' (2007-01-19 at 16:50) sage: from sage.calculus.all import * sage: f = sin(x)*cos(3*x) + cos(2*x) - sin(x)^2 sage: show(f.trig_expand()) sage: show(f.integral(x))
\sin \left( x \right) \cdot \cos \left( x \right)^{3} - 3 \cdot \cos \left( x \right) \cdot \sin \left( x \right)^{2} - 2 \cdot \sin \left( x \right)^{2} + \cos \left( x \right)^{2}
\frac{-1 \cdot \cos \left( 4 \cdot x \right)}{8} + \frac{\sin \left( 2 \cdot x \right)}{2} - \frac{x - \frac{\sin \left( 2 \cdot x \right)}{2}}{2} + \frac{\cos \left( 2 \cdot x \right)}{4}
r@U# Worksheet 'biggraph' (2007-01-19 at 17:43) sage: g = graphs.RandomGNP(30) Traceback (most recent call last): ... TypeError: RandomGNP() takes at least 3 arguments (2 given)rAUD# Worksheet 'tut' (2007-01-19 at 18:11) sage: factor(2007) 3^2 * 223rBU<# Worksheet 'tut' (2007-01-19 at 18:11) sage: 3^2 * 223 2007rCeU_Notebook__defaultsrD}rE(Ucell_output_colorrFU#0000EErGUmax_history_lengthrHMUcell_input_colorrIU#0000000rJUword_wrap_colsrKKPuU_Notebook__default_worksheetrLhVU_Notebook__history_countrMKU_Notebook__worksheet_dirrNUsage_notebook/worksheetsrOU_Notebook__log_serverrPU_Notebook__filenamerQUsage_notebook/nb.sobjrRU_Notebook__server_logrS]rTU_Notebook__next_worksheet_idrUKU_Notebook__kill_idlerVKU_Notebook__systemrWNU_Notebook__show_debugrXU_Notebook__dirrYU sage_notebookrZU_Notebook__authr[U:U_Notebook__colorr\NU_Notebook__object_dirr]Usage_notebook/objectsr^U_default_filenamer_U:/Users/was/talks/2007-01-19-sage/2.0/sage_notebook/nb.sobjr`U_Notebook__splashpageraub.