Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

Code Samples

169 views
unlisted
ubuntu2204
# what this does is prevent instances of returning to the element itself or the unit/1 # ex: in Z_3, 2^3=2, 2^(3+1)=1 # d is degree # q is the prime power finite field # we know that the max number of degrees for each variable before looping back is (q-1) because q is the order of the field # the max homogeneous degree is (q-1)*v because each v can tap out at (q-1), so whichever term has ALL variables maxed out will have (q-1) degrees, v times # d = (q-1)^m + r LEQ (q-1)*v # recall C(v,d,l) is the composition function of $d$ degrees over $v$ variables in l length # gotta define a global variable for runnn! # this bad boy will spit out the multiplicity and remainder of d over (q-1) def r(v,d,q): if d > v*(q-1): r = d % q m = (d-r)/q run = False return r, m, run print('The chosen degree,', d ,',is too big for',v, 'variables and',q,'order and cycles your polynomial back to returns a smaller polynomial') print('_____________________________________') # how small? idk im too scared to check lol, i thiunk it depends # tests if "run" is working right #print(run) else: r = d % (q-1) m = (d-r)/(q-1) run = True return r, m, run #tests to see if the run function is doing what its supposed to #print(run) # this system is working, the "run" vari is doing what it needs to # these are true #r(5,15,4) #r(5,8,4) # this is false #r(3,15,4) #print(run) def C(v,d,l= None): if l == None: l = v term = 0 i=0 for i in range(1, min (d,v,l) +1): #z is the number of "0" degrees, for padding purposes z = v-i # first bit is the unpadded, second is multiply by the padding options numiz= binomial (d-1,d-1) *binomial (v,z) #term is number of…terms term=term+numiz print("For", i, "nonzero degrees and", z, "zero degrees, there are", numiz, "terms.") i=i+1 if i == min(d,v,l)+1: print("Using", v, "variables over", d, "degrees and sequence length of", l, ",", term, "is the total number of possible terms using", min(v,l), "variables.") return term # variable length L isn't working yet def C_st(v,d,q,l=None): #this gives the necessary v's and m's and all that good stuff term_val = C(v,d,l) r_val, m_val, run_val = r(v,d,q) if run_val == False: print('I told you it doesnt work!') elif run_val == True: #print(v,m_val,r_val) #currently the "fixed length" thing isn't working so we'll loop back adj_terms = binomial(v,m_val)* term_val print(adj_terms,'is the total number of terms adjusted for cycles!') # the reason this works is because m is defined as the multiplicity of (q-1) living inside of d, and you need to pull ALL of them out or else they wreak havoc # then you get to permute the “maxed out” degrees. Since you have m maxed out variables, you get to choose “m” variables out of “v” to do it # then we do C(v-m,r) because “v-m” is whatever variables that are left that are free, and “r” is the remaining degrees you get to permute around that DON’T hit beyond “q-2” # FUCK YEAHHHHHH #this example will trigger a break because of the degree being too big! #C_st(3,15,5) #C_st(3,21,5) # this example will give some simple combinatorics (degree is nicely small) #C_st(4,3,5) C_st(4,4,2) #C(4,4)
For 1 nonzero degrees and 3 zero degrees, there are 4 terms. For 2 nonzero degrees and 2 zero degrees, there are 6 terms. For 3 nonzero degrees and 1 zero degrees, there are 4 terms. For 4 nonzero degrees and 0 zero degrees, there are 1 terms. Using 4 variables over 4 degrees and sequence length of 4 , 15 is the total number of possible terms using 4 variables. 15 is the total number of terms adjusted for cycles!