Differences between revisions 9 and 68 (spanning 59 versions)
 ⇤ ← Revision 9 as of 2009-01-28 20:21:34 → Size: 29334 Editor: DavidHansen Comment: ← Revision 68 as of 2020-06-14 09:10:48 → ⇥ Size: 48543 Editor: chapoton Comment: fixone Deletions are marked like this. Additions are marked like this. Line 1: Line 1: = Sage Interactions - Number Theory =goto [[interact|interact main page]] Line 5: Line 2: = Integer Factorization === Divisibility Poset ==by William Stein{{{#!sagecell@interactdef _(n=(5..100)):    Poset(([1..n], lambda x, y: y%x == 0) ).show()}}}{{attachment:divposet.png}} Line 8: Line 18: {{{ {{{#!sagecell Line 41: Line 51: g += line([(j*2-len(cur),-i), ((k*2)-len(rows[i-1]),-i+1)], g += line([(j*2-len(cur),-i), ((k*2)-len(rows[i-1]),-i+1)], Line 55: Line 65: == Continued Fraction Plotter ==by William Stein{{{@interactdef _(number=e, ymax=selector([None,5,20,..,400],nrows=2), clr=Color('purple'), prec=[500,1000,..,5000]):    c = list(continued_fraction(RealField(prec)(number))); print c    show(line([(i,z) for i, z in enumerate(c)],rgbcolor=clr),ymax=ymax,figsize=[10,2])}}}{{attachment:contfracplot.png}} More complicated demonstration using Mathematica: http://demonstrations.wolfram.com/FactorTrees/== Factoring an Integer ==by Timothy ClemansSage implementation of the Mathematica demonstration of the same name. http://demonstrations.wolfram.com/FactoringAnInteger/{{{#!sagecell@interactdef _(r=selector(range(0,10000,1000), label='range', buttons=True), n=slider(0,1000,1,2,'n',False)):    if not r and n in (0, 1):        n = 2    s = '$%d = %s$' % (r + n, factor(r + n))    s = s.replace('*', '\\times')    pretty_print(html(s))}}}= Prime Numbers = Line 67: Line 86: {{{@interactdef _(N=(100,(2..2000))):    html("$\pi(x)$ and $x/(\log(x)-1)$ for $x < %s$"%N)    show(plot(prime_pi, 0, N, rgbcolor='red') + plot(x/(log(x)-1), 5, N, rgbcolor='blue')) {{{#!sagecell@interactdef _(N=(100,list(range(2,2000)))):    pretty_print(html(r"$\pi(x)$ and $x/(\log(x)-1)$ for $x < %s$"%N))    show(plot(prime_pi, 0, N, color='red') + plot(x/(log(x)-1), 5, N, color='blue')) Line 75: Line 94: == Computing Generalized Bernoulli Numbers ==by William Stein (Sage-2.10.3){{{@interactdef _(m=selector([1..15],nrows=2), n=(7,(3..10))):    G = DirichletGroup(m)    s = "

First n=%s Bernoulli numbers attached to characters with modulus m=%s

"%(n,m)    s += ''    s += '
$\\chi$Conductor$B_{%s,\chi}$
$%s$
%s%s
' + \           ''.join(''%k for k in [1..n]) + ''    for eps in G.list():        v = ''.join([''%latex(eps.bernoulli(k)) for k in [1..n]])        s += '%s\n'%(             eps, eps.conductor(), v)    s += ''    html(s)}}}{{attachment:bernoulli.png}}== Fundamental Domains of SL_2(ZZ) ==by Robert Miller{{{L = [[-0.5, 2.0^(x/100.0) - 1 + sqrt(3.0)/2] for x in xrange(1000, -1, -1)]R = [[0.5, 2.0^(x/100.0) - 1 + sqrt(3.0)/2] for x in xrange(1000)]xes = [x/1000.0 for x in xrange(-500,501,1)]M = [[x,abs(sqrt(x^2-1))] for x in xes]fundamental_domain = L+M+Rfundamental_domain = [[x-1,y] for x,y in fundamental_domain]@interactdef _(gen = selector(['t+1', 't-1', '-1/t'], nrows=1)):    global fundamental_domain    if gen == 't+1':        fundamental_domain = [[x+1,y] for x,y in fundamental_domain]    elif gen == 't-1':        fundamental_domain = [[x-1,y] for x,y in fundamental_domain]    elif gen == '-1/t':        new_dom = []        for x,y in fundamental_domain:            sq_mod = x^2 + y^2            new_dom.append([(-1)*x/sq_mod, y/sq_mod])        fundamental_domain = new_dom    P = polygon(fundamental_domain)    P.ymax(1.2); P.ymin(-0.1)    P.show()}}}{{attachment:fund_domain.png}}== Computing modular forms ==by William Stein{{{j = 0@interactdef _(N=[1..100], k=selector([2,4,..,12],nrows=1), prec=(3..40),       group=[(Gamma0, 'Gamma0'), (Gamma1, 'Gamma1')]):    M = CuspForms(group(N),k)    print j; global j; j += 1    print M; print '\n'*3    print "Computing basis...\n\n"    if M.dimension() == 0:         print "Space has dimension 0"    else:        prec = max(prec, M.dimension()+1)        for f in M.basis():             view(f.q_expansion(prec))    print "\n\n\nDone computing basis."}}}{{attachment:modformbasis.png}}== Computing the cuspidal subgroup ==by William Stein{{{html('

Cuspidal Subgroups of Modular Jacobians J0(N)

')@interactdef _(N=selector([1..8*13], ncols=8, width=10, default=10)):    A = J0(N)    print A.cuspidal_subgroup()}}}{{attachment:cuspgroup.png}}== A Charpoly and Hecke Operator Graph ==by William Stein{{{# Note -- in Sage-2.10.3; multiedges are missing in plots; loops are missing in 3d plots@interactdef f(N = prime_range(11,400),      p = selector(prime_range(2,12),nrows=1),      three_d = ("Three Dimensional", False)):    S = SupersingularModule(N)    T = S.hecke_matrix(p)    G = Graph(T, multiedges=True, loops=not three_d)    html("

Charpoly and Hecke Graph: Level %s, T_%s

"%(N,p))    show(T.charpoly().factor())    if three_d:        show(G.plot3d(), aspect_ratio=[1,1,1])    else:        show(G.plot(),figsize=7)}}}{{attachment:heckegraph.png}}== Demonstrating the Diffie-Hellman Key Exchange Protocol ==by Timothy Clemans (refereed by William Stein){{{@interactdef diffie_hellman(button=selector(["New example"],label='',buttons=True),     bits=("Number of bits of prime", (8,12,..512))):    maxp = 2^bits    p = random_prime(maxp)    k = GF(p)    if bits>100:        g = k(2)    else:        g = k.multiplicative_generator()    a = ZZ.random_element(10, maxp)    b = ZZ.random_element(10, maxp)    print """

%s-Bit Diffie-Hellman Key Exchange

1. Alice and Bob agree to use the prime number p=%s and base g=%s.
2. Alice chooses the secret integer a=%s, then sends Bob (ga mod p):
%s%s mod %s = %s.
3. Bob chooses the secret integer b=%s, then sends Alice (gb mod p):
%s%s mod %s = %s.
4. Alice computes (gb mod p)a mod p:
%s%s mod %s = %s.
5. Bob computes (ga mod p)b mod p:
%s%s mod %s = %s.
""" % (bits, p, g, a, g, a, p, (g^a), b, g, b, p, (g^b), (g^b), a, p,        (g^ b)^a, g^a, b, p, (g^a)^b)}}}{{attachment:dh.png}}== Plotting an elliptic curve over a finite field =={{{E = EllipticCurve('37a')@interactdef _(p=slider(prime_range(1000), default=389)):    show(E)    print "p = %s"%p    show(E.change_ring(GF(p)).plot(),xmin=0,ymin=0)}}}{{attachment:ellffplot.png}}== Prime Spiral - Square == == Prime Spiral - Square FIXME == Line 240: Line 96: {{{ {{{#!sagecell Line 245: Line 101: REFERENCES: REFERENCES: Line 250: Line 106: Weisstein, Eric W. "Prime-Generating Polynomial." From MathWorld--A Wolfram Web Resource. http://mathworld.wolfram.com/Prime-GeneratingPolynomial.html Weisstein, Eric W. "Prime-Generating Polynomial." From MathWorld--A Wolfram Web Resource. http://mathworld.wolfram.com/Prime-GeneratingPolynomial.html Line 258: Line 114: elif y<0 and -x >= y and y= y and y end: print "WARNING: n is larger than the end value" if start < 1 or end <=start: print("invalid start or end value")    if n > end: print("WARNING: n is larger than the end value") Line 289: Line 145: N = M.copy() N = copy(M) Line 293: Line 149: #These functions return an int based on where the t is located in the spiral #These functions return an int based on where the t is located in the spiral Line 306: Line 162: if n !=0: x_cord, y_cord = find_xy(n, start) #Overrides the user given x and y coordinates if n !=0: x_cord, y_cord = find_xy(n, start) #Overrides the user given x and y coordinates Line 314: Line 170: Line 316: Line 172: #print x_cord, y_cord if show_lines:         for t in [(-size-1)..size+1]: if show_lines:        for t in [(-size-1)..size+1]: Line 320: Line 175: if m.is_pseudoprime(): main_list.add(m) if m.is_pseudoprime(): main_list.add(m) Line 325: Line 180: #This for loop changes the matrix by spiraling out from the center and changing each entry as it goes. It is faster than the find_xy function above. #This for loop changes the matrix by spiraling out from the center and changing each entry as it goes. It is faster than the find_xy function above. Line 327: Line 182: #print x, "=x y=", y, " num =", num Line 330: Line 184: else: x-=1 else: x-=1 Line 332: Line 186: elif county < overcount: elif county < overcount: Line 335: Line 189: else: y-=1 else: y-=1 Line 337: Line 191: else: else: Line 343: Line 197: if not invert and num in main_list: if not invert and num in main_list: Line 351: Line 205: if n != 0:         print '(to go from x,y coords to an n, reset by setting n=0)' if n != 0:        print('(to go from x,y coords to an n, reset by setting n=0)') Line 355: Line 209: #print 'if n =', n, 'then (x,y) =', (x_cord, y_cord)    print '(x,y) =', (x_cord, y_cord), '<=> n =', find_n(x_cord, y_cord, start)    print ' '    print "SW/NE line"    if -y_cord n =', find_n(x_cord, y_cord, start))    print(' ')    print("SW/NE line")    if -y_cord end: print "WARNING: n is greater than end value" Needs fix for show_factors{{{#!sagecell@interactdef polar_prime_spiral(start=1, end=2000, show_factors = false, highlight_primes = false, show_curves=true, n = 0):    #For more information about the factors in the spiral, visit http://www.dcs.gla.ac.uk/~jhw/spirals/index.html by John Williamson.    if start < 1 or end <=start: print("invalid start or end value")    if n > end: print("WARNING: n is greater than end value") Line 387: Line 242: Line 395: Line 250: R = points(list2, alpha = .1) #Faded Composites     else: R = points(list2, alpha = .1) #Faded Composites    else: Line 403: Line 258: R=points(list2, hue = .1, pointsize = p_size) R=points(list2, hue = .1, pointsize = p_size) Line 406: Line 261: print 'n =', factor(n) print('n = {}'.format(factor(n))) Line 414: Line 269: Q = plot(W1+W2+W3+W4, alpha = .1) Q = plot(W1+W2+W3+W4, alpha = .1) Line 417: Line 272: if show_curves: if show_curves: Line 422: Line 277: if n > (floor(sqrt(n)))^2 and n <= (floor(sqrt(n)))^2 + floor(sqrt(n)): if n > (floor(sqrt(n)))^2 and n <= (floor(sqrt(n)))^2 + floor(sqrt(n)): Line 425: Line 280: else: else: Line 428: Line 283: print 'Pink Curve: n^2 +', c            print 'Green Curve: n^2 + n +', c2            def g(m): return (a*m^2+b*m+c); print('Pink Curve: n^2 +', c)            print('Green Curve: n^2 + n +', c2)            def g(m): return (a*m^2+b*m+c); Line 436: Line 291: c= c2; c= c2; Line 446: Line 301: == Quadratic Residue Table == = Modular Forms === Computing modular forms ==by William Stein{{{#!sagecell@interactdef _(N=[1..100], k=selector([2,4,..,12],nrows=1), prec=(3..40),      group=[(Gamma0, 'Gamma0'), (Gamma1, 'Gamma1')]):    M = CuspForms(group(N),k)    print(M)    print('\n' * 3)    print("Computing basis...\n\n")    if M.dimension() == 0:         print("Space has dimension 0")    else:        prec = max(prec, M.dimension() + 1)        for f in M.basis():             view(f.q_expansion(prec))    print("\n\n\nDone computing basis.")}}}{{attachment:modformbasis.png}}== Computing the cuspidal subgroup ==by William Steinncols not working{{{#!sagecellpretty_print(html('

Cuspidal Subgroups of Modular Jacobians J0(N)

'))@interactdef _(N=selector([1..8*13], ncols=8, width=10, default=10)):    A = J0(N)    print(A.cuspidal_subgroup())}}}{{attachment:cuspgroup.png}}== A Charpoly and Hecke Operator Graph ==by William Stein{{{#!sagecell# Note -- in Sage-2.10.3; multiedges are missing in plots; loops are missing in 3d plots@interactdef f(N = prime_range(11,400),      p = selector(prime_range(2,12),nrows=1),      three_d = ("Three Dimensional", False)):    S = SupersingularModule(N)    T = S.hecke_matrix(p)    G = DiGraph(T, multiedges=not three_d)    if three_d:        G.remove_loops()    html("

Charpoly and Hecke Graph: Level %s, T_%s

"%(N,p))    show(T.charpoly().factor())    if three_d:        show(G.plot3d(), aspect_ratio=[1,1,1])    else:        show(G.plot(),figsize=7)}}}{{attachment:heckegraph.png}}= Modular Arithmetic === Quadratic Residue Table FIXME == Line 448: Line 368: {{{ {{{#!sagecell Line 499: Line 419: == Cubic Residue Table == == Cubic Residue Table FIXME == Line 501: Line 421: {{{ {{{#!sagecell Line 519: Line 439: if Mod(a,3)!=0 and Mod(b,3)==0:        return True    else:        return False return Mod(a,3)!=0 and Mod(b,3)==0 Line 557: Line 474: MP += line([(i,0),(i,r)], rgbcolor='black') MP += line([(i,0),(i,r)], rgbcolor='black') Line 560: Line 477: MP += text('$\omega^2$',(i+.5,r-j-.5),rgbcolor='black') MP += text(r'$\omega^2$',(i+.5,r-j-.5),rgbcolor='black') Line 562: Line 479: MP += text('$\omega$',(i+.5,r-j-.5),rgbcolor='black') MP += text(r'$\omega$',(i+.5,r-j-.5),rgbcolor='black') Line 571: Line 488: MP += text('$\pi_1$',(r/2,r+2), rgbcolor='black', fontsize=25)    MP += text('$\pi_2$',(-2.5,r/2), rgbcolor='black', fontsize=25)    html('Symmetry of Primary Cubic Residues mod ' \          + '%d primary primes in $\mathbf Z[\omega]$.'%r) MP += text(r'$\pi_1$',(r/2,r+2), rgbcolor='black', fontsize=25)    MP += text(r'$\pi_2$',(-2.5,r/2), rgbcolor='black', fontsize=25)    pretty_print(html('Symmetry of Primary Cubic Residues mod ' \          + r'%d primary primes in $\mathbf Z[\omega]$.'%r)) Line 580: Line 497: = Cyclotomic Fields = Line 583: Line 502: {{{ {{{#!sagecell Line 632: Line 551: S = circle((0,0),1,rgbcolor='yellow')  \     + line([e_pt,e_gs_pt], rgbcolor='red', thickness=4) \    + line([f_pt,f_gs_pt], rgbcolor='blue', thickness=3) \    + line([ef_pt,ef_gs_pt], rgbcolor='purple',thickness=2) \    + point(e_pt,pointsize=50, rgbcolor='red')  \    + point(f_pt,pointsize=50, rgbcolor='blue') \    + point(ef_pt,pointsize=50,rgbcolor='purple') \    + point(f_gs_pt,pointsize=75, rgbcolor='black') \     + point(e_gs_pt,pointsize=75, rgbcolor='black') \    + point(ef_gs_pt,pointsize=75, rgbcolor='black') \    + point(js_pt,pointsize=100,rgbcolor='green') S = circle((0,0),1,rgbcolor='yellow')    S += line([e_pt,e_gs_pt], rgbcolor='red', thickness=4)    S += line([f_pt,f_gs_pt], rgbcolor='blue', thickness=3)    S += line([ef_pt,ef_gs_pt], rgbcolor='purple',thickness=2)    S += point(e_pt,pointsize=50, rgbcolor='red')    S += point(f_pt,pointsize=50, rgbcolor='blue')    S += point(ef_pt,pointsize=50,rgbcolor='purple')    S += point(f_gs_pt,pointsize=75, rgbcolor='black')    S += point(e_gs_pt,pointsize=75, rgbcolor='black')    S += point(ef_gs_pt,pointsize=75, rgbcolor='black')    S += point(js_pt,pointsize=100,rgbcolor='green') Line 644: Line 563: S += text('$J(%s,%s) = %s$'%(latex2(e),latex2(f),latex(js)), \ S += text('$J(%s,%s) = %s$'%(latex2(e),latex2(f),latex(js)), Line 663: Line 582: {{{ {{{#!sagecell Line 712: Line 631: S = circle((0,0),1,rgbcolor='yellow')  \     + line([e_pt,e_gs_pt], rgbcolor='red', thickness=4) \    + line([f_pt,f_gs_pt], rgbcolor='blue', thickness=3) \    + line([ef_pt,ef_gs_pt], rgbcolor='purple',thickness=2) \    + point(e_pt,pointsize=50, rgbcolor='red')  \    + point(f_pt,pointsize=50, rgbcolor='blue') \    + point(ef_pt,pointsize=50,rgbcolor='purple') \    + point(f_gs_pt,pointsize=75, rgbcolor='black') \     + point(e_gs_pt,pointsize=75, rgbcolor='black') \    + point(ef_gs_pt,pointsize=75, rgbcolor='black') \    + point(js_pt,pointsize=100,rgbcolor='green') S = circle((0,0),1,rgbcolor='yellow')    S += line([e_pt,e_gs_pt], rgbcolor='red', thickness=4)    S += line([f_pt,f_gs_pt], rgbcolor='blue', thickness=3)    S += line([ef_pt,ef_gs_pt], rgbcolor='purple',thickness=2)    S += point(e_pt,pointsize=50, rgbcolor='red')    S += point(f_pt,pointsize=50, rgbcolor='blue')    S += point(ef_pt,pointsize=50,rgbcolor='purple')    S += point(f_gs_pt,pointsize=75, rgbcolor='black')    S += point(e_gs_pt,pointsize=75, rgbcolor='black')    S += point(ef_gs_pt,pointsize=75, rgbcolor='black')    S += point(js_pt,pointsize=100,rgbcolor='green') Line 724: Line 643: S += text('$J(%s,%s) = %s$'%(latex2(e),latex2(f),latex(js)), \ S += text('$J(%s,%s) = %s$'%(latex2(e),latex2(f),latex(js)), Line 727: Line 646: html('$$J(%s,%s) = %s$$'%(latex2(e),latex2(f),latex(js))) pretty_print(html('$$J(%s,%s) = %s$$'%(latex2(e),latex2(f),latex(js)))) Line 736: Line 655: ga[i].save('j%d.PNG'%i,figsize=4,aspect_ratio=1, \ ga[i].save('j%d.png'%i,figsize=4,aspect_ratio=1, Line 742: Line 661: html('') s='' Line 744: Line 663: html('
'%(2*i))        html(''%(2*i+1))    html('') s+='
'%(2*i)        s+=''%(2*i+1)    s+=''    pretty_print(html(s)) Line 750: Line 670: = Elliptic Curves = Line 753: Line 675: {{{ {{{#!sagecell Line 759: Line 681: else: else: Line 766: Line 688: def line_from_curve_points(E,P,Q,style='-',rgb=(1,0,0),length=25): """ P,Q two points on an elliptic curve. Output is a graphic representation of the straight line intersecting with P,Q. """ # The function tangent to P=Q on E if P == Q:  if P[2]==0:   return line([(1,-length),(1,length)],linestyle=style,rgbcolor=rgb)  else:   # Compute slope of the curve E in P   l=-(3*P[0]^2 + 2*E.a2()*P[0] + E.a4() - E.a1()*P[1])/((-2)*P[1] - E.a1()*P[0] - E.a3())   f(x) = l * (x - P[0]) + P[1]   return plot(f(x),-length,length,linestyle=style,rgbcolor=rgb) # Trivial case of P != R where P=O or R=O then we get the vertical line from the other point elif P[2] == 0:  return line([(Q[0],-length),(Q[0],length)],linestyle=style,rgbcolor=rgb) elif Q[2] == 0:  return line([(P[0],-length),(P[0],length)],linestyle=style,rgbcolor=rgb) # Non trivial case where P != R else:  # Case where x_1 = x_2 return vertical line evaluated in Q  if P[0] == Q[0]:   return line([(P[0],-length),(P[0],length)],linestyle=style,rgbcolor=rgb)  #Case where x_1 != x_2 return line trough P,R evaluated in Q"  l=(Q[1]-P[1])/(Q[0]-P[0])  f(x) = l * (x - P[0]) + P[1]  return plot(f(x),-length,length,linestyle=style,rgbcolor=rgb) Line 768: Line 721: curve = E.plot(rgbcolor = (0,0,1),xmin=25,xmax=25,plot_points=300) curve = E.plot(rgbcolor = (0,0,1),xmin=-5,xmax=5,plot_points=300) Line 794: Line 747: def line_from_curve_points(E,P,Q,style='-',rgb=(1,0,0),length=25): """ P,Q two points on an elliptic curve. Output is a graphic representation of the straight line intersecting with P,Q. """ # The function tangent to P=Q on E if P == Q:  if P[2]==0:   return line([(1,-length),(1,length)],linestyle=style,rgbcolor=rgb) }}}{{attachment:PointAddEllipticCurve.png}}== Plotting an elliptic curve over a finite field =={{{#!sagecellE = EllipticCurve('37a')@interactdef _(p=slider(prime_range(1000), default=389)):    show(E)    print("p = %s" % p)    show(E.change_ring(GF(p)).plot(), xmin=0, ymin=0)}}}{{attachment:ellffplot.png}}= Cryptography === The Diffie-Hellman Key Exchange Protocol ==by Timothy Clemans and William Stein{{{#!sagecell@interactdef diffie_hellman(bits=slider(8, 513, 4, 8, 'Number of bits', False),    button=selector(["Show new example"],label='',buttons=True)):    maxp = 2 ^ bits    p = random_prime(maxp)    k = GF(p)    if bits > 100:        g = k(2)    else:        g = k.multiplicative_generator()    a = ZZ.random_element(10, maxp)    b = ZZ.random_element(10, maxp)    pretty_print(html("""

%s-Bit Diffie-Hellman Key Exchange

1. Alice and Bob agree to use the prime number p = %s and base g = %s.
2. Alice chooses the secret integer a = %s, then sends Bob (ga mod p):
%s%s mod %s = %s.
3. Bob chooses the secret integer b=%s, then sends Alice (gb mod p):
%s%s mod %s = %s.
4. Alice computes (gb mod p)a mod p:
%s%s mod %s = %s.
5. Bob computes (ga mod p)b mod p:
%s%s mod %s = %s.
""" % (bits, p, g, a, g, a, p, (g^a), b, g, b, p, (g^b), (g^b), a, p,       (g^ b)^a, g^a, b, p, (g^a)^b)))}}}{{attachment:dh.png}}= Other === Continued Fraction Plotter ==by William Steincrows not working{{{#!sagecell@interactdef _(number=e, ymax=selector([5,20,..,400],nrows=2), clr=Color('purple'), prec=[500,1000,..,5000]):    c = list(continued_fraction(RealField(prec)(number))); print(c)    show(line([(i,z) for i, z in enumerate(c)],rgbcolor=clr),ymax=ymax,figsize=[10,2])}}}{{attachment:contfracplot.png}}== Computing Generalized Bernoulli Numbers ==by William Stein (Sage-2.10.3){{{#!sagecell@interactdef _(m=selector([1..15],nrows=2), n=(7,[3..10])):    G = DirichletGroup(m)    s = r"

First n=%s Bernoulli numbers attached to characters with modulus m=%s

"%(n,m)    s += r''    s += r'
$\chi$Conductor$B_{%s,\chi}$
$%s$
%s%s
' + \           ''.join(r''%k for k in [1..n]) + ''    for eps in G.list():        v = ''.join([''%latex(eps.bernoulli(k)) for k in [1..n]])        s += '%s\n'%(             eps, eps.conductor(), v)    s += ''    pretty_print(html(s))}}}{{attachment:bernoulli.png}}== Fundamental Domains of SL_2(ZZ) ==by Robert Miller{{{#!sagecellL = [[-0.5, 2.0^(x/100.0) - 1 + sqrt(3.0)/2] for x in range(1000, -1, -1)]R = [[0.5, 2.0^(x/100.0) - 1 + sqrt(3.0)/2] for x in range(1000)]xes = [x/1000.0 for x in range(-500,501,1)]M = [[x,abs(sqrt(x^2-1))] for x in xes]fundamental_domain = L+M+Rfundamental_domain = [[x-1,y] for x,y in fundamental_domain]@interactdef _(gen = selector(['t+1', 't-1', '-1/t'], buttons=True,nrows=1)):    global fundamental_domain    if gen == 't+1':        fundamental_domain = [[x+1,y] for x,y in fundamental_domain]    elif gen == 't-1':        fundamental_domain = [[x-1,y] for x,y in fundamental_domain]    elif gen == '-1/t':        new_dom = []        for x,y in fundamental_domain:            sq_mod = x^2 + y^2            new_dom.append([(-1)*x/sq_mod, y/sq_mod])        fundamental_domain = new_dom    P = polygon(fundamental_domain)    P.ymax(1.2); P.ymin(-0.1)    P.show()}}}{{attachment:fund_domain.png}}= Multiple Zeta Values =by Akhilesh P.== Computing Multiple Zeta values ===== Word Input ==={{{#!sagecellR=RealField(10)@interactdef _( weight=(5,(2..100))): n=weight a=[0 for i in range(n-1)] a.append(1) @interact def _(v=('word', input_grid(1, n, default=[a], to_value=lambda x: vector(flatten(x)))), accuracy=(100..100000)):  D=accuracy  a=[v[i] for i in range(len(v))]  DD=int(3.321928*D)+int(R(log(3.321928*D))/R(log(10)))+4  RIF=RealIntervalField(DD)  def Li(word):        n=int(DD*log(10)/log(2))+1        B=[]        L=[]        S=[]        count=-1        k=len(word)        for i in range(k):                B.append(RIF('0'))                L.append(RIF('0'))                if(word[i]==1 and i

# Integer Factorization

by William Stein

## Factor Trees

by William Stein

More complicated demonstration using Mathematica: http://demonstrations.wolfram.com/FactorTrees/

## Factoring an Integer

by Timothy Clemans

Sage implementation of the Mathematica demonstration of the same name. http://demonstrations.wolfram.com/FactoringAnInteger/

# Prime Numbers

by William Stein

by David Runde

## Prime Spiral - Polar

by David Runde

Needs fix for show_factors

# Modular Forms

by William Stein

## Computing the cuspidal subgroup

by William Stein

ncols not working

by William Stein

by Emily Kirkman

by Emily Kirkman

by Emily Kirkman

by Emily Kirkman

# Elliptic Curves

## Adding points on an elliptic curve

by David Møller Hansen

# Cryptography

## The Diffie-Hellman Key Exchange Protocol

by Timothy Clemans and William Stein

# Other

## Continued Fraction Plotter

by William Stein

crows not working

## Computing Generalized Bernoulli Numbers

by William Stein (Sage-2.10.3)

by Robert Miller

# Multiple Zeta Values

by Akhilesh P.

## Shuffle Regularization at 1

interact/number_theory (last edited 2020-06-14 09:10:48 by chapoton)