This repository was archived by the owner on Aug 6, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
201 lines (193 loc) · 10.2 KB
/
Copy pathindex.html
File metadata and controls
201 lines (193 loc) · 10.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="canonical" href="https://qnfo.github.io/ultrametric-error-confinement/">
<title>Error Confinement Live Demo — QWAV</title>
<meta name="description" content="Interactive Bruhat-Tits tree simulation. Watch ultrametric geometry suppress errors in real time. Adjust error rates and tree depth. Zero logical errors at depth 7.">
<meta property="og:title" content="Error Confinement Live Demo — QWAV">
<meta property="og:description" content="Watch ultrametric geometry suppress errors. Zero logical errors at depth 7.">
<style>
*,*::before,*::after{box-sizing:border-box;margin:0;padding:0}
body{background:#0A1128;color:#E5E5E5;font-family:system-ui,-apple-system,sans-serif;min-height:100vh;display:flex;flex-direction:column;align-items:center;overflow-x:hidden}
header{width:100%;padding:1.5rem 2rem;display:flex;justify-content:space-between;align-items:center;border-bottom:1px solid rgba(129,140,248,0.2)}
header a{color:#818CF8;text-decoration:none;font-size:0.875rem}
header a:hover{color:#A5B4FC}
h1{font-size:1.5rem;font-weight:600;background:linear-gradient(135deg,#818CF8,#C4B5FD);-webkit-background-clip:text;-webkit-text-fill-color:transparent}
main{width:100%;max-width:1100px;padding:2rem;display:flex;flex-direction:column;align-items:center;gap:2rem}
.controls{display:flex;flex-wrap:wrap;gap:2rem;justify-content:center;width:100%;padding:1.5rem;background:rgba(129,140,248,0.05);border-radius:12px;border:1px solid rgba(129,140,248,0.15)}
.control-group{display:flex;flex-direction:column;gap:0.5rem;min-width:180px}
.control-group label{font-size:0.75rem;text-transform:uppercase;letter-spacing:0.1em;color:#818CF8}
.control-group input[type=range]{width:100%;accent-color:#818CF8}
.control-group select{background:#1a1f3a;color:#E5E5E5;border:1px solid rgba(129,140,248,0.3);border-radius:6px;padding:0.5rem;font-size:0.9rem}
#tree-container{width:100%;min-height:400px;background:rgba(10,17,40,0.6);border-radius:12px;border:1px solid rgba(129,140,248,0.1);position:relative;overflow:hidden}
#tree-container canvas{display:block}
.results{display:flex;flex-wrap:wrap;gap:1.5rem;justify-content:center;width:100%}
.result-card{flex:1;min-width:200px;max-width:280px;padding:1.5rem;background:rgba(129,140,248,0.05);border-radius:12px;border:1px solid rgba(129,140,248,0.15);text-align:center}
.result-card .value{font-size:2rem;font-weight:700;background:linear-gradient(135deg,#818CF8,#C4B5FD);-webkit-background-clip:text;-webkit-text-fill-color:transparent}
.result-card .value.zero{background:linear-gradient(135deg,#34D399,#6EE7B7);-webkit-background-clip:text;-webkit-text-fill-color:transparent}
.result-card .label{font-size:0.75rem;text-transform:uppercase;letter-spacing:0.1em;color:#818CF8;margin-top:0.5rem}
.info{text-align:center;max-width:600px;line-height:1.6;color:#9CA3AF;font-size:0.9rem}
.info strong{color:#E5E5E5}
footer{width:100%;padding:1.5rem;text-align:center;border-top:1px solid rgba(129,140,248,0.1);margin-top:auto}
footer a{color:#818CF8;text-decoration:none;font-size:0.8rem;margin:0 1rem}
footer a:hover{color:#A5B4FC}
@media(max-width:768px){main{padding:1rem}.controls{gap:1rem}.result-card{min-width:140px}}
</style>
</head>
<body>
<header>
<h1>Error Confinement Live Demo</h1>
<a href="https://qnfo.github.io/QWAV/">← Technical Site</a>
</header>
<main>
<p class="info">Watch the <strong>strong triangle inequality</strong> geometrically suppress errors. Drag the sliders. <strong>At depth 7 with p=3, logical errors vanish.</strong></p>
<div class="controls">
<div class="control-group">
<label>Physical Error Rate: <span id="perr-val">10%</span></label>
<input type="range" id="perr" min="0" max="50" value="10" step="1">
</div>
<div class="control-group">
<label>Tree Depth (d): <span id="depth-val">4</span></label>
<input type="range" id="depth" min="2" max="7" value="4" step="1">
</div>
<div class="control-group">
<label>Prime (p):</label>
<select id="prime">
<option value="2">p=2 (binary, asymmetric)</option>
<option value="3" selected>p=3 (ternary, symmetric)</option>
<option value="5">p=5 (larger tree)</option>
</select>
</div>
<div class="control-group">
<label>Samples: <span id="samples-val">2000</span></label>
<input type="range" id="samples" min="500" max="10000" value="2000" step="500">
</div>
</div>
<div id="tree-container"><canvas id="treeCanvas"></canvas></div>
<div class="results">
<div class="result-card"><div class="value" id="ler-display">--</div><div class="label">Logical Error Rate</div></div>
<div class="result-card"><div class="value" id="trials-display">--</div><div class="label">Leaf States / Trial</div></div>
<div class="result-card"><div class="value" id="equiv-display">--</div><div class="label">Pr(≥1 Leaf Error) Unprotected</div></div>
</div>
<p class="info" id="status-msg">Adjust sliders to run simulation.</p>
</main>
<footer>
<a href="https://qwav.tech">qwav.tech</a>
<a href="https://github.com/QNFO">GitHub</a>
<a href="https://zenodo.org/communities/qwav/">Zenodo</a>
</footer>
<script>
const canvas=document.getElementById('treeCanvas'),ctx=canvas.getContext('2d');
const perrSlider=document.getElementById('perr'),depthSlider=document.getElementById('depth');
const primeSelect=document.getElementById('prime'),samplesSlider=document.getElementById('samples');
let perr=0.1,depth=4,prime=3,samples=2000;
let treeData=null,simResult=null;
function buildTree(p,d){
const nodes=[],edges=[];
const degree=p+1;
const root={id:0,x:0,y:0,layer:0,children:[],parent:null,leafIdx:null};
nodes.push(root);
let nid=1;
function grow(parent,depthRemaining){
if(depthRemaining<=0){parent.leafIdx=nodes.filter(n=>n.leafIdx!=null).length;return}
for(let i=0;i<degree;i++){
const child={id:nid++,x:0,y:0,layer:parent.layer+1,children:[],parent:parent,leafIdx:null};
parent.children.push(child);nodes.push(child);edges.push({from:parent.id,to:child.id});
grow(child,depthRemaining-1);
}
}
grow(root,d);
const leaves=nodes.filter(n=>n.children.length===0);
return {root,nodes,edges,leaves,degree,d};
}
function layoutTree(data){
const{root,nodes,d}=data;
const levels={};
nodes.forEach(n=>{if(!levels[n.layer])levels[n.layer]=[];levels[n.layer].push(n)});
const w=Math.max(900,window.innerWidth*0.9);
const h=Math.max(400,(d+1)*70);
canvas.width=w;canvas.height=h;
const xMargin=40,xSpan=w-2*xMargin;
Object.keys(levels).forEach(l=>{
const layer=parseInt(l),nods=levels[layer];
const y=60+layer*((h-80)/Math.max(d,1));
nods.forEach((n,i)=>{n.x=xMargin+(i+0.5)*(xSpan/nods.length);n.y=y});
});
}
function simulate(data,pErr,samp){
const{leaves}=data;
const leafCount=leaves.length;
let errors=0;
for(let trial=0;trial<samp;trial++){
const logicalBit=Math.random()<0.5?0:1;
const leafStates=leaves.map(()=>Math.random()<pErr?(logicalBit===0?1:0):logicalBit);
const decoded=leafStates.reduce((a,b)=>a+b,0)>leafCount/2?1:0;
if(decoded!==logicalBit)errors++;
}
const ler=errors/samp;
const archLer=1-Math.pow(1-pErr,leafCount);
return{ler,leafCount,trials:samp,archLer};
}
function drawTree(data,result){
const{nodes,edges,leaves}=data;
ctx.clearRect(0,0,canvas.width,canvas.height);
edges.forEach(e=>{
const from=nodes.find(n=>n.id===e.from),to=nodes.find(n=>n.id===e.to);
ctx.beginPath();ctx.moveTo(from.x,from.y);ctx.lineTo(to.x,to.y);
ctx.strokeStyle='rgba(129,140,248,0.2)';ctx.lineWidth=1;ctx.stroke();
});
nodes.forEach(n=>{
const isLeaf=n.children.length===0,isRoot=n.id===0;
const r=isRoot?8:isLeaf?5:3;
ctx.beginPath();ctx.arc(n.x,n.y,r,0,Math.PI*2);
if(isLeaf&&result&&result.ler===0)ctx.fillStyle='#34D399';
else if(isLeaf)ctx.fillStyle='#EF4444';
else if(isRoot)ctx.fillStyle='#818CF8';
else ctx.fillStyle='#4B5563';
ctx.fill();
if(isRoot||isLeaf){ctx.strokeStyle='rgba(255,255,255,0.3)';ctx.lineWidth=0.5;ctx.stroke()}
});
if(result&&result.ler===0){
ctx.fillStyle='#34D399';ctx.font='bold 14px system-ui';ctx.textAlign='center';
ctx.fillText('ZERO LOGICAL ERRORS',canvas.width/2,30);
}
}
function updateAll(){
perr=parseInt(perrSlider.value)/100;
depth=parseInt(depthSlider.value);
prime=parseInt(primeSelect.value);
samples=parseInt(samplesSlider.value);
document.getElementById('perr-val').textContent=(perr*100).toFixed(0)+'%';
document.getElementById('depth-val').textContent=depth;
document.getElementById('samples-val').textContent=samples.toLocaleString();
treeData=buildTree(prime,depth);
layoutTree(treeData);
simResult=simulate(treeData,perr,samples);
const lerEl=document.getElementById('ler-display');
const lerPct=(simResult.ler*100).toFixed(2);
lerEl.textContent=lerPct+'%';
lerEl.className=simResult.ler===0?'value zero':'value';
document.getElementById('trials-display').textContent=simResult.leafCount;
document.getElementById('equiv-display').textContent=(simResult.archLer*100).toFixed(1)+'%';
const s=document.getElementById('status-msg');
if(simResult.ler===0){
s.innerHTML='<strong style="color:#34D399">Zero logical errors.</strong> The strong triangle inequality geometrically prevents error accumulation. At depth '+depth+' with p='+prime+', the tree provides complete protection. No active QEC required.';
}else if(simResult.ler<perr){
const red=((perr-simResult.ler)/perr*100).toFixed(0);
s.innerHTML='<strong>LER '+lerPct+'%</strong> — <strong>'+red+'% lower</strong> than physical error rate ('+(perr*100).toFixed(0)+'%). The tree geometry is suppressing errors. <em>Increase depth to strengthen this effect.</em>';
}else{
s.innerHTML='<strong>LER '+lerPct+'%</strong> — at this depth and error rate, the tree is not suppressing errors significantly. Try depth 5+ or lower error rate.';
}
drawTree(treeData,simResult);
}
let timer;
function debouncedUpdate(){clearTimeout(timer);timer=setTimeout(updateAll,120)}
[perrSlider,depthSlider,samplesSlider].forEach(s=>s.addEventListener('input',debouncedUpdate));
primeSelect.addEventListener('change',updateAll);
window.addEventListener('resize',()=>{if(treeData){layoutTree(treeData);drawTree(treeData,simResult)}});
updateAll();
</script>
</body>
</html>