Download Folding Integral/stabilized-singularity.html from perrabyte/higher-accuracy-integrals: direct link, hf CLI and curl.
- Browser
- Download file 13.6 kB
-
https://huggingface.co/datasets/perrabyte/higher-accuracy-integrals/resolve/main/Folding%20Integral/stabilized-singularity.html
- Command line
-
hf download 'hf://datasets/perrabyte/higher-accuracy-integrals/Folding Integral/stabilized-singularity.html'
-
curl -L -o stabilized-singularity.html https://huggingface.co/datasets/perrabyte/higher-accuracy-integrals/resolve/main/Folding%20Integral/stabilized-singularity.html
13.6 kB
| <html lang="en"> | |
| <head> | |
| <meta charset="utf-8"/> | |
| <meta name="viewport" content="width=device-width,initial-scale=1"/> | |
| <title>Gravity Experiment — Probability Singularity</title> | |
| <style> | |
| :root{--bg:#0b0f14;--panel:#121821;--ink:#e6edf3;--muted:#8b949e;--accent:#58a6ff;--warn:#f85149;--ok:#3fb950;--line:#21262d;--gold:#d29922} | |
| *{box-sizing:border-box} | |
| body{margin:0;background:var(--bg);color:var(--ink);font:14px/1.5 ui-sans-serif,system-ui,sans-serif} | |
| .wrap{max-width:1100px;margin:0 auto;padding:16px} | |
| h1{font-size:20px;margin:0 0 4px} | |
| .sub{color:var(--muted);margin-bottom:12px;font-size:13px} | |
| .grid{display:grid;grid-template-columns:300px 1fr;gap:12px} | |
| @media(max-width:800px){.grid{grid-template-columns:1fr}} | |
| .panel{background:var(--panel);border:1px solid var(--line);border-radius:8px;padding:12px} | |
| .panel h2{font-size:13px;text-transform:uppercase;letter-spacing:.06em;color:var(--muted);margin:0 0 8px} | |
| label{display:block;font-size:12px;color:var(--muted);margin:8px 0 2px} | |
| input[type=range]{width:100%} | |
| .row{display:flex;justify-content:space-between;font-size:12px} | |
| .val{color:var(--accent);font-variant-numeric:tabular-nums} | |
| button{background:#21262d;color:var(--ink);border:1px solid var(--line);border-radius:6px;padding:8px 12px;cursor:pointer;font:inherit;margin:4px 4px 0 0} | |
| button.primary{background:var(--accent);color:#0b0f14;border-color:var(--accent)} | |
| button:hover{filter:brightness(1.15)} | |
| canvas{width:100%;height:260px;display:block;border-radius:6px;background:#0d1117} | |
| .stats{display:grid;grid-template-columns:1fr 1fr;gap:6px;margin-top:8px} | |
| .stat{background:#0d1117;border:1px solid var(--line);border-radius:6px;padding:6px 8px} | |
| .stat .k{color:var(--muted);font-size:11px} | |
| .stat .v{font-size:15px;font-variant-numeric:tabular-nums} | |
| .ok{color:var(--ok)} .bad{color:var(--warn)} .gold{color:var(--gold)} | |
| .log{font-family:ui-monospace,monospace;font-size:11px;color:var(--muted);max-height:160px;overflow:auto;margin-top:8px;background:#0d1117;border:1px solid var(--line);border-radius:6px;padding:6px} | |
| .log div{padding:1px 0} | |
| </style> | |
| </head> | |
| <body> | |
| <div class="wrap"> | |
| <h1>Gravity Experiment — Probability Singularity</h1> | |
| <div class="sub">Probe \(g(x)=a\,\sin(kx+b)/x\). The singularity at \(x=0\) acts as a sensor: it reads local curvature to determine its probability of resolving to \(+\infty\) (blue) or \(-\infty\) (red).</div> | |
| <div class="grid"> | |
| <div class="panel"> | |
| <h2>Parameters</h2> | |
| <label>a (amplitude) <span class="val" id="va">1.00</span></label> | |
| <input type="range" id="a" min="-3" max="3" step="0.05" value="1"/> | |
| <label>k (wavenumber) <span class="val" id="vk">5.00</span></label> | |
| <input type="range" id="k" min="-20" max="20" step="0.1" value="5"/> | |
| <label>b (phase) <span class="val" id="vb">3.14</span></label> | |
| <input type="range" id="b" min="-3.14" max="3.14" step="0.01" value="3.14"/> | |
| <label>window L <span class="val" id="vL">6.00</span></label> | |
| <input type="range" id="L" min="2" max="12" step="0.5" value="6"/> | |
| <label>\(\kappa_{\max}\) (safe cap) <span class="val" id="vkmax">25.0</span></label> | |
| <input type="range" id="kmax" min="1" max="200" step="1" value="25"/> | |
| <label>gravity rate \(\eta\) <span class="val" id="vet">0.02</span></label> | |
| <input type="range" id="et" min="0.001" max="0.1" step="0.001" value="0.02"/> | |
| <div style="margin-top:10px"> | |
| <button class="primary" id="run">Run gravity</button> | |
| <button id="random">Random k,b</button> | |
| <button id="reset">Reset</button> | |
| </div> | |
| <div class="stats"> | |
| <div class="stat"><div class="k">curvature κ</div><div class="v" id="curv">—</div></div> | |
| <div class="stat"><div class="k">P(+) / P(-)</div><div class="v" id="prob">—</div></div> | |
| <div class="stat"><div class="k">safe step h</div><div class="v" id="h">—</div></div> | |
| <div class="stat"><div class="k">status</div><div class="v" id="status">—</div></div> | |
| </div> | |
| <div class="log" id="log"></div> | |
| </div> | |
| <div class="panel"> | |
| <h2>Probe \(g(x)=a\sin(kx+b)/x\)</h2> | |
| <canvas id="c1"></canvas> | |
| <h2 style="margin-top:10px">Curvature \(\kappa\) vs \(k\) (at fixed a,b,L)</h2> | |
| <canvas id="c2"></canvas> | |
| <div style="margin-top:8px;font-size:12px;color:var(--muted)"> | |
| Blue: g(x). The split sphere at x=0 shows the singularity's probability bias based on sensed curvature. | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| <script> | |
| const $ = id => document.getElementById(id); | |
| const canvas = (id) => { | |
| const c=$(id); const r=c.getBoundingClientRect(); | |
| c.width=r.width*devicePixelRatio; c.height=r.height*devicePixelRatio; | |
| return {c,ctx:c.getContext('2d'),w:c.width,h:c.height,dpr:devicePixelRatio}; | |
| }; | |
| function params(){ | |
| return { | |
| a:+$('a').value, k:+$('k').value, b:+$('b').value, | |
| L:+$('L').value, kmax:+$('kmax').value, et:+$('et').value | |
| }; | |
| } | |
| function g(x,p){ | |
| if(Math.abs(x)<1e-6){ | |
| const limit = p.a * p.k * Math.cos(p.b); | |
| if (Math.abs(Math.sin(p.b)) < 1e-5) return limit; | |
| return Math.sign(p.a * Math.sin(p.b)) * 1e5; | |
| } | |
| return p.a*Math.sin(p.k*x+p.b)/x; | |
| } | |
| function curvature(p){ | |
| const N=2000, h= (2*p.L)/N; | |
| let maxg=0, maxg2=0; | |
| for(let i=0;i<=N;i++){ | |
| const x=-p.L+i*h; | |
| if(Math.abs(x) < 0.5) continue; | |
| const gm1=g(x-h,p), g0=g(x,p), gp1=g(x+h,p); | |
| if(!isFinite(g0) || !isFinite(gm1) || !isFinite(gp1)) continue; | |
| const g2=(gp1-2*g0+gm1)/(h*h); | |
| if(!isFinite(g2)) continue; | |
| const av=Math.abs(g0); const av2=Math.abs(g2); | |
| if(av>maxg)maxg=av; | |
| if(av2>maxg2)maxg2=av2; | |
| } | |
| if(maxg<1e-12) return 0; | |
| return maxg2/maxg; | |
| } | |
| // The user's theory: Probability is dependent on the curve's curvature | |
| function getProbability(kappa, p) { | |
| // If the singularity is perfectly stable (sin b = 0), it's a fixed point (not an infinity) | |
| if (Math.abs(Math.sin(p.b)) < 1e-3) return { p_pos: 1, p_neg: 0, isStable: true }; | |
| // Map curvature to a probability bias. Higher curvature = stronger bias. | |
| // The sign of the bias is determined by the direction of the wave (sign of a*sin(b)). | |
| const direction = Math.sign(p.a * Math.sin(p.b)); | |
| const bias = Math.tanh(kappa * 0.05) * direction; | |
| const p_pos = 0.5 + 0.5 * bias; | |
| return { p_pos, p_neg: 1 - p_pos, isStable: false }; | |
| } | |
| function drawProbe(p){ | |
| const {ctx,w,h,dpr}=canvas('c1'); | |
| ctx.scale(dpr,dpr); | |
| const W=w/dpr,H=h/dpr; | |
| ctx.clearRect(0,0,W,H); | |
| const xs=[]; for(let i=0;i<=400;i++) xs.push(-p.L + (2*p.L)*i/400); | |
| const ys=xs.map(x=>g(x,p)); | |
| let ymin=Infinity, ymax=-Infinity; | |
| for(let i=0; i<=400; i++){ | |
| const x = xs[i]; | |
| if (Math.abs(x) < 0.2) continue; | |
| const y = ys[i]; | |
| if(isFinite(y)){ | |
| if(y<ymin) ymin=y; | |
| if(y>ymax) ymax=y; | |
| } | |
| } | |
| if(!isFinite(ymin) || ymax-ymin < 0.01){ ymin=-1; ymax=1; } | |
| const span=Math.max(1e-6,ymax-ymin); | |
| ymin-=span*0.15; ymax+=span*0.15; | |
| let span2=ymax-ymin; | |
| const X=x=> (x+p.L)/(2*p.L)*W; | |
| const Y=y=> H - (y-ymin)/span2*H; | |
| // Grid | |
| ctx.strokeStyle='#21262d'; ctx.lineWidth=1; | |
| ctx.beginPath(); ctx.moveTo(0,Y(0)); ctx.lineTo(W,Y(0)); ctx.stroke(); | |
| ctx.beginPath(); ctx.moveTo(X(0),0); ctx.lineTo(X(0),H); ctx.stroke(); | |
| // Plot Curve | |
| ctx.strokeStyle='#58a6ff'; ctx.lineWidth=2; ctx.beginPath(); | |
| let first=true; | |
| xs.forEach((x,i)=>{ | |
| if(Math.abs(x) < 0.02) { first = true; return; } | |
| const y=ys[i]; | |
| if(!isFinite(y)){first=true;return;} | |
| const px=X(x),py=Y(y); | |
| if(first){ctx.moveTo(px,py);first=false;}else ctx.lineTo(px,py); | |
| }); | |
| ctx.stroke(); | |
| // --- THE PROBABILITY SINGULARITY --- | |
| const kap = curvature(p); | |
| const { p_pos, p_neg, isStable } = getProbability(kap, p); | |
| const cx = X(0), cy = Y(0); | |
| if (isStable) { | |
| // Stable green ring | |
| ctx.fillStyle = 'rgba(63, 185, 80, 0.2)'; | |
| ctx.beginPath(); ctx.arc(cx, cy, 15, 0, Math.PI*2); ctx.fill(); | |
| ctx.strokeStyle = '#3fb950'; ctx.lineWidth = 2; | |
| ctx.beginPath(); ctx.arc(cx, cy, 6, 0, Math.PI*2); ctx.stroke(); | |
| ctx.fillStyle='#3fb950'; ctx.font='bold 11px sans-serif'; | |
| ctx.fillText('STABLE', cx+12, cy-12); | |
| } else { | |
| // Probability Pie Chart | |
| const r = 12; | |
| // Negative probability (Red) | |
| ctx.fillStyle = '#f85149'; | |
| ctx.beginPath(); | |
| ctx.moveTo(cx, cy); | |
| ctx.arc(cx, cy, r, -Math.PI/2, -Math.PI/2 + p_neg * Math.PI*2); | |
| ctx.fill(); | |
| // Positive probability (Blue) | |
| ctx.fillStyle = '#58a6ff'; | |
| ctx.beginPath(); | |
| ctx.moveTo(cx, cy); | |
| ctx.arc(cx, cy, r, -Math.PI/2 + p_neg * Math.PI*2, -Math.PI/2 + Math.PI*2); | |
| ctx.fill(); | |
| // Outer ring | |
| ctx.strokeStyle = '#e6edf3'; ctx.lineWidth = 1.5; | |
| ctx.beginPath(); ctx.arc(cx, cy, r, 0, Math.PI*2); ctx.stroke(); | |
| // Center dot | |
| ctx.fillStyle = '#0d1117'; | |
| ctx.beginPath(); ctx.arc(cx, cy, 2, 0, Math.PI*2); ctx.fill(); | |
| // Label | |
| ctx.fillStyle='#e6edf3'; ctx.font='bold 11px sans-serif'; | |
| ctx.fillText(`P(+)=${(p_pos*100).toFixed(0)}% P(-)=${(p_neg*100).toFixed(0)}%`, cx+16, cy-8); | |
| } | |
| } | |
| function drawKappaVsK(p, traj){ | |
| const {ctx,w,h,dpr}=canvas('c2'); | |
| ctx.scale(dpr,dpr); | |
| const W=w/dpr,H=h/dpr; | |
| ctx.clearRect(0,0,W,H); | |
| const ks=[]; for(let i=0;i<=200;i++) ks.push(-20 + 40*i/200); | |
| const ks2=ks.map(k=>{const pp={...p,k}; return curvature(pp);}); | |
| let ymax=Math.max(...ks2.filter(isFinite)); | |
| if(!isFinite(ymax)||ymax<1)ymax=50; | |
| ymax=Math.min(ymax*1.2, 500); | |
| const X=k=> (k+20)/40*W; | |
| const Y=y=> H - (y/ymax)*H; | |
| // Safe band | |
| ctx.fillStyle='rgba(63,185,80,0.08)'; | |
| ctx.fillRect(0,Y(p.kmax),W,H-Y(p.kmax)); | |
| ctx.strokeStyle='#3fb950'; ctx.lineWidth=1; ctx.setLineDash([4,4]); | |
| ctx.beginPath(); ctx.moveTo(0,Y(p.kmax)); ctx.lineTo(W,Y(p.kmax)); ctx.stroke(); | |
| ctx.setLineDash([]); | |
| // Curve | |
| ctx.strokeStyle='#8b949e'; ctx.lineWidth=1.5; ctx.beginPath(); | |
| let first=true; | |
| ks.forEach((k,i)=>{ | |
| const y=ks2[i]; | |
| if(!isFinite(y)||y>ymax*5){first=true;return;} | |
| const px=X(k),py=Y(Math.min(y,ymax)); | |
| if(first){ctx.moveTo(px,py);first=false;}else ctx.lineTo(px,py); | |
| }); | |
| ctx.stroke(); | |
| // Trajectory | |
| if(traj && traj.length>1){ | |
| ctx.strokeStyle='#f85149'; ctx.lineWidth=2; ctx.beginPath(); | |
| traj.forEach((pt,i)=>{ | |
| const px=X(pt.k), py=Y(Math.min(pt.kappa,ymax)); | |
| if(i===0) ctx.moveTo(px,py); else ctx.lineTo(px,py); | |
| }); | |
| ctx.stroke(); | |
| traj.forEach((pt,i)=>{ | |
| ctx.fillStyle=i===traj.length-1?'#3fb950':'#f85149'; | |
| ctx.beginPath(); ctx.arc(X(pt.k),Y(Math.min(pt.kappa,ymax)),4,0,Math.PI*2); ctx.fill(); | |
| }); | |
| } | |
| const curKappa=curvature(p); | |
| ctx.fillStyle='#58a6ff'; | |
| ctx.beginPath(); ctx.arc(X(p.k),Y(Math.min(curKappa,ymax)),5,0,Math.PI*2); ctx.fill(); | |
| ctx.fillStyle='#8b949e'; ctx.font='11px sans-serif'; | |
| ctx.fillText('κ(k)',8,14); ctx.fillText('safe band',W-70, H-6); | |
| } | |
| function log(msg){ | |
| const d=document.createElement('div'); d.textContent=msg; $('log').prepend(d); | |
| if($('log').childNodes.length > 30) $('log').lastChild.remove(); | |
| } | |
| function update(){ | |
| const p=params(); | |
| $('va').textContent=p.a.toFixed(2); | |
| $('vk').textContent=p.k.toFixed(2); | |
| $('vb').textContent=p.b.toFixed(2); | |
| $('vL').textContent=p.L.toFixed(2); | |
| $('vkmax').textContent=p.kmax.toFixed(1); | |
| $('vet').textContent=p.et.toFixed(3); | |
| const kap=curvature(p); | |
| const { p_pos, p_neg, isStable } = getProbability(kap, p); | |
| $('curv').textContent=isFinite(kap)?kap.toFixed(3):'∞'; | |
| $('h').textContent=isFinite(kap)?(1/Math.sqrt(Math.max(kap,1e-9))).toFixed(4):'0'; | |
| $('prob').textContent = isStable ? 'Stable' : `${(p_pos*100).toFixed(0)}% / ${(p_neg*100).toFixed(0)}%`; | |
| const st = (kap<=p.kmax && isStable) ? 'SAFE' : 'UNSAFE'; | |
| $('status').textContent=st; | |
| $('status').className='v '+(st==='SAFE'?'ok':'bad'); | |
| drawProbe(p); | |
| drawKappaVsK(p,null); | |
| } | |
| let traj=null; | |
| let animId=null; | |
| function runGravity(){ | |
| if(animId) cancelAnimationFrame(animId); | |
| traj=[]; | |
| const p0=params(); | |
| let k=p0.k; | |
| let b=p0.b; | |
| let steps=0; | |
| function step(){ | |
| const pp={...p0,k,b}; | |
| const kap=curvature(pp); | |
| traj.push({k,kappa:kap}); | |
| if(kap<=p0.kmax && Math.abs(Math.sin(b))<0.005){ | |
| log(`step ${steps}: k=${k.toFixed(2)} b=${b.toFixed(2)} STABLE`); | |
| $('k').value=k; $('b').value=b; | |
| update(); | |
| drawKappaVsK(params(),traj); | |
| return; | |
| } | |
| if(kap>p0.kmax){ | |
| const sign = k>=0?1:-1; | |
| k = k - p0.et*sign*(kap-p0.kmax)*0.5; | |
| } | |
| b = b - p0.et * Math.sin(b) * 2.0; | |
| $('k').value=Math.max(-20,Math.min(20,k)); | |
| $('b').value=Math.max(-3.14,Math.min(3.14,b)); | |
| if(steps%5===0) log(`step ${steps}: k=${k.toFixed(2)} b=${b.toFixed(2)} κ=${isFinite(kap)?kap.toFixed(1):'∞'}`); | |
| steps++; | |
| if(steps<100){ | |
| update(); | |
| drawKappaVsK(params(),traj); | |
| animId=requestAnimationFrame(step); | |
| } | |
| } | |
| step(); | |
| } | |
| $('run').addEventListener('click',runGravity); | |
| $('random').addEventListener('click',()=>{ | |
| $('k').value=(Math.random()*40-20).toFixed(1); | |
| $('b').value=(Math.random()*6.28-3.14).toFixed(2); | |
| traj=null; update(); | |
| }); | |
| $('reset').addEventListener('click',()=>{ | |
| if(animId) cancelAnimationFrame(animId); | |
| $('k').value=5; $('b').value=3.14; $('a').value=1; traj=null; update(); | |
| }); | |
| ['a','k','b','L','kmax','et'].forEach(id=>$(id).addEventListener('input',()=>{ | |
| if(animId) cancelAnimationFrame(animId); | |
| traj=null; update(); | |
| })); | |
| window.addEventListener('resize',update); | |
| update(); | |
| </script> | |
| </body> | |
| </html> |