Differences between revisions 51 and 54 (spanning 3 versions)
Revision 51 as of 2014-12-20 21:29:37
Size: 41707
Editor: akhi
Comment:
Revision 54 as of 2014-12-20 22:08:03
Size: 45946
Editor: akhi
Comment:
Deletions are marked like this. Additions are marked like this.
Line 1178: Line 1178:
        b=[]
        n=len(a)
        for i in range(n):
                b.append(a[i])
        for j in range(l-1,-1,-1):
                k=0
                for t in range(m+1):
                        for i in range(n):
                                if(a[i][j]== t):
                                        b[k]=a[i]
                                        k=k+1
                for i in range(n):
                        a[i]=b[i]
        return(a)
 b=[]
 n=len(a)
 for i in range(n):
  b.append(a[i])
 for j in range(l-1,-1,-1):
  k=0
  for t in range(m+1):
   for i in range(n):
    if(a[i][j]== t):
     b[k]=a[i]
     k=k+1
  for i in range(n):
   a[i]=b[i]
 return(a)

  def sort1(a,l,m):
 b=[]
 b.append([])
 b.append([])
 n=len(a[0])
 for i in range(n):
  b[0].append(a[0][i])
  b[1].append(a[1][i])
 for j in range(l-1,-1,-1):
  k=0
  for t in range(m+1):
   for i in range(n):
    if(a[0][i][j]== t):
     b[0][k]=a[0][i]
     b[1][k]=a[1][i]
     k=k+1
  for i in range(n):
   a[0][i]=b[0][i]
   a[1][i]=b[1][i]
 return(a)
Line 1193: Line 1215:
        n=len(a)
        b=[]
        b.append(a[0])
        m=[]
        m.append(1)
        c=0
        for i in range(1,n):
                if(a[i]==a[i-1]):
                        m[c]=m[c]+1
                else:
                        b.append(a[i])
                        m.append(1)
                        c=c+1
        return(b,m)
 n=len(a)
 b=[]
 b.append(a[0])
 m=[]
 m.append(1)
 c=0
 for i in range(1,n):
  if(a[i]==a[i-1]):
   m[c]=m[c]+1
  else:
   b.append(a[i])
   m.append(1)
   c=c+1
 return(b,m)


  def count1(a):
 n=len(a[0])
 b=[]
 b.append([])
 b.append([])
 b[0].append(a[0][0])
 b[1].append(a[1][0])
 c=0
 for i in range(1,n):
  if(a[0][i]==a[0][i-1]):
   b[1][c]=b[1][c]+a[1][i]
  else:
   b[0].append(a[0][i])
   b[1].append(a[1][i])
   c=c+1

 return(b)
Line 1235: Line 1276:
        r=[]
        r.append([])
        r.append([])
        t=0
        c=1
        for i in range(len(a)+1):
                if(t==0):
                        b=shuffle(a[:len(a)-i],a[len(a)-i:])
                        for j in range(len(b[0])):
                                r[0].append(b[0][j])
                                r[1].append(b[1][j]*c)
                        c=-c
                        if(i<len(a)):
                                if(a[len(a)-1-i]==1):
                                        t=1
        r=sort1(r,len(a),max(a+[0]))
        r=count1(r)
        rg=[]
        rg.append([])
        rg.append([])
        for i in range(len(r[0])):
                if(r[1][i] is not 0):
                        rg[0].append(r[0][i])
                        rg[1].append(r[1][i])
        return(rg)
  c=Regshuf0(a)
  for i in range(len(c[0])-1):
    if(c[1][i] != 0):
      print c[1][i],"*",c[0][i] ,"+ ",
  if(c[1][len(c[0])-1] != 0):
    print c[1][len(c[0])-1],"*",c[0][len(c[0])-1]


}}}
{{attachment:akhi7.png}}
== Shuffle Regularization at 1 ==
{{{#!sagecell
@interact
def _( w=(2,(2..20))):
 a=[0]
 a=a+[1 for i in range(1,w)]
 import itertools
 #this program gives the list of all binary words of weight n and depth k
 @interact
 def _(v=('word', input_grid(1, w, default=[a], to_value=lambda x: vector(flatten(x))))):
  a=[v[i] for i in range(len(v))]
  def kbits(n, k):
    result = []
    for bits in itertools.combinations(range(n), k):
        s = ['0'] * n
        for bit in bits:
            s[bit] = '1'
        result.append(''.join(s))
    return result
  def sort(a,l,m):
 b=[]
 n=len(a)
 for i in range(n):
  b.append(a[i])
 for j in range(l-1,-1,-1):
  k=0
  for t in range(m+1):
   for i in range(n):
    if(a[i][j]== t):
     b[k]=a[i]
     k=k+1
  for i in range(n):
   a[i]=b[i]
 return(a)

  def sort1(a,l,m):
 b=[]
 b.append([])
 b.append([])
 n=len(a[0])
 for i in range(n):
  b[0].append(a[0][i])
  b[1].append(a[1][i])
 for j in range(l-1,-1,-1):
  k=0
  for t in range(m+1):
   for i in range(n):
    if(a[0][i][j]== t):
     b[0][k]=a[0][i]
     b[1][k]=a[1][i]
     k=k+1
  for i in range(n):
   a[0][i]=b[0][i]
   a[1][i]=b[1][i]
 return(a)

  def count(a):
 n=len(a)
 b=[]
 b.append(a[0])
 m=[]
 m.append(1)
 c=0
 for i in range(1,n):
  if(a[i]==a[i-1]):
   m[c]=m[c]+1
  else:
   b.append(a[i])
   m.append(1)
   c=c+1
 return(b,m)


  def count1(a):
 n=len(a[0])
 b=[]
 b.append([])
 b.append([])
 b[0].append(a[0][0])
 b[1].append(a[1][0])
 c=0
 for i in range(1,n):
  if(a[0][i]==a[0][i-1]):
   b[1][c]=b[1][c]+a[1][i]
  else:
   b[0].append(a[0][i])
   b[1].append(a[1][i])
   c=c+1

 return(b)
  def shuffle(a,b):
        r=len(a)
        s=len(b)
        # Generating an array of strings containing all combinations of weight r+s and depth s
        M=kbits(r+s,s)
        n=len(M)
        a1= []
        for i in range(n):
                a1.append(list(M[i]))
        # The zeroes are replaced by the entries of a and the ones by the entries of b
        a2= []
        for i in range(n):
                a2.append([])
                count0=0
                count1=0
                for j in range(s+r):
                        if(a1[i][j]=='0'):
                                a2[i].append(a[count0])
                                count0=count0+1
                        if(a1[i][j]=='1'):
                                a2[i].append(b[count1])
                                count1=count1+1
        # Reordering in lexicographic order the entries of a2: this is done by first reordering them according to the last digit, then the next to last digit, etc
        a3=sort(a2,r+s,max(a+b+[0]))
        # Getting the same list without repetitions and with multiplicities
        a4=count(a3)
        return(a4)
  def Regshuf1(a):
Line 1242: Line 1436:
   b=shufflenew2.shuffle(a[:len(a)-i],a[len(a)-i:])    b=shuffle(a[:i],a[i:])
Line 1248: Line 1442:
    if(a[len(a)-1-i]==1):     if(a[i]==0):
Line 1250: Line 1444:
 r=sort1.sort(r,len(a),max(a+[0]))
 r=counting2.count(r)
 r=sort1(r,len(a),max(a+[0]))
 r=count1(r)
Line 1260: Line 1454:
  c=Regshuf0(a)   c=Regshuf1(a)
Line 1262: Line 1456:
    print c[1][i],"*",c[0][i] ,"+ ",
  print c[1][len(c[0])-1],"*",c[0][len(c[0])-1]


}}}
{{attachment:akhi6.png}}
    if(c[1][i] != 0):
  
print c[1][i],"*",c[0][i] ,"+ ",
  if(c[1][len(c[0])-1] != 0):
  
print c[1][len(c[0])-1],"*",c[0][len(c[0])-1]


}}}
{{attachment:akhi8.png}}

Integer Factorization

Divisibility Poset

by William Stein

divposet.png

Factor Trees

by William Stein

factortree.png

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

Illustrating the prime number theorem

by William Stein

primes.png

Prime Spiral - Square FIXME

by David Runde

SquareSpiral.PNG

Prime Spiral - Polar

by David Runde

PolarSpiral.PNG

Modular Forms

Computing modular forms

by William Stein

modformbasis.png

Computing the cuspidal subgroup

by William Stein

cuspgroup.png

A Charpoly and Hecke Operator Graph

by William Stein

heckegraph.png

Modular Arithmetic

Quadratic Residue Table FIXME

by Emily Kirkman

quadres.png

quadresbig.png

Cubic Residue Table FIXME

by Emily Kirkman

cubres.png

Cyclotomic Fields

Gauss and Jacobi Sums in Complex Plane

by Emily Kirkman

jacobising.png

Exhaustive Jacobi Plotter

by Emily Kirkman

jacobiexh.png

Elliptic Curves

Adding points on an elliptic curve

by David Møller Hansen

PointAddEllipticCurve.png

Plotting an elliptic curve over a finite field

ellffplot.png

Cryptography

The Diffie-Hellman Key Exchange Protocol

by Timothy Clemans and William Stein

dh.png

Other

Continued Fraction Plotter

by William Stein

contfracplot.png

Computing Generalized Bernoulli Numbers

by William Stein (Sage-2.10.3)

bernoulli.png

Fundamental Domains of SL_2(ZZ)

by Robert Miller

fund_domain.png

Multiple Zeta Values

by Akhilesh P.

Word to composition

akhi2.png

Composition to Word

akhi3.png

Dual of a Word

akhi4.png

Computing Multiple Zeta values

Word Input

akhi1.png

Composition Input

akhi5.png

Shuffle product of two Words

akhi6.png

Shuffle Regularization at 0

akhi7.png

Shuffle Regularization at 1

akhi8.png

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