Godtone
Joined 17 December 2020
m →My Python 3 code: added a note about the usage of harmonic subgroups |
→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): | ||
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]) )) | ||
else: | |||
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( | def pval(f, et2, p=None): | ||
if p==None: | if p==None: | ||
p = prime_limit(prime_idx( len( | p = prime_limit(prime_idx( len(f)-1 )) | ||
return sum([ | 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> | ||