Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/yang/blob/main/scripts/ReplayDyadicW2.lean # yang This project has not described itself yet. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `yang / scripts / ReplayDyadicW2.lean` 75 lines · 2590 bytes Raw Blame History 1 import DyadicTrig 2 import DyadicExp 3 4 open YangMills.DyadicTrig YangMills.DyadicExp 5 6 structure Cell where 7 cosLo : Int 8 cosHi : Int 9 sinLo : Int 10 sinHi : Int 11 deriving Inhabited 12 13 def angles : Array Cell := (Array.range 2048).map fun i => 14 let sq := sinSqBounds i 15 ⟨(cosBounds 11 (i+1)).1 / 4, ceilDiv (cosBounds 11 i).2 4, 16 sq.1 / `4194304`, ceilDiv sq.2 `4194304`⟩ 17 18 def loMul (x lo hi : Int) := min (x*lo) (x*hi) / q 19 def hiMul (x lo hi : Int) := ceilDiv (max (x*lo) (x*hi)) q 20 21 /-- Independently evaluate the cell sums with arbitrary-precision signed integers. -/ 22 def fieldEnergies (cells : Array Cell) (rl rh : Int) : Int × Int := Id.run do 23 let mut weights : Array (Int × Int) := #[] 24 let mut zl := 0 25 let mut zh := 0 26 let mut ml := 0 27 let mut mh := 0 28 let mut transverse := 0 29 for c in cells do 30 let xl := loMul c.cosLo rl rh 31 let xh := hiMul c.cosHi rl rh 32 let wl := c.sinLo * expLo xl / q 33 let wh := ceilDiv (c.sinHi * expHi xh) q 34 weights := weights.push (wl,wh) 35 zl := zl + wl 36 zh := zh + wh 37 ml := ml + loMul c.cosLo wl wh 38 mh := mh + hiMul c.cosHi wl wh 39 let d := max (-((2*q-hiMul xh c.sinLo c.sinHi)/6)) (ceilDiv (2*q-loMul xl c.sinLo c.sinHi) 6) 40 let a := max (-c.cosLo) c.cosHi 41 let cost := ceilDiv (ceilDiv (a*a) q) 27 + ceilDiv (2*ceilDiv (d*d) q) 3 42 transverse := transverse + ceilDiv (cost*wh) q 43 zl := zl/2048 44 zh := ceilDiv zh 2048 45 ml := ml/2048*q 46 mh := ceilDiv mh 2048*q 47 ml := min (ml/zl) (ml/zh) 48 mh := max (ceilDiv mh zl) (ceilDiv mh zh) 49 let mut energy := 0 50 for side in [:2] do 51 let mut fl := 0 52 let mut fh := 0 53 for j in [:1024] do 54 let i := if side == 0 then j else 2047-j 55 let (wl,wh) := weights[i]! 56 let c := cells[i]! 57 let cl := if side == 0 then c.cosLo-mh else ml-c.cosHi 58 let ch := if side == 0 then c.cosHi-ml else mh-c.cosLo 59 let dl := loMul cl wl wh 60 let dh := hiMul ch wl wh 61 let f := ceilDiv (max (-(fl+min 0 dl)) (fh+max 0 dh)) 2048 62 energy := energy + (if j == 0 then ceilDiv (16*wh) `4194304` else ceilDiv (f*f) wl) 63 fl := fl+dl 64 fh := fh+dh 65 let parallel := ceilDiv (ceilDiv (ceilDiv energy 2048*q) zl * 986961) 100000 66 return (parallel, ceilDiv (ceilDiv transverse 2048*q) zl) 67 68 def main : IO Unit := do 69 let cells := angles 70 for b in ([1000,1272,1500,1800,1900,1950,2000,2200,2400,2450,2500,2600,2750,2800,2830,2880] : List Int) do 71 for k in [:128] do 72 let rl := 6*b*q*k/`1280000` 73 let rh := ceilDiv (6*b*q*(k+1)) `1280000` 74 let (p,s) := fieldEnergies cells rl rh 75 IO.println s!"{b} {k} {p} {s}"