Differences between revisions 2 and 3
Revision 2 as of 2009-05-19 03:11:50
Size: 2599
Editor: was
Comment:
Revision 3 as of 2017-02-02 02:47:35
Size: 0
Editor: mrennekamp
Comment: lines of code to do ('bern:'). archived by mrennekamp
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:

Oops, this is already in Sage.

Code to do it...


chi-bernoulli
system:sage

From page 656 of Cohen:

{{{id=0|
def S(n,chi):
 return sum(chi(r)*r^n for r in [0..chi.modulus()-1])

def bern(k,chi):
 m = chi.modulus()
 return sum([binomial(k,j) * bernoulli(j)*m^(j-1)*S(k-j,chi) for j
in [0..k]])
///
}}}

{{{id=1|
chi = DirichletGroup(33).1
///
}}}

{{{id=2|
v = [(n,len(str(bern(2*n+1,chi)))) for n in [1..50]]
///
}}}

{{{id=6|
finance.TimeSeries([a for _, a in v]).plot()
///
}}}

{{{id=3|
time chi.bernoulli(97)
///

-1386550730901281655459039291153060660155554359838499623998185825120793577393363680421610680951607498384083291848913360896584699889220142412405950009577924616113546699259811090054434267531175979305388645876564283593414395718/11*zeta10^3
+ 1139018380559996978485536615865491587631736962914990971722815468579216496531837604612620427605357600704292888340343244789306247121665563078738013093738955470092365206329028171332764293574767994686073536165936744981416609102/11*zeta10^2
- 1815995258580769504023108459745030375976990595454787816812259082650991112133850260010917340017496257156415860250825070730584479213960689975366958760972790104039091614348113102193952661883076923857562553616318209769197351882/11*zeta10
+ 1592208039972106215192346184315475058638993887793107974730549965346512172063570657390267817543848692352055390892551815337023626015369750759903577411594239137472016340616541079239824887795689418707971932300648448020408760118/11
CPU time: 4.17 s, Wall time: 4.35 s
}}}

{{{id=4|
time bern(97,chi)
///

-1386550730901281655459039291153060660155554359838499623998185825120793577393363680421610680951607498384083291848913360896584699889220142412405950009577924616113546699259811090054434267531175979305388645876564283593414395718/11*zeta10^3
+ 1139018380559996978485536615865491587631736962914990971722815468579216496531837604612620427605357600704292888340343244789306247121665563078738013093738955470092365206329028171332764293574767994686073536165936744981416609102/11*zeta10^2
- 1815995258580769504023108459745030375976990595454787816812259082650991112133850260010917340017496257156415860250825070730584479213960689975366958760972790104039091614348113102193952661883076923857562553616318209769197351882/11*zeta10
+ 1592208039972106215192346184315475058638993887793107974730549965346512172063570657390267817543848692352055390892551815337023626015369750759903577411594239137472016340616541079239824887795689418707971932300648448020408760118/11
CPU time: 0.22 s, Wall time: 0.22 s
}}}

{{{id=5|

///
}}}