wavefunction 0.0.1__tar.gz → 0.0.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,105 @@
1
+ Metadata-Version: 2.4
2
+ Name: wavefunction
3
+ Version: 0.0.2
4
+ Summary: Quantum Wavefunction with Spectral Complexity measure
5
+ Author-email: Juha Meskanen <juha@meskanen.com>
6
+ Maintainer-email: Juha Meskanen <juha@meskanen.com>
7
+ License-Expression: MIT
8
+ Project-URL: Homepage, https://github.com/juhakm/wavefunction
9
+ Project-URL: Bug Reports, https://github.com/juhakm/wavefunction
10
+ Project-URL: Say Thanks!, https://github.com/juhakm/wavefunction
11
+ Project-URL: Source, https://github.com/juhakm/wavefunction
12
+ Keywords: quantum,quantum-field-theory,information-theory,wavefunction,spinor,emergent-physics,minimal-spectral-length,computational-physics
13
+ Classifier: Development Status :: 4 - Beta
14
+ Classifier: Intended Audience :: Science/Research
15
+ Classifier: Intended Audience :: Education
16
+ Classifier: Topic :: Scientific/Engineering
17
+ Classifier: Topic :: Scientific/Engineering :: Physics
18
+ Classifier: Topic :: Scientific/Engineering :: Mathematics
19
+ Classifier: Topic :: Scientific/Engineering :: Information Analysis
20
+ Classifier: Programming Language :: Python
21
+ Classifier: Programming Language :: Python :: 3
22
+ Classifier: Programming Language :: Python :: 3.9
23
+ Classifier: Programming Language :: Python :: 3.10
24
+ Classifier: Programming Language :: Python :: 3.11
25
+ Classifier: Typing :: Typed
26
+ Classifier: Operating System :: OS Independent
27
+ Requires-Python: >=3.9
28
+ Description-Content-Type: text/markdown
29
+ License-File: LICENSE
30
+ Requires-Dist: numpy<1.27,>=1.25
31
+ Requires-Dist: scipy>=1.10
32
+ Requires-Dist: numba>=0.59
33
+ Requires-Dist: matplotlib
34
+ Dynamic: license-file
35
+
36
+ # Wavefunction
37
+
38
+ Quantum Mechanical complex valued wavefunction with Spectral Complexity measure.
39
+
40
+ ## Install
41
+
42
+ ```bash
43
+ pip install wavefunction
44
+ ```
45
+
46
+ ## Introduction
47
+
48
+ Spectral Complexity measure for complex-valued wavefunctions.
49
+
50
+ ## Theory background (Meskanen 2026 — "The Wavefunction as Compression")
51
+
52
+ The central hypothesis is that the quantum wavefunction is the universe's data-compression codec. Internal observers — themselves composed of compressed structures — perceive their constituent degrees of freedom as wave-like because they are observing *compressed information*. The codec that produces this compression is the Fourier / spectral decomposition.
53
+
54
+ ### Spectral Complexity $ C_s $
55
+
56
+ A wavefunction $ \psi(x) $ can always be written as a superposition of spectral modes, each characterised by two attributes:
57
+
58
+ - **frequency** $ \omega $ — the rate of oscillation, unbounded above zero
59
+ - **phase** $ \phi $ — the offset of the oscillation, bounded in $[0, 2\pi)$
60
+
61
+ The *spectral complexity* $ C_s(\psi) $ is the total continuous information cost needed to specify the set of modes that materially compose $ \psi $:
62
+
63
+ $$
64
+ C_s(\psi) = \sum_i \left[ \frac{\omega_i}{\Delta \omega} + \phi_{\text{cost}}(\phi_i) \right]
65
+ $$
66
+
67
+ #### Frequency cost (dominant term)
68
+
69
+ $ \frac{\omega_i}{\Delta \omega} $ is the number of resolution steps $ \Delta \omega $ needed to locate frequency $ \omega_i $. It is unbounded, continuous, and grows linearly with frequency. This term *dominates* $ C_s $ and is the reason the measure exponentially suppresses high-frequency (rough, chaotic) states.
70
+
71
+ The identification $ \Delta \omega = \hbar \ln 2 $ connects the minimum frequency resolution to Planck's constant (Meskanen 2026, §3.1).
72
+
73
+ #### Phase cost (subdominant, bounded)
74
+
75
+ Each phase $ \phi_i \in [0, 2\pi) $ requires a finite amount of information to specify. The cost is *global* over all modes: it measures how much information is needed to distinguish the phases from one another.
76
+
77
+ With only two modes at phases 0 and $ \pi $, very little is needed; with many modes at crowded, uneven phases, somewhat more is required. In practice this term is bounded by $ \log_2(N_{\text{modes}}) $ and is a second-order correction.
78
+
79
+ The current implementation uses a simple uniform fixed cost per non-reference mode as a tractable proxy; the reference mode (highest amplitude) is exempt because only *relative* phases are observable — a global phase shift leaves $ |\psi(x)|^2 $ unchanged.
80
+
81
+ #### Amplitude and the fidelity engine
82
+
83
+ Amplitude does not appear as a separate encoding cost. Instead it determines *which modes are included* in the description via a power-ranked fidelity engine: modes are added in descending power order until the accumulated power reaches a target fraction of the total. Modes below this threshold are simply absent from the description — they are not part of the codec output and contribute zero complexity cost.
84
+
85
+ This correctly handles the case where many weak modes coexist with a few dominant ones: the dominant modes determine $ C_s $; the weak modes are free.
86
+
87
+ #### Solomonoff suppression and the probability profile
88
+
89
+ Under Solomonoff-like induction the prior probability of a configuration is $ P(\psi) \propto 2^{-C_s(\psi)} $. Because $ C_s $ is a *sum* over independent modes, the probability *factorises*:
90
+
91
+ $$
92
+ P(\psi) \propto \prod_i 2^{-\omega_i / \Delta \omega}
93
+ $$
94
+
95
+ Each mode is suppressed independently and exponentially by its frequency. The resulting probability profile is Boltzmann-like with inverse temperature $ \beta = \ln(2)/\Delta \omega $:
96
+
97
+ $$
98
+ P(\text{mode } i \text{ present}) \propto \exp(-\ln(2) \cdot \omega_i / \Delta \omega)
99
+ $$
100
+
101
+ Smooth, low-frequency, compressible states dominate the measure. Boltzmann brains, random fluctuations, and chaotic configurations are exponentially suppressed — not by fine-tuning, but because they require many high-frequency modes to describe.
102
+
103
+ ### The conjecture $ C_s \propto S_{\text{Euclidean}} $
104
+
105
+ The central open conjecture (Meskanen 2026, §4) is that the minimum spectral complexity path through configuration space coincides with the minimum Euclidean action path of standard quantum gravity. If true, quantum gravity is Solomonoff induction over compressed descriptions of geometry, and $ \hbar $ is the minimum spectral resolution of a finite informational universe.
@@ -0,0 +1,70 @@
1
+ # Wavefunction
2
+
3
+ Quantum Mechanical complex valued wavefunction with Spectral Complexity measure.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ pip install wavefunction
9
+ ```
10
+
11
+ ## Introduction
12
+
13
+ Spectral Complexity measure for complex-valued wavefunctions.
14
+
15
+ ## Theory background (Meskanen 2026 — "The Wavefunction as Compression")
16
+
17
+ The central hypothesis is that the quantum wavefunction is the universe's data-compression codec. Internal observers — themselves composed of compressed structures — perceive their constituent degrees of freedom as wave-like because they are observing *compressed information*. The codec that produces this compression is the Fourier / spectral decomposition.
18
+
19
+ ### Spectral Complexity $ C_s $
20
+
21
+ A wavefunction $ \psi(x) $ can always be written as a superposition of spectral modes, each characterised by two attributes:
22
+
23
+ - **frequency** $ \omega $ — the rate of oscillation, unbounded above zero
24
+ - **phase** $ \phi $ — the offset of the oscillation, bounded in $[0, 2\pi)$
25
+
26
+ The *spectral complexity* $ C_s(\psi) $ is the total continuous information cost needed to specify the set of modes that materially compose $ \psi $:
27
+
28
+ $$
29
+ C_s(\psi) = \sum_i \left[ \frac{\omega_i}{\Delta \omega} + \phi_{\text{cost}}(\phi_i) \right]
30
+ $$
31
+
32
+ #### Frequency cost (dominant term)
33
+
34
+ $ \frac{\omega_i}{\Delta \omega} $ is the number of resolution steps $ \Delta \omega $ needed to locate frequency $ \omega_i $. It is unbounded, continuous, and grows linearly with frequency. This term *dominates* $ C_s $ and is the reason the measure exponentially suppresses high-frequency (rough, chaotic) states.
35
+
36
+ The identification $ \Delta \omega = \hbar \ln 2 $ connects the minimum frequency resolution to Planck's constant (Meskanen 2026, §3.1).
37
+
38
+ #### Phase cost (subdominant, bounded)
39
+
40
+ Each phase $ \phi_i \in [0, 2\pi) $ requires a finite amount of information to specify. The cost is *global* over all modes: it measures how much information is needed to distinguish the phases from one another.
41
+
42
+ With only two modes at phases 0 and $ \pi $, very little is needed; with many modes at crowded, uneven phases, somewhat more is required. In practice this term is bounded by $ \log_2(N_{\text{modes}}) $ and is a second-order correction.
43
+
44
+ The current implementation uses a simple uniform fixed cost per non-reference mode as a tractable proxy; the reference mode (highest amplitude) is exempt because only *relative* phases are observable — a global phase shift leaves $ |\psi(x)|^2 $ unchanged.
45
+
46
+ #### Amplitude and the fidelity engine
47
+
48
+ Amplitude does not appear as a separate encoding cost. Instead it determines *which modes are included* in the description via a power-ranked fidelity engine: modes are added in descending power order until the accumulated power reaches a target fraction of the total. Modes below this threshold are simply absent from the description — they are not part of the codec output and contribute zero complexity cost.
49
+
50
+ This correctly handles the case where many weak modes coexist with a few dominant ones: the dominant modes determine $ C_s $; the weak modes are free.
51
+
52
+ #### Solomonoff suppression and the probability profile
53
+
54
+ Under Solomonoff-like induction the prior probability of a configuration is $ P(\psi) \propto 2^{-C_s(\psi)} $. Because $ C_s $ is a *sum* over independent modes, the probability *factorises*:
55
+
56
+ $$
57
+ P(\psi) \propto \prod_i 2^{-\omega_i / \Delta \omega}
58
+ $$
59
+
60
+ Each mode is suppressed independently and exponentially by its frequency. The resulting probability profile is Boltzmann-like with inverse temperature $ \beta = \ln(2)/\Delta \omega $:
61
+
62
+ $$
63
+ P(\text{mode } i \text{ present}) \propto \exp(-\ln(2) \cdot \omega_i / \Delta \omega)
64
+ $$
65
+
66
+ Smooth, low-frequency, compressible states dominate the measure. Boltzmann brains, random fluctuations, and chaotic configurations are exponentially suppressed — not by fine-tuning, but because they require many high-frequency modes to describe.
67
+
68
+ ### The conjecture $ C_s \propto S_{\text{Euclidean}} $
69
+
70
+ The central open conjecture (Meskanen 2026, §4) is that the minimum spectral complexity path through configuration space coincides with the minimum Euclidean action path of standard quantum gravity. If true, quantum gravity is Solomonoff induction over compressed descriptions of geometry, and $ \hbar $ is the minimum spectral resolution of a finite informational universe.
@@ -8,7 +8,7 @@ packages = ["wavefunction"]
8
8
 
9
9
  [project]
10
10
  name = "wavefunction"
11
- version = "0.0.1"
11
+ version = "0.0.2"
12
12
  description = "Quantum Wavefunction with Spectral Complexity measure"
13
13
  readme = {file = "README.md", content-type = "text/markdown"}
14
14
  requires-python = ">=3.9"
@@ -0,0 +1,199 @@
1
+ import pytest
2
+ import numpy as np
3
+ from wavefunction import SpectralMode, Wavefunction
4
+
5
+ # ---------------------------------------------------------------------------
6
+ # Tests for SpectralMode
7
+ # ---------------------------------------------------------------------------
8
+
9
+ def test_spectral_mode_initialization():
10
+ """Ensure SpectralMode properties match specifications (e.g., phase wrapping)."""
11
+ # Amplitude should always be non-negative
12
+ m1 = SpectralMode(frequency=2.5, amplitude=-1.2, phase=0.0)
13
+ assert m1.amplitude == 1.2
14
+
15
+ # Phase should wrap cleanly within [0, 2pi)
16
+ m2 = SpectralMode(frequency=-1.0, amplitude=0.5, phase=2.5 * np.pi)
17
+ assert pytest.approx(m2.phase) == 0.5 * np.pi
18
+
19
+ m3 = SpectralMode(frequency=0.0, amplitude=1.0, phase=-0.5 * np.pi)
20
+ assert pytest.approx(m3.phase) == 1.5 * np.pi
21
+
22
+
23
+ # ---------------------------------------------------------------------------
24
+ # Tests for Wavefunction Construction & Attributes
25
+ # ---------------------------------------------------------------------------
26
+
27
+ def test_wavefunction_normalization():
28
+ """Verify that Wavefunction automatically normalizes input data."""
29
+ raw_psi = np.array([3.0 + 4j, 0.0, 0.0, 0.0])
30
+ wf = Wavefunction(raw_psi, dx=1.0)
31
+
32
+ # The L2 discrete norm should equal 1.0
33
+ assert pytest.approx(np.sum(np.abs(wf.psi) ** 2)) == 1.0
34
+ # Born rule array sanity check
35
+ assert pytest.approx(np.sum(wf.probability_density)) == 1.0
36
+
37
+ def test_wavefunction_zero_norm_raises_error():
38
+ """An all-zero array cannot be normalized and should raise an exception."""
39
+ zero_psi = np.zeros(16)
40
+ with pytest.raises(ValueError, match="Cannot normalise a zero wavefunction"):
41
+ Wavefunction(zero_psi)
42
+
43
+ def test_grid_derived_properties():
44
+ """Check coordinates, sizes, and natural default values."""
45
+ N = 8
46
+ dx = 0.5
47
+ raw_psi = np.ones(N)
48
+ wf = Wavefunction(raw_psi, dx=dx)
49
+
50
+ assert wf.N == N
51
+ assert np.allclose(wf.x, np.array([0.0, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5]))
52
+
53
+ expected_delta_omega = 2.0 * np.pi / (N * dx)
54
+ assert pytest.approx(wf.delta_omega) == expected_delta_omega
55
+ assert pytest.approx(wf.hbar_identified) == expected_delta_omega / np.log(2.0)
56
+
57
+
58
+ # ---------------------------------------------------------------------------
59
+ # Tests for Fidelity Engine & Modes
60
+ # ---------------------------------------------------------------------------
61
+
62
+ def test_fidelity_engine_greedy_accumulation():
63
+ """Verify that the fidelity engine slices off low power noise bins."""
64
+ N = 128
65
+ dx = 0.1
66
+ delta_omega = 2.0 * np.pi / (N * dx) # ~0.49087
67
+
68
+ # Choose exact grid frequencies (e.g., bin 4 and bin 20) to eliminate leakage
69
+ k1 = 4 * delta_omega
70
+ k2 = 20 * delta_omega
71
+
72
+ wf = Wavefunction.plane_wave_superposition(
73
+ N=N, amplitudes=[1.0, 0.01], wavenumbers=[k1, k2], dx=dx,
74
+ fidelity_target=0.999 # Excludes the tiny second mode
75
+ )
76
+
77
+ modes = wf.retained_modes()
78
+ # High-power mode carries >99.9% of total variance, so weak mode is ignored
79
+ assert len(modes) == 1
80
+
81
+ # Relax target to capture both clean bins
82
+ wf_inclusive = Wavefunction.plane_wave_superposition(
83
+ N=N, amplitudes=[1.0, 0.01], wavenumbers=[k1, k2], dx=dx,
84
+ fidelity_target=1.0
85
+ )
86
+ assert len(wf_inclusive.retained_modes()) == 2
87
+
88
+
89
+ # ---------------------------------------------------------------------------
90
+ # Tests for Spectral Complexity Mechanics
91
+ # ---------------------------------------------------------------------------
92
+
93
+ def test_global_phase_invariance():
94
+ """Global phase factor shifts should not affect complexity or reference flags."""
95
+ wf_base = Wavefunction.gaussian_packet(N=64, k0=2.0)
96
+ wf_shifted = wf_base * np.exp(1j * 1.234) # arbitrary global phase rotation
97
+
98
+ assert pytest.approx(wf_base.spectral_complexity()) == wf_shifted.spectral_complexity()
99
+ assert pytest.approx(wf_base.solomonoff_weight()) == wf_shifted.solomonoff_weight()
100
+
101
+ def test_complexity_hierarchy():
102
+ """Chaotic configurations must present vastly larger complexity profiles."""
103
+ N = 128
104
+ dx = 0.1
105
+ # Simple low-frequency pure state vs random noise
106
+ smooth_wf = Wavefunction.plane_wave_superposition(N=N, amplitudes=[1.0], wavenumbers=[0.0], dx=dx)
107
+ chaotic_wf = Wavefunction.random_state(N=N, dx=dx, seed=123)
108
+
109
+ assert smooth_wf.spectral_complexity() < chaotic_wf.spectral_complexity()
110
+ assert smooth_wf.solomonoff_weight() > chaotic_wf.solomonoff_weight()
111
+
112
+ def test_reference_mode_exempt_from_phase_cost():
113
+ """Verify the reference mode yields 0 phase cost; others pay phase_resolution."""
114
+ N = 64
115
+ dx = 0.1
116
+ delta_omega = 2.0 * np.pi / (N * dx) # ~0.98175
117
+
118
+ # Choose exact grid frequencies (bin 0 and bin 5) to eliminate leakage
119
+ k1 = 0.0
120
+ k2 = 5 * delta_omega
121
+
122
+ wf = Wavefunction.plane_wave_superposition(
123
+ N=N, amplitudes=[1.0, 1.0], wavenumbers=[k1, k2], dx=dx,
124
+ fidelity_target=1.0, phase_resolution=1.5
125
+ )
126
+
127
+ modes = wf.retained_modes()
128
+ # Without leakage, we get exactly the 2 discrete modes we generated
129
+ assert len(modes) == 2
130
+
131
+ # 0.0 frequency mode is our reference (lowest |w| fallback for tie-breaker)
132
+ # total cost = (0.0 / d_omega + 0.0) + (|k2| / d_omega + 1.5)
133
+ expected_freq_cost = abs(k2) / wf.delta_omega # matches exactly 5.0
134
+ expected_phase_cost = 1.5
135
+ assert pytest.approx(wf.spectral_complexity()) == expected_freq_cost + expected_phase_cost
136
+
137
+
138
+ # ---------------------------------------------------------------------------
139
+ # Tests for Mathematical Invariants & Derived Metrics
140
+ # ---------------------------------------------------------------------------
141
+
142
+ def test_solomonoff_bounds_and_profiles():
143
+ """Validate limits for weights and dictionary profiles mapping."""
144
+ wf = Wavefunction.gaussian_packet(N=64)
145
+ weight = wf.solomonoff_weight()
146
+
147
+ # Probability bounds
148
+ assert 0.0 < weight <= 1.0
149
+
150
+ suppressions = wf.mode_suppression_factors()
151
+ retained_freqs = [m.frequency for m in wf.retained_modes()]
152
+
153
+ assert set(suppressions.keys()) == set(retained_freqs)
154
+ for freq, factor in suppressions.items():
155
+ assert 0.0 < factor <= 1.0
156
+
157
+
158
+ # ---------------------------------------------------------------------------
159
+ # Tests for Linear Algebra Operators
160
+ # ---------------------------------------------------------------------------
161
+
162
+ def test_arithmetic_and_inner_product():
163
+ """Validate vector space rules and basic inner products."""
164
+ N = 32
165
+ dx = 0.2
166
+ wf1 = Wavefunction.plane_wave_superposition(N=N, amplitudes=[1.0], wavenumbers=[1.0], dx=dx)
167
+ wf2 = Wavefunction.plane_wave_superposition(N=N, amplitudes=[1.0], wavenumbers=[2.0], dx=dx)
168
+
169
+ # Mismatched grid checks
170
+ wf_bad = Wavefunction.plane_wave_superposition(N=N+10, dx=dx)
171
+ with pytest.raises(ValueError, match="Grid size mismatch"):
172
+ _ = wf1 + wf_bad
173
+
174
+ # Test superposition scaling operation paths
175
+ wf_sum = wf1 + wf2
176
+ assert isinstance(wf_sum, Wavefunction)
177
+ assert pytest.approx(np.sum(np.abs(wf_sum.psi) ** 2)) == 1.0
178
+
179
+ # Check scaling mechanics
180
+ wf_scaled = wf1 * 3.0
181
+ assert pytest.approx(np.sum(np.abs(wf_scaled.psi) ** 2)) == 1.0
182
+
183
+ wf_rscaled = 3.0 * wf1
184
+ assert np.allclose(wf_scaled.psi, wf_rscaled.psi)
185
+
186
+ # Unitary normalization validation checks via self-inner-product
187
+ # <psi|psi> * dx for a normalized state will return exactly 1.0 * dx * (1/dx sum logic)
188
+ # wait, inner_product explicitly includes * self.dx multiplication at the end
189
+ # since sum(|psi|^2) == 1, inner_product(wf, wf) is exactly 1.0 * dx.
190
+ assert pytest.approx(wf1.inner_product(wf1)) == 1.0 * dx
191
+
192
+
193
+ def test_repr():
194
+ """Verify string debugging readout formats correctly without breaking."""
195
+ wf = Wavefunction.gaussian_packet(N=32)
196
+ rep = repr(wf)
197
+ assert "Wavefunction" in rep
198
+ assert "C_s=" in rep
199
+ assert "modes=" in rep
@@ -0,0 +1,8 @@
1
+ from .wavefunction import Wavefunction
2
+ from .wavefunction import SpectralMode
3
+
4
+
5
+ __all__ = [
6
+ "Wavefunction",
7
+ "SpectralMode",
8
+ ]
@@ -614,62 +614,3 @@ class Wavefunction:
614
614
  f"ℏ_id={self.hbar_identified:.3e})"
615
615
  )
616
616
 
617
-
618
- # ---------------------------------------------------------------------------
619
- # Demo
620
- # ---------------------------------------------------------------------------
621
-
622
- if __name__ == "__main__":
623
- print(__doc__)
624
- print("=" * 65)
625
- print("Demo")
626
- print("=" * 65)
627
-
628
- # 1. Gaussian packet — few dominant modes, low C_s
629
- gp = Wavefunction.gaussian_packet(N=256, x0=12.8, sigma=2.0, k0=2.0, dx=0.1)
630
- print("\n[1] Gaussian wave packet")
631
- gp.spectral_complexity(verbose=True)
632
- print(gp)
633
-
634
- # 2. Two-component superposition — moderate C_s
635
- sp = Wavefunction.plane_wave_superposition(
636
- N=256, amplitudes=[0.6, 0.8],
637
- wavenumbers=[1.0, 5.0], phases=[0.0, np.pi / 4], dx=0.1)
638
- print("\n[2] Two-component superposition")
639
- sp.spectral_complexity(verbose=True)
640
- print(sp)
641
-
642
- # 3. Random state — all modes active, high C_s
643
- rnd = Wavefunction.random_state(N=256, seed=0, dx=0.1)
644
- print("\n[3] Random (high-entropy) state")
645
- print(f" C_s = {rnd.spectral_complexity():.2f} (verbose suppressed)")
646
- print(rnd)
647
-
648
- # 4. Solomonoff weights — exponential ordering
649
- print("\nSolomonoff weights 2^{{-C_s}}:")
650
- for label, wf in [("Gaussian", gp), ("Superposition", sp), ("Random", rnd)]:
651
- print(f" {label:>16s}: {wf.solomonoff_weight():.4e}")
652
-
653
- # 5. Interference economy
654
- gp2 = Wavefunction.gaussian_packet(N=256, x0=20.0, sigma=2.0, k0=2.0, dx=0.1)
655
- combined = gp + gp2
656
- print(f"\n[5] Interference economy:")
657
- print(f" C_s(ψ₁) = {gp.spectral_complexity():.2f}")
658
- print(f" C_s(ψ₂) = {gp2.spectral_complexity():.2f}")
659
- print(f" C_s(ψ₁ + ψ₂) = {combined.spectral_complexity():.2f}")
660
- print(" Superposition is cheaper than two independent descriptions.")
661
-
662
- # 6. Fidelity engine: weak modes don't inflate C_s
663
- x = np.arange(64)
664
- psi_clean = sum(np.exp(1j * 2*np.pi*k*x/64) for k in [2, 7, 13])
665
- rng = np.random.default_rng(0)
666
- psi_noisy = psi_clean + 0.01 * sum(
667
- np.exp(1j * (2*np.pi*k*x/64 + rng.uniform(0, 2*np.pi)))
668
- for k in range(20, 50))
669
- wf_clean = Wavefunction(psi_clean, dx=0.1)
670
- wf_noisy = Wavefunction(psi_noisy, dx=0.1)
671
- print(f"\n[6] Fidelity engine — weak modes ignored:")
672
- print(f" C_s(clean, 3 modes) = {wf_clean.spectral_complexity():.3f}")
673
- print(f" C_s(+ 30 weak noise modes) = {wf_noisy.spectral_complexity():.3f}")
674
- print(f" Modes retained (clean/noisy) = "
675
- f"{len(wf_clean.retained_modes())} / {len(wf_noisy.retained_modes())}")
@@ -0,0 +1,105 @@
1
+ Metadata-Version: 2.4
2
+ Name: wavefunction
3
+ Version: 0.0.2
4
+ Summary: Quantum Wavefunction with Spectral Complexity measure
5
+ Author-email: Juha Meskanen <juha@meskanen.com>
6
+ Maintainer-email: Juha Meskanen <juha@meskanen.com>
7
+ License-Expression: MIT
8
+ Project-URL: Homepage, https://github.com/juhakm/wavefunction
9
+ Project-URL: Bug Reports, https://github.com/juhakm/wavefunction
10
+ Project-URL: Say Thanks!, https://github.com/juhakm/wavefunction
11
+ Project-URL: Source, https://github.com/juhakm/wavefunction
12
+ Keywords: quantum,quantum-field-theory,information-theory,wavefunction,spinor,emergent-physics,minimal-spectral-length,computational-physics
13
+ Classifier: Development Status :: 4 - Beta
14
+ Classifier: Intended Audience :: Science/Research
15
+ Classifier: Intended Audience :: Education
16
+ Classifier: Topic :: Scientific/Engineering
17
+ Classifier: Topic :: Scientific/Engineering :: Physics
18
+ Classifier: Topic :: Scientific/Engineering :: Mathematics
19
+ Classifier: Topic :: Scientific/Engineering :: Information Analysis
20
+ Classifier: Programming Language :: Python
21
+ Classifier: Programming Language :: Python :: 3
22
+ Classifier: Programming Language :: Python :: 3.9
23
+ Classifier: Programming Language :: Python :: 3.10
24
+ Classifier: Programming Language :: Python :: 3.11
25
+ Classifier: Typing :: Typed
26
+ Classifier: Operating System :: OS Independent
27
+ Requires-Python: >=3.9
28
+ Description-Content-Type: text/markdown
29
+ License-File: LICENSE
30
+ Requires-Dist: numpy<1.27,>=1.25
31
+ Requires-Dist: scipy>=1.10
32
+ Requires-Dist: numba>=0.59
33
+ Requires-Dist: matplotlib
34
+ Dynamic: license-file
35
+
36
+ # Wavefunction
37
+
38
+ Quantum Mechanical complex valued wavefunction with Spectral Complexity measure.
39
+
40
+ ## Install
41
+
42
+ ```bash
43
+ pip install wavefunction
44
+ ```
45
+
46
+ ## Introduction
47
+
48
+ Spectral Complexity measure for complex-valued wavefunctions.
49
+
50
+ ## Theory background (Meskanen 2026 — "The Wavefunction as Compression")
51
+
52
+ The central hypothesis is that the quantum wavefunction is the universe's data-compression codec. Internal observers — themselves composed of compressed structures — perceive their constituent degrees of freedom as wave-like because they are observing *compressed information*. The codec that produces this compression is the Fourier / spectral decomposition.
53
+
54
+ ### Spectral Complexity $ C_s $
55
+
56
+ A wavefunction $ \psi(x) $ can always be written as a superposition of spectral modes, each characterised by two attributes:
57
+
58
+ - **frequency** $ \omega $ — the rate of oscillation, unbounded above zero
59
+ - **phase** $ \phi $ — the offset of the oscillation, bounded in $[0, 2\pi)$
60
+
61
+ The *spectral complexity* $ C_s(\psi) $ is the total continuous information cost needed to specify the set of modes that materially compose $ \psi $:
62
+
63
+ $$
64
+ C_s(\psi) = \sum_i \left[ \frac{\omega_i}{\Delta \omega} + \phi_{\text{cost}}(\phi_i) \right]
65
+ $$
66
+
67
+ #### Frequency cost (dominant term)
68
+
69
+ $ \frac{\omega_i}{\Delta \omega} $ is the number of resolution steps $ \Delta \omega $ needed to locate frequency $ \omega_i $. It is unbounded, continuous, and grows linearly with frequency. This term *dominates* $ C_s $ and is the reason the measure exponentially suppresses high-frequency (rough, chaotic) states.
70
+
71
+ The identification $ \Delta \omega = \hbar \ln 2 $ connects the minimum frequency resolution to Planck's constant (Meskanen 2026, §3.1).
72
+
73
+ #### Phase cost (subdominant, bounded)
74
+
75
+ Each phase $ \phi_i \in [0, 2\pi) $ requires a finite amount of information to specify. The cost is *global* over all modes: it measures how much information is needed to distinguish the phases from one another.
76
+
77
+ With only two modes at phases 0 and $ \pi $, very little is needed; with many modes at crowded, uneven phases, somewhat more is required. In practice this term is bounded by $ \log_2(N_{\text{modes}}) $ and is a second-order correction.
78
+
79
+ The current implementation uses a simple uniform fixed cost per non-reference mode as a tractable proxy; the reference mode (highest amplitude) is exempt because only *relative* phases are observable — a global phase shift leaves $ |\psi(x)|^2 $ unchanged.
80
+
81
+ #### Amplitude and the fidelity engine
82
+
83
+ Amplitude does not appear as a separate encoding cost. Instead it determines *which modes are included* in the description via a power-ranked fidelity engine: modes are added in descending power order until the accumulated power reaches a target fraction of the total. Modes below this threshold are simply absent from the description — they are not part of the codec output and contribute zero complexity cost.
84
+
85
+ This correctly handles the case where many weak modes coexist with a few dominant ones: the dominant modes determine $ C_s $; the weak modes are free.
86
+
87
+ #### Solomonoff suppression and the probability profile
88
+
89
+ Under Solomonoff-like induction the prior probability of a configuration is $ P(\psi) \propto 2^{-C_s(\psi)} $. Because $ C_s $ is a *sum* over independent modes, the probability *factorises*:
90
+
91
+ $$
92
+ P(\psi) \propto \prod_i 2^{-\omega_i / \Delta \omega}
93
+ $$
94
+
95
+ Each mode is suppressed independently and exponentially by its frequency. The resulting probability profile is Boltzmann-like with inverse temperature $ \beta = \ln(2)/\Delta \omega $:
96
+
97
+ $$
98
+ P(\text{mode } i \text{ present}) \propto \exp(-\ln(2) \cdot \omega_i / \Delta \omega)
99
+ $$
100
+
101
+ Smooth, low-frequency, compressible states dominate the measure. Boltzmann brains, random fluctuations, and chaotic configurations are exponentially suppressed — not by fine-tuning, but because they require many high-frequency modes to describe.
102
+
103
+ ### The conjecture $ C_s \propto S_{\text{Euclidean}} $
104
+
105
+ The central open conjecture (Meskanen 2026, §4) is that the minimum spectral complexity path through configuration space coincides with the minimum Euclidean action path of standard quantum gravity. If true, quantum gravity is Solomonoff induction over compressed descriptions of geometry, and $ \hbar $ is the minimum spectral resolution of a finite informational universe.
@@ -1,6 +1,7 @@
1
1
  LICENSE
2
2
  README.md
3
3
  pyproject.toml
4
+ tests/test_wavefunction.py
4
5
  wavefunction/__init__.py
5
6
  wavefunction/py.typed
6
7
  wavefunction/wavefunction.py
@@ -1,47 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: wavefunction
3
- Version: 0.0.1
4
- Summary: Quantum Wavefunction with Spectral Complexity measure
5
- Author-email: Juha Meskanen <juha@meskanen.com>
6
- Maintainer-email: Juha Meskanen <juha@meskanen.com>
7
- License-Expression: MIT
8
- Project-URL: Homepage, https://github.com/juhakm/wavefunction
9
- Project-URL: Bug Reports, https://github.com/juhakm/wavefunction
10
- Project-URL: Say Thanks!, https://github.com/juhakm/wavefunction
11
- Project-URL: Source, https://github.com/juhakm/wavefunction
12
- Keywords: quantum,quantum-field-theory,information-theory,wavefunction,spinor,emergent-physics,minimal-spectral-length,computational-physics
13
- Classifier: Development Status :: 4 - Beta
14
- Classifier: Intended Audience :: Science/Research
15
- Classifier: Intended Audience :: Education
16
- Classifier: Topic :: Scientific/Engineering
17
- Classifier: Topic :: Scientific/Engineering :: Physics
18
- Classifier: Topic :: Scientific/Engineering :: Mathematics
19
- Classifier: Topic :: Scientific/Engineering :: Information Analysis
20
- Classifier: Programming Language :: Python
21
- Classifier: Programming Language :: Python :: 3
22
- Classifier: Programming Language :: Python :: 3.9
23
- Classifier: Programming Language :: Python :: 3.10
24
- Classifier: Programming Language :: Python :: 3.11
25
- Classifier: Typing :: Typed
26
- Classifier: Operating System :: OS Independent
27
- Requires-Python: >=3.9
28
- Description-Content-Type: text/markdown
29
- License-File: LICENSE
30
- Requires-Dist: numpy<1.27,>=1.25
31
- Requires-Dist: scipy>=1.10
32
- Requires-Dist: numba>=0.59
33
- Requires-Dist: matplotlib
34
- Dynamic: license-file
35
-
36
- # Wavefunction
37
-
38
- Quantum Mechanical complex valued wavefunction with Spectral Complexity measure.
39
-
40
- ## Install
41
-
42
- ```
43
- pip install wavefunction
44
- ```
45
-
46
- [https://pypi.org/project/wavefunction/](https://pypi.org/project/wavefunction/)
47
-
@@ -1,12 +0,0 @@
1
- # Wavefunction
2
-
3
- Quantum Mechanical complex valued wavefunction with Spectral Complexity measure.
4
-
5
- ## Install
6
-
7
- ```
8
- pip install wavefunction
9
- ```
10
-
11
- [https://pypi.org/project/wavefunction/](https://pypi.org/project/wavefunction/)
12
-
@@ -1,6 +0,0 @@
1
- from .wavefunction import Wavefunction
2
-
3
-
4
- __all__ = [
5
- "Wavefunction"
6
- ]
@@ -1,47 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: wavefunction
3
- Version: 0.0.1
4
- Summary: Quantum Wavefunction with Spectral Complexity measure
5
- Author-email: Juha Meskanen <juha@meskanen.com>
6
- Maintainer-email: Juha Meskanen <juha@meskanen.com>
7
- License-Expression: MIT
8
- Project-URL: Homepage, https://github.com/juhakm/wavefunction
9
- Project-URL: Bug Reports, https://github.com/juhakm/wavefunction
10
- Project-URL: Say Thanks!, https://github.com/juhakm/wavefunction
11
- Project-URL: Source, https://github.com/juhakm/wavefunction
12
- Keywords: quantum,quantum-field-theory,information-theory,wavefunction,spinor,emergent-physics,minimal-spectral-length,computational-physics
13
- Classifier: Development Status :: 4 - Beta
14
- Classifier: Intended Audience :: Science/Research
15
- Classifier: Intended Audience :: Education
16
- Classifier: Topic :: Scientific/Engineering
17
- Classifier: Topic :: Scientific/Engineering :: Physics
18
- Classifier: Topic :: Scientific/Engineering :: Mathematics
19
- Classifier: Topic :: Scientific/Engineering :: Information Analysis
20
- Classifier: Programming Language :: Python
21
- Classifier: Programming Language :: Python :: 3
22
- Classifier: Programming Language :: Python :: 3.9
23
- Classifier: Programming Language :: Python :: 3.10
24
- Classifier: Programming Language :: Python :: 3.11
25
- Classifier: Typing :: Typed
26
- Classifier: Operating System :: OS Independent
27
- Requires-Python: >=3.9
28
- Description-Content-Type: text/markdown
29
- License-File: LICENSE
30
- Requires-Dist: numpy<1.27,>=1.25
31
- Requires-Dist: scipy>=1.10
32
- Requires-Dist: numba>=0.59
33
- Requires-Dist: matplotlib
34
- Dynamic: license-file
35
-
36
- # Wavefunction
37
-
38
- Quantum Mechanical complex valued wavefunction with Spectral Complexity measure.
39
-
40
- ## Install
41
-
42
- ```
43
- pip install wavefunction
44
- ```
45
-
46
- [https://pypi.org/project/wavefunction/](https://pypi.org/project/wavefunction/)
47
-
File without changes
File without changes