Godtone (talk | contribs)
m My Python 3 code: added a note about the usage of harmonic subgroups
Godtone (talk | contribs)
My Python 3 code: fixed subgroup-related things and corrected a variable name
Line 499: Line 499:
return mul_fact(x, recip_fact(y))
return mul_fact(x, recip_fact(y))
def fact(r, p=None):
def fact(r, p=None):
return (
if p==None:
strip_list_of_right(div_fact( fact_int(r[0]), fact_int(r[1]) ))
return strip_list_of_right(div_fact( fact_int(r[0]), fact_int(r[1]) ))
if p==None else
else:
div_fact( fact_int(r[0],p), fact_int(r[1],p) )
numer = fact_int(r[0],p)
)
denom = fact_int(r[1],p)
if len(numer)>0 and len(denom)>0 and r[0]!=r[1]:
return div_fact(numer,denom)
else:
return []
def unfact(f, p=None):
def unfact(f, p=None):
return unfact_int([max(n,0) for n in f],p), unfact_int([-min(d,0) for d in f],p)
return unfact_int([max(n,0) for n in f],p), unfact_int([-min(d,0) for d in f],p)
Line 551: Line 555:
def ed(equal_divisions, of_n=2):
def ed(equal_divisions, of_n=2):
return math.log(of_n,2)/equal_divisions
return math.log(of_n,2)/equal_divisions
def pval(r, et2, p=None):
def pval(f, et2, p=None):
if p==None:
if p==None:
p = prime_limit(prime_idx( len(r)-1 ))
p = prime_limit(prime_idx( len(f)-1 ))
return sum([ r[i]*round(steps(p[i],et2)) for i in range(len(r)) ])
return sum([ f[i]*round(steps(p[i],et2)) for i in range(len(f)) ])
def consistent_err(x, et2, p=None):
def consistent_err(x, et2, p=None):
return pval(x if type(x)==list else fact(x,p), et2, p) - steps(as_float(x,p),et2)
return pval(x if type(x)==list else fact(x,p), et2, p) - steps(as_float(x,p),et2)
</syntaxhighlight>
</syntaxhighlight>