from research import *
cases={'C480':{'pair':[2148,3206],'first_pivot':3620,'second_pivot':2756},'Actual_fixed_A':{'pair':[4114,3056],'first_pivot':12026,'second_pivot':12026}}
s=begin(507,'Explain successful and fractional endpoint completions','Does the pivot-residue theorem explain the two recorded529 realizations?',cases,['C480 checkpoint; C481 report','C506'])
r={}
for k,v in cases.items():
 a,b=v['first_pivot'],v['second_pivot'];first=[a+E*(x-a) for x in v['pair']];second=[b+E*(x-b) for x in first]
 r[k]={'first':first,'first_mod23':[x%23 for x in first],'second_pivot_mod23':b%23,'second':second,'fractional_parts':[x%1 for x in second],'second_width':abs(second[1]-second[0])}
finish(s,r,'C480’s first endpoints and second pivot all have residue19, so the supplied completion is integral. The fixed12026 trial has first residue22 against pivot20, leaving a common4/23 fraction. Both widths still reach1250. This explains the recorded difference without adding a pivot.',
 'Compare another family where two different Keys produce the same gain: the SP rectangle.',{'C480':r['C480']['second']==[1956,3206],'fraction':r['Actual_fixed_A']['fractional_parts']==[F(4,23)]*2,'widths':all(v['second_width']==1250 for v in r.values())})
