-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathanalysis.mac
More file actions
1874 lines (1688 loc) · 82.1 KB
/
Copy pathanalysis.mac
File metadata and controls
1874 lines (1688 loc) · 82.1 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
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* =====================================================================
analysis.mac
Maxima analysis and proofs for:
"Emergent Fractional Dimensionality and Spinor-Like Holonomy
in Multi-Sheeted n-gon Tilings"
This file generalizes the original pentagon-specific analysis to an
arbitrary regular n-gon (n >= 3). The pentagon (n = 5) case is
preserved as a verification benchmark and is run automatically at
the end of the file.
All computations are performed in exact arithmetic when possible.
For the n = 5 case, the substrate is the real quadratic field
Q(sqrt(5)) (equivalently the maximal real subfield of Q[zeta_5]).
For general n, the substrate is the maximal real subfield of the
cyclotomic field Q[zeta_n], i.e. Q(zeta_n + zeta_n^{-1}) of
degree phi(n)/2 over Q (for n >= 3).
Sections:
0. PARAMETERIZATION (set N_GON here; everything else follows)
1. Golden ratio phi and the field Q(sqrt(5)) [pentagon-specific]
2. Regular n-gon: angles, deficits, excesses [generalized]
3. n-th roots of unity and the cyclotomic field [generalized]
4. Exact rotations in 2D and basis vectors [generalized]
5. Holonomy, sheet transitions, spinor cover [generalized]
6. Emergent dimensions and Alexander-Orbach [n-independent]
7. Cut-and-project: ambient Z^n lattice [generalized]
8. Cellular automaton: regularity and rule count [generalized]
9. n-gon geometry: diagonals, areas, vertices [generalized]
10. Q(sqrt(5))-arithmetic and units [pentagon-specific]
11. Dihedral group D_n and n-gon symmetries [generalized]
12. Volume growth and dimensional flow [n-independent]
13. Graph Laplacian: star and cycle C_n [generalized]
14. Self-tests and summary
===================================================================== */
/* Make all output verbose-friendly. */
if not(?boundp('display2d)) then display2d : false$
/* Load string-handling package (provides pad_right, sconcat utilities). */
load("stringproc")$
/* Load additional packages for enhanced analysis. */
load("eigen")$
print("============================================================")$
print("analysis.mac : Multi-Sheeted n-gon Tiling Analysis")$
print("============================================================")$
/* ---------------------------------------------------------------------
SECTION 0. RANGE PARAMETERIZATION
---------------------------------------------------------------------
Three parameters below define the sweep range. Every n-gon-dependent
section (2-9, 11-13) is executed inside a loop over n = N_GON_MIN,
N_GON_MIN + N_GON_STEP, ..., N_GON_MAX. Pentagon-specific symbolic
checks (Sections 1, 10) are still executed unconditionally once as a
benchmark before the loop.
Quick orientation:
n = 3 : equilateral triangle (6 around vertex tile flat)
n = 4 : square (4 around vertex tile flat)
n = 5 : regular pentagon (3 leave deficit pi/5; original paper)
n = 6 : regular hexagon (3 tile flat; honeycomb)
n = 7 : regular heptagon (3 yield negative-curvature surplus)
n = 8 : regular octagon
n = 12 : regular dodecagon (rich cyclotomic structure)
Floor( 2*pi / interior_angle ) tells how many n-gons fit at a vertex
in flat geometry, and the residual angle gives the deficit/excess
used in the holonomy section.
RANGE CONTROLS (edit these three lines):
--------------------------------------------------------------------- */
N_GON_MIN : 3 $ /* first n-gon in sweep (integer >= 3) */
N_GON_MAX : 12 $ /* last n-gon in sweep (integer >= N_GON_MIN) */
N_GON_STEP : 1 $ /* step size (positive integer) */
/* ---------------------------------------------------------------
ADDITIONAL GLOBAL PARAMETERS
--------------------------------------------------------------- */
/* Inflation / substitution analysis depth (Sections 15, 19). */
INFLATION_DEPTH : 6 $
/* Heat-trace / diffusion kernel time samples (Section 17). */
HEAT_TIMES : [0.01, 0.1, 0.5, 1.0, 2.0, 5.0, 10.0, 50.0] $
/* Zeta function: number of terms in Euler-product approximation (Sec 16). */
ZETA_TERMS : 40 $
/* Acceptance-window sampling resolution (Section 18). */
WINDOW_SAMPLES : 20 $
/* Validate range parameters. */
if not integerp(N_GON_MIN) or N_GON_MIN < 3
then error("N_GON_MIN must be an integer >= 3; got", N_GON_MIN)$
if not integerp(N_GON_MAX) or N_GON_MAX < N_GON_MIN
then error("N_GON_MAX must be >= N_GON_MIN; got", N_GON_MAX)$
if not integerp(N_GON_STEP) or N_GON_STEP < 1
then error("N_GON_STEP must be a positive integer; got", N_GON_STEP)$
print("------------------------------------------------------------")$
print("RANGE PARAMETERIZATION:")$
print(" N_GON_MIN =", N_GON_MIN,
" N_GON_MAX =", N_GON_MAX,
" N_GON_STEP =", N_GON_STEP)$
print("------------------------------------------------------------")$
/* Accumulator for the per-n summary table (populated inside the loop). */
ngon_summary_table : [] $
/* Accumulator for cross-section correlation data (Section 20). */
cross_section_data : [] $
/* ---------------------------------------------------------------------
SECTION 1. Golden ratio phi and Q(sqrt(5)) [pentagon-specific]
---------------------------------------------------------------------
These identities are pentagon-specific; we keep them as exact
symbolic checks so any future code that imports the file can rely
on phi, psi, and their identities. Generalizations to other n
involve different number fields:
n=3,4,6 : Q (degree 1)
n=5,8,10,12 : real quadratic field over Q
n=7,9,11,13,14 : higher-degree real cyclotomic fields
--------------------------------------------------------------------- */
phi : (1 + sqrt(5))/2 $
psi : (1 - sqrt(5))/2 $ /* Galois conjugate of phi */
P1 : ratsimp(phi^2 - (phi + 1)) $
print("[Pentagon] P1: phi^2 - (phi+1) =", P1)$
if P1 # 0 then error("Identity P1 (phi^2 = phi+1) failed")$
P2 : ratsimp(1/phi - (phi - 1)) $
print("[Pentagon] P2: 1/phi - (phi-1) =", P2)$
if P2 # 0 then error("Identity P2 failed")$
P4 : ratsimp(phi*(phi - 1) - 1) $
print("[Pentagon] P4: phi*(phi-1) - 1 =", P4)$
if P4 # 0 then error("Identity P4 failed")$
P6a : ratsimp(phi + psi - 1) $
P6b : ratsimp(phi*psi - (-1)) $
print("[Pentagon] P6a: phi + psi - 1 =", P6a,
" (Vieta: sum of roots of x^2-x-1)")$
print("[Pentagon] P6b: phi*psi + 1 =", P6b,
" (Vieta: product of roots)")$
if P6a # 0 then error("Identity P6a failed")$
if P6b # 0 then error("Identity P6b failed")$
P7 : ratsimp(phi^2 + psi^2 - 3) $
print("[Pentagon] P7: phi^2 + psi^2 - 3 =", P7,
" (trace of phi^2 in Q(sqrt 5))")$
if P7 # 0 then error("Identity P7 failed")$
minpoly_phi(x) := x^2 - x - 1 $
print("[Pentagon] Minimal polynomial of phi:", minpoly_phi(x),
" value at phi:", ratsimp(minpoly_phi(phi)),
", value at psi:", ratsimp(minpoly_phi(psi)))$
if ratsimp(minpoly_phi(phi)) # 0
then error("Minimal polynomial check failed for phi")$
if ratsimp(minpoly_phi(psi)) # 0
then error("Minimal polynomial check failed for psi")$
qsqrt5(a, b) := a + b*sqrt(5) $
qconj(z) := subst(-sqrt(5), sqrt(5), z) $
qnorm(z) := ratsimp(z * qconj(z)) $
qtrace(z) := ratsimp(z + qconj(z)) $
print("[Pentagon] qnorm(phi) =", qnorm(phi), " (expected -1)")$
if qnorm(phi) # -1 then error("Norm of phi expected to be -1")$
print("[Pentagon] qtrace(phi) =", qtrace(phi), " (expected 1)")$
if qtrace(phi) # 1 then error("Trace of phi expected to be 1")$
print("[Pentagon] Fibonacci-phi identity check (phi^n = F_n phi + F_{n-1}):")$
for nn:2 thru 8 do block(
[lhs, rhs, diff_val],
lhs : expand(phi^nn),
rhs : fib(nn)*phi + fib(nn-1),
diff_val : ratsimp(lhs - rhs),
print(" n =", nn, ": diff =", diff_val),
if diff_val # 0 then error("Fibonacci-phi identity failed at n =", nn))$
print("[Pentagon] Binet formula check F_n = (phi^n - psi^n)/sqrt(5):")$
for nn:1 thru 8 do block(
[binet, diff_val],
binet : ratsimp((phi^nn - psi^nn)/sqrt(5)),
diff_val : ratsimp(binet - fib(nn)),
print(" n =", nn, ": F_n =", fib(nn), ", Binet =", binet,
", diff =", diff_val),
if diff_val # 0 then error("Binet identity failed at n =", nn))$
/* ===================================================================
HELPER FUNCTIONS (defined once, used inside the loop)
=================================================================== */
/* General formulas as functions of n. */
interior_angle_ngon(n) := (n - 2)*%pi / n $
exterior_angle_ngon(n) := 2*%pi / n $
sum_interior_ngon(n) := (n - 2)*%pi $
/* Rotation matrix by 2*pi/n. */
Rn_general(n) := matrix(
[cos(2*%pi/n), -sin(2*%pi/n)],
[sin(2*%pi/n), cos(2*%pi/n)]) $
/* Vertex angle for vertex k of a regular n-gon (vertex 0 at top). */
vertex_angle_ngon(n, k) := %pi/2 + 2*%pi*k/n $
/* Holonomy helpers. */
holonomy_Zn(transitions, n) :=
mod(lreduce("+", transitions, 0), n) $
order_Zn(g, n) := block([gg:mod(g, n), result],
if gg = 0 then return(1),
result : catch(
for k:1 thru n do
if mod(k*gg, n) = 0 then throw(k),
n),
result) $
/* Alexander-Orbach spectral dimension. */
d_spec_AO(d_eff, d_w) := 2 * d_eff / d_w $
/* Cyclic shift matrix. */
cyclic_shift_n(n) := genmatrix(
lambda([i, j], if mod(j - i, n) = 1 then 1 else 0),
n, n) $
/* CA rule-count formulas. */
num_outer_tot_rules(k) := 2^(2*(k+1)) $
num_tot_rules(k) := 2^(k+2) $
num_general_rules(k) := 2^(2^(k+1)) $
num_outer_tot_rules_q(k,q) := q^(q * (k*(q-1) + 1)) $
/* Polygon geometry (unit side). */
circumradius_ngon(n) := 1/(2*sin(%pi/n)) $
apothem_ngon(n) := 1/(2*tan(%pi/n)) $
area_ngon(n) := (n/4) * cot(%pi/n) $
diagonal_ngon(n, k) := sin(k*%pi/n)/sin(%pi/n) $
/* Acceptance-window helper. */
in_acceptance_window(pperp, rho) :=
is(pperp . transpose(pperp) <= rho^2) $
/* Dimensional-flow interpolator. */
d_spec_flow(d_uv, d_ir, t, t0) :=
d_ir + (d_uv - d_ir) * exp(-t/t0) $
/* n-independent Alexander-Orbach checks (run once before the loop). */
print("------------------------------------------------------------")$
print("Emergent-dimension framework (n-independent, run once):")$
cond : ratsimp(d_spec_AO(d_eff, 2) - d_eff) $
print(" d_spec(d_eff, d_w=2) - d_eff =", cond,
" (d_w=2 saturates Alexander-Orbach)")$
if cond # 0 then error("Alexander-Orbach saturation failed")$
dspec_deriv_dw : diff(d_spec_AO(d_eff, d_w), d_w) $
dspec_deriv_deff : diff(d_spec_AO(d_eff, d_w), d_eff) $
print(" d/d(d_w) d_spec =", dspec_deriv_dw)$
print(" d/d(d_eff) d_spec =", dspec_deriv_deff)$
msd_exponent(d_w) := 2 / d_w $
p0_exponent(d_spec) := d_spec / 2 $
print(" MSD exponent 2/d_w at d_w=2.5 =", float(msd_exponent(2.5)))$
print(" P_0(t) decay exponent d_spec/2 at d_spec=1.5 =",
float(p0_exponent(1.5)))$
test_dims(d_eff_val, d_w_val) :=
block([d_s],
d_s : float(d_spec_AO(d_eff_val, d_w_val)),
print(" d_eff=", d_eff_val, " d_w=", d_w_val,
" => d_spec=", d_s,
if d_s < d_eff_val then " (sub-diffusive)"
else " (not sub-diffusive)"),
d_s) $
print("Dimension sanity table:")$
test_dims(2.5, 2.0) $
test_dims(2.5, 2.5) $
test_dims(2.5, 3.0) $
test_dims(2.8, 3.2) $
test_dims(2.2, 2.4) $
sier_deff : log(3)/log(2) $
sier_dw : log(5)/log(2) $
sier_dspec : float(d_spec_AO(sier_deff, sier_dw)) $
print("Sierpinski-gasket reference: d_eff=",
float(sier_deff), " d_w=", float(sier_dw),
" d_spec=", sier_dspec)$
in_paper_regime(d_eff_val, d_w_val) :=
is(d_eff_val > 2) and is(d_eff_val < 3)
and is(d_w_val > 2)
and is(float(d_spec_AO(d_eff_val, d_w_val)) < d_eff_val) $
print("in_paper_regime(2.5, 2.4) =", in_paper_regime(2.5, 2.4),
" (true expected)")$
print("in_paper_regime(2.0, 2.0) =", in_paper_regime(2.0, 2.0))$
print("in_paper_regime(2.5, 1.9) =", in_paper_regime(2.5, 1.9))$
print("in_paper_regime(3.1, 2.5) =", in_paper_regime(3.1, 2.5))$
print("Dimensional flow d_spec(t) interpolator (UV=2.5, IR=1.7):")$
for tt in [0.1, 1, 10, 100] do
print(" t =", tt,
": d_spec(t) =", float(d_spec_flow(2.5, 1.7, tt, 10))) $
/* ---------------------------------------------------------------
EXTENDED ALEXANDER-ORBACH ANALYSIS
--------------------------------------------------------------- */
print("------------------------------------------------------------")$
print("Extended Alexander-Orbach / spectral-dimension analysis:")$
/* Full (d_eff, d_w) phase diagram on a grid. */
print(" Phase diagram: d_spec = 2*d_eff/d_w on grid")$
print(" (rows = d_eff 1.5..3.5 step 0.5; cols = d_w 1.5..4.0 step 0.5)")$
block([deff_vals, dw_vals, header, sep],
deff_vals : [1.5, 2.0, 2.5, 3.0, 3.5],
dw_vals : [1.5, 2.0, 2.5, 3.0, 3.5, 4.0],
header : pad_right("d_eff\\d_w", 12),
for dw in dw_vals do header : sconcat(header, " | ", pad_right(string(dw), 7)),
print(" ", header),
sep : " ------------",
for dw in dw_vals do sep : sconcat(sep, "-+---------"),
print(sep),
for deff in deff_vals do block(
[row],
row : pad_right(string(deff), 12),
for dw in dw_vals do block(
[ds],
ds : float(d_spec_AO(deff, dw)),
row : sconcat(row, " | ", pad_right(string(ds), 7))),
print(" ", row))) $
/* Anomalous diffusion classification. */
classify_diffusion(d_w) :=
if d_w < 2 then "super-diffusive"
else if d_w = 2 then "normal"
else "sub-diffusive (anomalous)" $
print(" Diffusion classification by d_w:")$
for dw in [1.5, 2.0, 2.5, 3.0, 4.0] do
print(" d_w =", dw, "->", classify_diffusion(dw)) $
/* Spectral dimension from return probability exponent. */
/* P_0(t) ~ t^{-d_s/2} => log P_0 / log t = -d_s/2 */
print(" Return-probability log-log slope (d_s/2) for d_s in {1.0..2.5}:")$
for ds in [1.0, 1.2, 1.5, 1.7, 2.0, 2.5] do
print(" d_s =", ds, " slope =", -ds/2,
" P_0(t=100) =", float(100^(-ds/2))) $
/* Crossover scale: when does UV regime end? */
/* d_spec(t) crosses d_eff at t = t_cross where exp(-t/t0) = (d_eff-d_ir)/(d_uv-d_ir) */
t_crossover(d_uv, d_ir, d_eff_val, t0) :=
if d_uv = d_ir then inf
else -t0 * log((d_eff_val - d_ir)/(d_uv - d_ir)) $
print(" Crossover times (UV=2.5, IR=1.7, t0=10):")$
for deff in [1.8, 2.0, 2.2, 2.4] do
print(" d_eff =", deff, " t_cross =",
float(t_crossover(2.5, 1.7, deff, 10))) $
/* Integrated spectral weight. */
/* integral_0^Lambda rho(lambda) d lambda = d_spec/2 * integral lambda^{d_s/2-1} */
dos_integral(lam_max, B, d_spec) :=
B * lam_max^(d_spec/2) / (d_spec/2) $
print(" DOS integrated weight (B=1, d_s=1.7, Lambda=1) =",
float(dos_integral(1.0, 1.0, 1.7))) $
print(" DOS integrated weight (B=1, d_s=2.0, Lambda=1) =",
float(dos_integral(1.0, 1.0, 2.0))) $
/* Volume-growth and MSD models (n-independent, run once). */
print("------------------------------------------------------------")$
print("Volume-growth and MSD models (n-independent, run once):")$
synthetic_volume(r, c, d) := c * r^d $
sample_radii : makelist(rr, rr, 1, 10) $
sample_volumes : map(lambda([rr], float(synthetic_volume(rr, 2.5, 2.5))),
sample_radii) $
print(" Sample r :", sample_radii)$
print(" Sample V(r) :", sample_volumes)$
log_slope : float((log(sample_volumes[10]) - log(sample_volumes[1]))
/ (log(10) - log(1))) $
print(" Recovered slope:", log_slope, " (expected 2.5)")$
if abs(log_slope - 2.5) > 1.0e-10
then error("Slope recovery failed")$
msd_model(t, D_alpha, d_w) := D_alpha * t^(2/d_w) $
print(" MSD model (D=1, d_w=2.5):")$
for tt in [1, 10, 100, 1000] do
print(" t =", tt, ": MSD =", float(msd_model(tt, 1, 2.5))) $
p0_model(t, A, d_spec) := A * t^(-d_spec/2) $
print(" P_0(t) model (A=1, d_spec=1.7):")$
for tt in [1, 10, 100, 1000] do
print(" t =", tt, ": P_0 =", float(p0_model(tt, 1, 1.7))) $
dos_model(lam, B, d_spec) := B * lam^(d_spec/2 - 1) $
print(" DOS model (B=1, d_spec=1.7):")$
for lam in [0.001, 0.01, 0.1, 1] do
print(" lambda =", lam, ": rho =", float(dos_model(lam, 1, 1.7))) $
/* ---------------------------------------------------------------
EXTENDED VOLUME-GROWTH ANALYSIS
--------------------------------------------------------------- */
print("------------------------------------------------------------")$
print("Extended volume-growth analysis (n-independent):")$
/* Multi-scale volume growth: compare d_eff = 2.0, 2.5, 3.0 */
print(" V(r) = c * r^d_eff for d_eff in {2.0, 2.5, 3.0}, c=1:")$
for deff in [2.0, 2.5, 3.0] do block(
[vols],
vols : map(lambda([rr], float(synthetic_volume(rr, 1.0, deff))),
[1, 2, 5, 10, 20, 50, 100]),
print(" d_eff =", deff, ": V(r) =", vols)) $
/* Ratio V(2r)/V(r) = 2^d_eff (self-similarity). */
print(" Self-similarity ratio V(2r)/V(r) = 2^d_eff:")$
for deff in [1.5, 2.0, 2.5, 3.0] do
print(" d_eff =", deff, " ratio =", float(2^deff)) $
/* Effective dimension from two-point volume ratio. */
d_eff_from_ratio(V1, V2, r1, r2) :=
log(V2/V1) / log(r2/r1) $
print(" Recovered d_eff from V(5)/V(1) with true d_eff=2.5:",
float(d_eff_from_ratio(
synthetic_volume(1, 1.0, 2.5),
synthetic_volume(5, 1.0, 2.5), 1, 5))) $
print(" Recovered d_eff from V(10)/V(2) with true d_eff=2.5:",
float(d_eff_from_ratio(
synthetic_volume(2, 1.0, 2.5),
synthetic_volume(10, 1.0, 2.5), 2, 10))) $
/* Lacunarity: variance of V(r) over random sub-windows. */
/* Lacunarity Lambda = (sigma_V / mu_V)^2; for self-similar sets Lambda ~ r^{-d_eff} */
lacunarity_model(r, d_eff_val) := r^(-d_eff_val) $
print(" Lacunarity model Lambda(r) = r^{-d_eff} (d_eff=2.5):")$
for rr in [1, 2, 5, 10, 20] do
print(" r =", rr, " Lambda =", float(lacunarity_model(rr, 2.5))) $
/* Multifractal spectrum: f(alpha) = d_eff for monofractal. */
/* For a monofractal, the Legendre transform of tau(q) = (q-1)*d_eff gives */
/* f(alpha) = d_eff at alpha = d_eff, zero elsewhere. */
tau_q_monofractal(q, d_eff_val) := (q - 1) * d_eff_val $
alpha_q_monofractal(q, d_eff_val) := d_eff_val $ /* d tau/d q */
f_alpha_monofractal(alpha, d_eff_val) :=
if alpha = d_eff_val then d_eff_val else 0 $
print(" Monofractal tau(q) = (q-1)*d_eff (d_eff=2.5):")$
for q in [-2, -1, 0, 1, 2, 3] do
print(" q =", q, " tau(q) =", float(tau_q_monofractal(q, 2.5))) $
/* Z_2 spinor checks (n-independent, run once). */
print("------------------------------------------------------------")$
print("Spinor / holonomy checks (Z_2, n-independent, run once):")$
print("[Spinor case G = Z_2]:")$
print(" single-loop holonomy =", holonomy_Zn([1], 2),
" (expected 1, i.e. tau = -1)")$
if holonomy_Zn([1], 2) # 1 then error("Z2 holonomy failed")$
print(" double-loop holonomy =", holonomy_Zn([1,1], 2),
" (expected 0)")$
if holonomy_Zn([1,1], 2) # 0 then error("Z2 double-loop holonomy failed")$
print(" spinor loop order =", order_Zn(1, 2),
" (expected 2 -- double cover)")$
if order_Zn(1, 2) # 2 then error("Z2 spinor order != 2")$
/* ---------------------------------------------------------------
EXTENDED HOLONOMY / FLAT-BUNDLE ANALYSIS (n-independent)
--------------------------------------------------------------- */
print("------------------------------------------------------------")$
print("Extended flat-bundle / holonomy analysis (n-independent):")$
/* Holonomy group structure for Z_m covers. */
print(" Holonomy groups Z_m for m = 2..12:")$
for m : 2 thru 12 do block(
[gens, orders],
gens : makelist(gg, gg, 0, m-1),
orders : map(lambda([gg], order_Zn(gg, m)), gens),
print(" Z_", m, ": generators and orders =",
map(list, gens, orders))) $
/* Flat U(1) holonomy: phase accumulated around a vortex. */
/* For a Z_n vortex, the holonomy phase is exp(2 pi i k / n). */
flat_U1_holonomy(k, n) := exp(2*%pi*%i*k/n) $
print(" Flat U(1) holonomy phases exp(2 pi i k/n) for n=5:")$
for k : 0 thru 4 do
print(" k =", k, ": phase =",
rectform(flat_U1_holonomy(k, 5)),
" ~ (", float(realpart(flat_U1_holonomy(k,5))),
",", float(imagpart(flat_U1_holonomy(k,5))), ")") $
/* Aharonov-Bohm phase: flux Phi through vortex, holonomy = exp(2 pi i Phi/Phi_0). */
AB_phase(flux_ratio) := exp(2*%pi*%i*flux_ratio) $
print(" Aharonov-Bohm phases for flux/flux_0 in {0, 1/5, 2/5, 3/5, 4/5, 1}:")$
for fr in [0, 1/5, 2/5, 3/5, 4/5, 1] do
print(" Phi/Phi_0 =", fr, ": phase =",
float(realpart(AB_phase(fr))), "+",
float(imagpart(AB_phase(fr))), "i") $
/* Monodromy matrix for a 2D representation of Z_n. */
monodromy_2D(n) := matrix(
[cos(2*%pi/n), -sin(2*%pi/n)],
[sin(2*%pi/n), cos(2*%pi/n)]) $
print(" Monodromy matrices for n = 3, 4, 5, 6:")$
for n_m in [3, 4, 5, 6] do block(
[M, Mk, found_k],
M : monodromy_2D(n_m),
print(" n =", n_m, ": M =",
matrix([float(M[1,1]), float(M[1,2])],
[float(M[2,1]), float(M[2,2])])),
/* Find smallest k with M^k = I */
Mk : ident(2),
found_k : -1,
for k : 1 thru 2*n_m do block(
Mk : Mk . M,
if found_k < 0 and
abs(float(trigsimp(Mk[1,1])) - 1) < 1e-10 and
abs(float(trigsimp(Mk[1,2]))) < 1e-10 and
abs(float(trigsimp(Mk[2,1]))) < 1e-10 and
abs(float(trigsimp(Mk[2,2])) - 1) < 1e-10
then found_k : k),
print(" M^k = I first at k =", found_k, " (expected", n_m, ")")) $
/* Berry phase for a closed loop in parameter space. */
/* For a 2-level system with gap Delta, Berry phase = pi * winding_number. */
berry_phase(winding) := %pi * winding $
print(" Berry phases for winding numbers 0..4:")$
for w : 0 thru 4 do
print(" w =", w, ": gamma_B =", float(berry_phase(w)),
" = ", w, "* pi") $
/* Chern number from holonomy: C = (1/2pi) * integral of Berry curvature. */
/* For Z_n holonomy, C = k/n for the k-th sector. */
chern_number(k, n) := k/n $
print(" Chern numbers for Z_5 sectors k = 0..4:")$
for k : 0 thru 4 do
print(" k =", k, ": C =", chern_number(k, 5),
" =", float(chern_number(k, 5))) $
/* ===================================================================
MAIN SWEEP LOOP over n = N_GON_MIN .. N_GON_MAX step N_GON_STEP
=================================================================== */
print("============================================================")$
print("BEGIN SWEEP: n =", N_GON_MIN, "to", N_GON_MAX,
"step", N_GON_STEP)$
print("============================================================")$
/* ---------------------------------------------------------------
HELPER FUNCTIONS FOR ENHANCED SECTIONS (defined before loop)
--------------------------------------------------------------- */
/* --- Section 15: Inflation / substitution helpers --- */
/* Apply a substitution matrix M to a vector v (tile counts). */
apply_substitution(M, v) := M . v $
/* Iterate substitution k times. */
iterate_substitution(M, v, k) := block(
[result : v],
for i : 1 thru k do result : apply_substitution(M, result),
result) $
/* Perron-Frobenius eigenvalue (largest real eigenvalue, numeric). */
pf_eigenvalue_numeric(M) := block(
[eigs, real_eigs],
eigs : map(lambda([e], float(e)), eigenvalues(M)[1]),
real_eigs : sublist(eigs, lambda([e], imagpart(e) = 0)),
if real_eigs = [] then error("No real eigenvalues found")
else lmax(map(realpart, real_eigs))) $
/* Growth rate from iterated substitution (ratio of total counts). */
substitution_growth_rate(M, v, k) := block(
[v1, v2, s1, s2],
v1 : iterate_substitution(M, v, k),
v2 : iterate_substitution(M, v, k+1),
s1 : lreduce("+", list_matrix_entries(v1), 0),
s2 : lreduce("+", list_matrix_entries(v2), 0),
if s1 = 0 then error("Zero count at step k")
else float(s2/s1)) $
/* --- Section 16: Zeta / L-series helpers --- */
/* Partial Euler product for zeta_Q(sqrt5)(s) up to norm N_max. */
/* Primes in Z[phi]: p splits if (5/p)=1, inert if (5/p)=-1, ramifies if p=5. */
legendre5(p) :=
if mod(p, 5) = 0 then 0
else if mod(p^2, 5) = 1 then 1 /* p = +-1 mod 5 => splits */
else -1 $ /* p = +-2 mod 5 => inert */
/* Euler factor at rational prime p for zeta_{Q(sqrt5)}(s). */
euler_factor_qsqrt5(p, s) :=
if legendre5(p) = 1 then 1/(1 - p^(-s))^2
else if legendre5(p) = -1 then 1/(1 - p^(-2*s))
else 1/(1 - p^(-s)) $ /* ramified: p = 5 */
/* Partial Dedekind zeta product over primes up to P_max. */
partial_dedekind_zeta(s, P_max) := block(
[prod : 1.0, p],
p : 2,
while p <= P_max do block(
prod : prod * float(euler_factor_qsqrt5(p, s)),
p : next_prime(p)),
prod) $
/* Dirichlet L-function for the Kronecker symbol (5/.) */
/* L(s, chi_5) = sum_{n=1}^{N} chi_5(n) / n^s (partial sum) */
kronecker5(n) :=
if mod(n, 5) = 0 then 0
else if member(mod(n, 5), [1, 4]) then 1
else -1 $
partial_L_chi5(s, N_terms) :=
float(sum(kronecker5(nn) / nn^s, nn, 1, N_terms)) $
/* --- Section 17: Heat-trace helpers --- */
/* Heat kernel on Z (1D lattice): K_t(x) = exp(-t) * I_x(t) */
/* Approximated by Gaussian for large t: K_t(x) ~ (4 pi t)^{-1/2} exp(-x^2/(4t)) */
heat_kernel_1D_gauss(x, t) := (1/sqrt(4*%pi*t)) * exp(-x^2/(4*t)) $
/* Heat trace on a finite cycle C_n: Tr(e^{-t L}) = sum_k exp(-t lambda_k) */
/* where lambda_k = 2 - 2 cos(2 pi k / n). */
heat_trace_cycle(n, t) :=
float(sum(exp(-t * (2 - 2*cos(2*%pi*k/n))), k, 0, n-1)) $
/* Heat trace on star K_{1,n}: eigenvalues 0, 1 (x n-1), n+1. */
heat_trace_star(n, t) :=
float(1 + (n-1)*exp(-t) + exp(-t*(n+1))) $
/* Spectral zeta function: zeta_L(s) = sum_{lambda_k > 0} lambda_k^{-s} */
/* For cycle C_n: */
spectral_zeta_cycle(n, s) :=
float(sum(
if k = 0 then 0
else (2 - 2*cos(2*%pi*k/n))^(-s),
k, 0, n-1)) $
/* Effective spectral dimension from heat-trace slope: */
/* Tr(e^{-t L}) ~ t^{-d_s/2} => d_s = -2 * d(log Tr)/d(log t) */
heat_trace_slope(n, t1, t2) :=
-2 * (log(heat_trace_cycle(n, t2)) - log(heat_trace_cycle(n, t1)))
/ (log(t2) - log(t1)) $
/* --- Section 18: Acceptance-window helpers --- */
/* Regular n-gon acceptance window: vertices at angles 2 pi k/n, radius rho. */
window_vertex(n, k, rho) :=
[rho * cos(2*%pi*k/n), rho * sin(2*%pi*k/n)] $
/* Check if a 2D point p_perp lies inside the regular n-gon window of radius rho. */
/* Uses the half-plane intersection test. */
in_ngon_window(p_perp, n, rho) := block(
[inside : true, px : p_perp[1], py : p_perp[2]],
for k : 0 thru n-1 do block(
[theta_k : 2*%pi*k/n,
nx, ny, d],
nx : float(cos(theta_k + %pi/2)),
ny : float(sin(theta_k + %pi/2)),
d : float(rho * cos(%pi/n)),
if nx*px + ny*py > d then inside : false),
inside) $
/* Area of regular n-gon with inradius rho. */
ngon_window_area(n, rho) := n * rho^2 * tan(%pi/n) $
/* Density of accepted points: rho_accept = A_window / A_unit_cell */
/* For the pentagonal lattice, A_unit_cell = phi^2 * sin(2 pi/5). */
acceptance_density(n, rho, A_cell) :=
float(ngon_window_area(n, rho)) / float(A_cell) $
/* --- Section 19: Fibonacci word / substitution helpers --- */
/* Fibonacci word substitution: a -> ab, b -> a */
fib_word_substitute(w) := block(
[result : ""],
for i : 1 thru slength(w) do block(
[c : substring(w, i, i+1)],
result : sconcat(result,
if c = "a" then "ab" else "a")),
result) $
/* Generate Fibonacci word of depth k starting from "a". */
fib_word(k) := block(
[w : "a"],
for i : 1 thru k do w : fib_word_substitute(w),
w) $
/* Count occurrences of character c in string w. */
count_char(w, c) := block(
[cnt : 0],
for i : 1 thru slength(w) do
if substring(w, i, i+1) = c then cnt : cnt + 1,
cnt) $
/* Thue-Morse sequence: t(n) = parity of number of 1s in binary(n). */
thue_morse(n) := mod(sum(
block([bit : floor(n / 2^k)],
mod(bit, 2)),
k, 0, floor(log(max(n,1))/log(2))), 2) $
/* Rudin-Shapiro sequence: r(n) = (-1)^{number of 11 pairs in binary(n)}. */
rudin_shapiro(n) := block(
[bits : [], m : n, cnt : 0],
while m > 0 do (bits : cons(mod(m,2), bits), m : floor(m/2)),
for i : 1 thru length(bits)-1 do
if bits[i] = 1 and bits[i+1] = 1 then cnt : cnt + 1,
(-1)^cnt) $
for N_GON : N_GON_MIN thru N_GON_MAX step N_GON_STEP do block(
/* ---- local variables for this iteration ---- */
[n_int, theta_int_n, theta_ext_n, theta_cen_n,
cos_int_n, sin_int_n, cos_ext_n, sin_ext_n,
k_flat_n, deficit_n, excess_n,
k_loop_close_n, n_full_turns_n,
Rn, detRn, trRn, Rn_power, Rn_power_floats, Rk,
vertices_unit, vertices_unit_num,
edges_unit, edges_unit_num, side_unit_R,
fiber_order_n, h1, h2, h_comp, h_sum,
sum_all_roots, sum_prim_roots_n, moebius_n, two_cos_n,
Cn, In_id, charCn, Cn_power, Cn_orth,
ones_n, eig_diag, Jn_mat, P_diag_n, P_perp_n, rank_perp_n,
n_half, demo_perp, demo_norm2,
R_unit_n, r_unit_n, A_unit_n,
S0, conj_Rn, Rn_inv_p, conj_diff, Dn_order,
A_star_n, D_star_n, L_star_n, ones_star,
L_star_char, L_star_char_expected,
A_Cn, D_Cn, L_Cn, Cn_eigs_num, Cn_gap,
row_entry],
/* ----------------------------------------------------------------
Derived constants for this n
---------------------------------------------------------------- */
n_int : N_GON,
theta_int_n : (n_int - 2)*%pi / n_int,
theta_ext_n : 2*%pi / n_int,
theta_cen_n : 2*%pi / n_int,
cos_int_n : cos(theta_int_n),
sin_int_n : sin(theta_int_n),
cos_ext_n : cos(theta_ext_n),
sin_ext_n : sin(theta_ext_n),
k_flat_n : floor(2*%pi / theta_int_n),
deficit_n : ratsimp(2*%pi - k_flat_n * theta_int_n),
excess_n : ratsimp((k_flat_n + 1) * theta_int_n - 2*%pi),
k_loop_close_n : 2*n_int / gcd(2*n_int, n_int - 2),
n_full_turns_n : k_loop_close_n * (n_int - 2) / (2 * n_int),
print("============================================================"),
print("N_GON =", N_GON),
print("============================================================"),
print("Interior angle theta = (n-2)*pi/n =", theta_int_n,
" =", float(theta_int_n*180/%pi), "deg"),
print("Exterior angle = 2*pi/n =", theta_ext_n,
" =", float(theta_ext_n*180/%pi), "deg"),
print("Flat-vertex count k_flat = floor(2*pi/theta) =", k_flat_n),
print("Angular deficit at k_flat copies =", deficit_n,
" =", float(deficit_n*180/%pi), "deg"),
print("Angular excess at (k_flat+1) copies =", excess_n,
" =", float(excess_n*180/%pi), "deg"),
print("Smallest k>0 with k*theta = (integer)*2*pi: k =",
k_loop_close_n,
", accumulating ", n_full_turns_n, " full turns"),
/* ----------------------------------------------------------------
SECTION 2. Angles
---------------------------------------------------------------- */
print("------------------------------------------------------------"),
print("[n = ", N_GON, "] Angle summary:"),
print(" Interior angle theta =", theta_int_n,
" =", float(theta_int_n), " rad =",
float(theta_int_n*180/%pi), " deg"),
print(" Exterior angle =", theta_ext_n,
" =", float(theta_ext_n), " rad"),
print(" Central angle =", theta_cen_n,
" =", float(theta_cen_n), " rad"),
print(" Sum of interior angles =", sum_interior_ngon(n_int)),
print(" Avg interior angle =",
ratsimp(sum_interior_ngon(n_int)/n_int)),
if ratsimp(sum_interior_ngon(n_int)/n_int - theta_int_n) # 0
then error("Average interior angle inconsistent at n =", n_int),
print("[n = ", N_GON, "] k-copy vertex-loop accumulation:"),
for kk:1 thru max(12, 2*N_GON) do block(
[accum, n_turns, closes],
accum : ratsimp(kk * theta_int_n),
n_turns : ratsimp(accum / (2*%pi)),
closes : if integerp(ratsimp(n_turns)) then "CLOSES" else "open",
print(" k =", kk, ": sum =", accum, " = ",
ratsimp(n_turns), "* 2pi -- ", closes)),
print("Smallest k with full closure: k =", k_loop_close_n,
" (number of full turns =", n_full_turns_n, ")"),
/* ----------------------------------------------------------------
SECTION 3. Roots of unity
---------------------------------------------------------------- */
print("------------------------------------------------------------"),
print("[n = ", N_GON, "] Cyclotomic / roots-of-unity structure:"),
print(" x^n - 1 factorization =", factor(x^n_int - 1)),
print(" totient(n) = phi(n) =", totient(n_int),
" (degree of Q[zeta_n] over Q)"),
print(" Real subfield degree =",
if n_int <= 2 then 1 else totient(n_int)/2,
" (degree of Q(zeta + zeta^{-1}) over Q)"),
sum_all_roots : rectform(sum(exp(2*%pi*%i*k/n_int), k, 0, n_int - 1)),
print(" Sum of all n-th roots (numeric) =", float(sum_all_roots),
" (expected 0 for n >= 2)"),
if abs(float(realpart(sum_all_roots))) > 1.0e-10
or abs(float(imagpart(sum_all_roots))) > 1.0e-10
then error("Sum of n-th roots not zero at n =", n_int),
sum_prim_roots_n : rectform(
sum(if gcd(k, n_int) = 1 then exp(2*%pi*%i*k/n_int) else 0,
k, 1, n_int - 1)),
moebius_n : moebius(n_int),
print(" Sum of primitive n-th roots (numeric) =",
float(sum_prim_roots_n),
", Moebius mu(n) =", moebius_n),
if abs(float(realpart(sum_prim_roots_n)) - moebius_n) > 1.0e-10
or abs(float(imagpart(sum_prim_roots_n))) > 1.0e-10
then error("Sum of primitive n-th roots != mu(n) at n =", n_int),
two_cos_n : 2*cos(2*%pi/n_int),
print(" 2*cos(2*pi/n) =", two_cos_n, " =", float(two_cos_n),
" (algebraic integer in real cyclotomic subfield)"),
if n_int = 5 then block(
[check_72, check_144],
check_72 : float(2*cos(2*%pi/5) - ((sqrt(5)-1)/2)),
check_144 : float(2*cos(4*%pi/5) - (-(sqrt(5)+1)/2)),
print(" [Pentagon] 2*cos(72) - (sqrt 5 - 1)/2 ~", check_72),
print(" [Pentagon] 2*cos(144) - (-(sqrt 5 + 1)/2) ~", check_144),
if abs(check_72) > 1.0e-12 or abs(check_144) > 1.0e-12
then error("Pentagon 2cos identities failed")),
/* ----------------------------------------------------------------
SECTION 4. Rotation matrices and basis vectors
---------------------------------------------------------------- */
Rn : Rn_general(n_int),
print("------------------------------------------------------------"),
print("[n = ", N_GON, "] Rotation matrix R (by exterior angle 2*pi/n):"),
print(" Symbolic:", Rn),
print(" Numeric :",
matrix([float(cos(2*%pi/n_int)), float(-sin(2*%pi/n_int))],
[float(sin(2*%pi/n_int)), float( cos(2*%pi/n_int))])),
detRn : ratsimp(trigsimp(determinant(Rn))),
print(" det(R) =", detRn, " (expected 1)"),
if ratsimp(detRn - 1) # 0 then error("det(R) != 1 at n =", n_int),
trRn : ratsimp(mat_trace(Rn)),
print(" tr(R) =", trRn, " = 2 cos(2*pi/n) =", float(trRn)),
Rn_power : Rn,
for kk:2 thru n_int do Rn_power : Rn_power . Rn,
Rn_power_floats : matrix(
[float(trigsimp(Rn_power[1,1])), float(trigsimp(Rn_power[1,2]))],
[float(trigsimp(Rn_power[2,1])), float(trigsimp(Rn_power[2,2]))]),
print(" R^n numeric =", Rn_power_floats, " (expected I)"),
for i:1 thru 2 do for j:1 thru 2 do
if abs(Rn_power_floats[i,j] - if i=j then 1 else 0) > 1.0e-10
then error("R^n != I at n =", n_int),
print("[n = ", N_GON, "] R^k traces (should equal 2 cos(2 pi k/n)):"),
Rk : ident(2),
for kk:1 thru n_int do block(
[trk, expected],
Rk : Rk . Rn,
trk : float(trigsimp(mat_trace(Rk))),
expected : float(2*cos(2*%pi*kk/n_int)),
print(" k =", kk, ": tr(R^k) =", trk, " ~ 2cos(",kk,
"*2pi/n) =", expected),
if abs(trk - expected) > 1.0e-10
then error("R^k trace mismatch at k =", kk, "n =", n_int)),
vertices_unit : makelist(
[cos(vertex_angle_ngon(n_int, k)),
sin(vertex_angle_ngon(n_int, k))],
k, 0, n_int - 1),
vertices_unit_num : makelist(
[float(cos(vertex_angle_ngon(n_int, k))),
float(sin(vertex_angle_ngon(n_int, k)))],
k, 0, n_int - 1),
print("------------------------------------------------------------"),
print("[n = ", N_GON, "] PRIMARY BASIS VECTORS (unit circumradius,"),
print(" vertex 0 at top, CCW):"),
for k:0 thru n_int - 1 do
print(" v[", k, "] = ", vertices_unit[k+1],
" ~ ", vertices_unit_num[k+1]),
edges_unit : makelist(
[vertices_unit[mod(k, n_int) + 1][1]
- vertices_unit[mod(k - 1, n_int) + 1][1],
vertices_unit[mod(k, n_int) + 1][2]
- vertices_unit[mod(k - 1, n_int) + 1][2]],
k, 1, n_int),
edges_unit_num : makelist(
[float(trigsimp(edges_unit[k][1])),
float(trigsimp(edges_unit[k][2]))],
k, 1, n_int),
print("[n = ", N_GON, "] EDGE VECTORS e[k] = v[k] - v[k-1] (unit",
"circumradius):"),
for k:1 thru n_int do
print(" e[", k, "] (numeric) = ", edges_unit_num[k]),
side_unit_R : 2*sin(%pi/n_int),
print("[n = ", N_GON, "] Side length (unit circumradius) s =",
side_unit_R, " =", float(side_unit_R)),
if n_int = 5 then block(
[c72, s72, c36, s36, R72, R72p5],
c72 : (sqrt(5) - 1)/4,
s72 : sqrt(10 + 2*sqrt(5))/4,
c36 : (sqrt(5) + 1)/4,
s36 : sqrt(10 - 2*sqrt(5))/4,
print(" [Pentagon] cos(72) - (phi-1)/2 =",
ratsimp(c72 - (phi-1)/2)),
print(" [Pentagon] cos(36) - phi/2 =",
ratsimp(c36 - phi/2)),
print(" [Pentagon] cos^2(72) + sin^2(72) =",
ratsimp(c72^2 + s72^2)),
print(" [Pentagon] cos^2(36) + sin^2(36) =",
ratsimp(c36^2 + s36^2)),
R72 : matrix([c72, -s72], [s72, c72]),
R72p5 : ratsimp(R72 . R72 . R72 . R72 . R72),
print(" [Pentagon] R72^5 (radcan'd) =",
map(lambda([e], ratsimp(radcan(e))), R72p5)),
print(" [Pentagon] R72^5 - I numeric =",
map(lambda([e], float(e)), R72p5 - ident(2)))),
/* ----------------------------------------------------------------
SECTION 5. Holonomy
---------------------------------------------------------------- */
print("------------------------------------------------------------"),
print("[n = ", N_GON, "] Holonomy / spinor cover analysis:"),
fiber_order_n : k_loop_close_n,
print(" Natural single-vortex fiber order =", fiber_order_n),
print(" Z_n single-vortex holonomy (n =", fiber_order_n, ") :",
holonomy_Zn([1], fiber_order_n)),
print(" Required loop count to close fiber :",
order_Zn(1, fiber_order_n)),
print("[Anyonic case G = Z_n with n =", n_int, "]:"),
print(" single-vortex holonomy =", holonomy_Zn([1], n_int)),
print(" loop order required =", order_Zn(1, n_int),
" (expected", n_int, ")"),
if order_Zn(1, n_int) # n_int
then error("Z_n anyonic order != n at n =", n_int),
print("[n = ", N_GON, "] order(g, n) = n/gcd(g, n) check (g = 0..n-1):"),
for gg:0 thru n_int - 1 do block(
[o, expected],
o : order_Zn(gg, n_int),
expected : if gg = 0 then 1 else n_int/gcd(gg, n_int),
if o # expected
then error("order(", gg, ",", n_int, ") =", o,
", expected ", expected)),
print(" All g in Z_n satisfy order(g) = n/gcd(g, n)."),
h1 : holonomy_Zn([1, 2], n_int),
h2 : holonomy_Zn([mod(3, n_int), mod(4, n_int)], n_int),
h_comp : holonomy_Zn([1, 2, mod(3, n_int), mod(4, n_int)], n_int),
h_sum : mod(h1 + h2, n_int),
print("[n = ", N_GON, "] Composite holonomy: Loop A =", h1,
", Loop B =", h2, ", Composite =", h_comp,
", Sum mod n =", h_sum),
if h_comp # h_sum
then error("Composite holonomy failed at n =", n_int),
/* ----------------------------------------------------------------
SECTION 7. Cut-and-project lattice
---------------------------------------------------------------- */
print("------------------------------------------------------------"),
print("[n = ", N_GON, "] Cut-and-project ambient lattice Z^n:"),
Cn : cyclic_shift_n(n_int),
In_id : ident(n_int),
print(" C_n cyclic shift matrix:"),
print(" ", Cn),
charCn : ratsimp(expand(charpoly(Cn, x))),
print(" charpoly(C_n) =", charCn),
if expand(charCn - (x^n_int - 1)) # 0
and expand(charCn + (x^n_int - 1)) # 0
and expand(charCn - (-1)^n_int*(x^n_int - 1)) # 0
then error("char poly of C_n should be +/- (x^n - 1) at n =", n_int),
Cn_power : Cn,
for kk:2 thru n_int do Cn_power : Cn_power . Cn,
if Cn_power # In_id then error("C_n^n != I_n at n =", n_int),
print(" C_n^n = I_n verified."),
Cn_orth : ratsimp(Cn . transpose(Cn)),
if Cn_orth # In_id then error("C_n should be orthogonal at n =", n_int),
print(" C_n is orthogonal: C_n . C_n^T = I_n."),
ones_n : genmatrix(lambda([i,j], 1), n_int, 1),
eig_diag : ratsimp(Cn . ones_n - ones_n),
print(" C_n . (1,...,1)^T - (1,...,1)^T =",
transpose(eig_diag), " (should be zero)"),
if eig_diag # genmatrix(lambda([i,j], 0), n_int, 1)
then error("Diagonal eigenvector of C_n failed at n =", n_int),
Jn_mat : genmatrix(lambda([i, j], 1), n_int, n_int),
P_diag_n : ratsimp((1/n_int) * Jn_mat),
P_perp_n : ratsimp(In_id - P_diag_n),
if ratsimp(P_diag_n . P_diag_n - P_diag_n) # zeromatrix(n_int, n_int)
then error("P_diag not idempotent at n =", n_int),
if ratsimp(P_perp_n . P_perp_n - P_perp_n) # zeromatrix(n_int, n_int)
then error("P_perp not idempotent at n =", n_int),
if ratsimp(P_diag_n . P_perp_n) # zeromatrix(n_int, n_int)
then error("Projectors not orthogonal at n =", n_int),
if ratsimp(P_diag_n + P_perp_n - In_id) # zeromatrix(n_int, n_int)
then error("Projectors don't sum to I_n at n =", n_int),
print(" Projectors P_diag, P_perp: idempotent, orthogonal, complete."),
rank_perp_n : mat_trace(P_perp_n),
print(" dim(orthogonal complement of diagonal) =", rank_perp_n,
" = n - 1"),
if rank_perp_n # n_int - 1
then error("Perp projector rank should be n - 1 at n =", n_int),
print("[n = ", N_GON, "] REAL-INVARIANT 2D SUBSPACES V_k of C_n:"),
n_half : floor((n_int - 1)/2),
for k:1 thru n_half do block(
[u_vec, w_vec, u_num, w_num, theta_k],
theta_k : 2*%pi*k/n_int,
u_vec : makelist(cos(2*%pi*k*j/n_int), j, 0, n_int - 1),
w_vec : makelist(sin(2*%pi*k*j/n_int), j, 0, n_int - 1),
u_num : map(lambda([xx], float(xx)), u_vec),
w_num : map(lambda([xx], float(xx)), w_vec),
print(" V_", k, " (rotation angle 2 pi *", k, "/n =",
float(theta_k), "):"),
print(" u_", k, " (cos) =", u_num),
print(" w_", k, " (sin) =", w_num)),
if mod(n_int, 2) = 0 then block(
[alt_vec],
alt_vec : makelist((-1)^j, j, 0, n_int - 1),
print(" alternating-sign eigenvector (eigenvalue -1) =", alt_vec)),
print(" Physical 2D plane E_|| recommended = V_1."),
print(" Perp subspace E_perp = (diagonal) +",