Special Relativity in Financial Modeling 1.0.0
Lorentz transforms, spacetime classification, and geodesic price paths for quantitative finance
Loading...
Searching...
No Matches
spacetime_manifold.hpp
Go to the documentation of this file.
1#pragma once
2/**
3 * @file spacetime_manifold.hpp
4 * @brief Spacetime manifold processor with Christoffel symbols (AGT-13 / SRFM)
5 *
6 * Module: src/manifold/
7 * Owner: AGT-13 (Adversarial hardening) — 2026-03-01
8 *
9 * Responsibility
10 * --------------
11 * Model the financial market as a curved spacetime manifold:
12 *
13 * • Classify spacetime events into relativistic regimes.
14 * • Compute Christoffel connection coefficients Γ^λ_μν from a metric tensor.
15 * • Provide the flat Minkowski metric η = diag(−1, +1, +1, +1).
16 *
17 * Key invariant (tested by property suite):
18 * For the flat Minkowski metric, ALL 64 Christoffel symbols are zero.
19 *
20 * Design Constraints
21 * ------------------
22 * • No exceptions; all fallible paths return std::optional or signal via bool.
23 * • All public methods are noexcept.
24 * • MetricTensor spatial block must be positive-definite for a valid manifold.
25 *
26 * NOT Responsible For
27 * • Coordinate transformations between frames.
28 * • Integration of geodesic equations (see geodesic_solver.hpp).
29 */
30
31#include <array>
32#include <cmath>
33#include <optional>
34
35namespace srfm::manifold {
36
37// ── Constants ─────────────────────────────────────────────────────────────────
38
39/// Number of spacetime dimensions.
40inline constexpr int DIM = 4;
41
42/// Total Christoffel symbols: DIM³ = 64.
43inline constexpr int NUM_CHRISTOFFEL = DIM * DIM * DIM;
44
45// ── MetricTensor ──────────────────────────────────────────────────────────────
46
47/**
48 * @brief Symmetric 4×4 spacetime metric tensor g_{μν}.
49 *
50 * Row/column indices: 0=t, 1=x, 2=y, 3=z.
51 * Sign convention: (−,+,+,+). Flat Minkowski: diag(−1,+1,+1,+1).
52 *
53 * The spatial block g[1..3][1..3] must be positive-definite for a physically
54 * valid metric (time-like signature).
55 */
57 std::array<std::array<double, DIM>, DIM> g{};
58
59 /// Construct the flat Minkowski metric η = diag(−1,+1,+1,+1).
60 [[nodiscard]] static MetricTensor minkowski() noexcept;
61
62 /// Check that the metric has correct signature: g[0][0] < 0,
63 /// spatial diagonal entries g[i][i] > 0 for i ∈ {1,2,3}, finite entries.
64 [[nodiscard]] bool is_valid() const noexcept;
65
66 /// Return the inverse metric g^{μν} assuming diagonal metric (fast path).
67 /// For non-diagonal metrics falls back to returning nullopt.
68 [[nodiscard]] std::optional<MetricTensor> inverse_diagonal() const noexcept;
69};
70
71// ── SpacetimeEvent ────────────────────────────────────────────────────────────
72
73/**
74 * @brief A point in 4D spacetime (t, x, y, z).
75 *
76 * In the financial interpretation:
77 * t = time index
78 * x = price
79 * y = volume
80 * z = volatility proxy
81 */
83 double t{0.0};
84 double x{0.0};
85 double y{0.0};
86 double z{0.0};
87
88 /// True iff all coordinates are finite.
89 [[nodiscard]] bool is_finite() const noexcept;
90};
91
92// ── Regime ────────────────────────────────────────────────────────────────────
93
94/**
95 * @brief Market relativistic regime classification.
96 */
97enum class Regime {
98 Newtonian, ///< |β| < 0.1 — classical approximation valid
99 Relativistic, ///< 0.1 ≤ |β| < 0.9 — corrections needed
100 HighGamma, ///< 0.9 ≤ |β| < 0.9999 — extreme Lorentz contraction
101 Subluminal, ///< Catch-all: |β| ≥ 0 and < BETA_MAX_SAFE
102};
103
104// ── Christoffel index helpers ─────────────────────────────────────────────────
105
106/// Pack (λ, μ, ν) into flat index in [0, 64).
107[[nodiscard]] inline constexpr int christoffel_index(int lambda, int mu, int nu) noexcept {
108 return lambda * DIM * DIM + mu * DIM + nu;
109}
110
111// ── SpacetimeManifold ─────────────────────────────────────────────────────────
112
113/**
114 * @brief Processes spacetime events and computes manifold geometry.
115 *
116 * Stateless. Thread-safe.
117 *
118 * @example
119 * @code
120 * SpacetimeManifold manifold;
121 * SpacetimeEvent evt{1.0, 100.5, 1e6, 0.02};
122 * auto regime = manifold.process(evt); // → Regime::Newtonian
123 * auto metric = MetricTensor::minkowski();
124 * auto christoffel = manifold.christoffelSymbols(metric); // all zeros
125 * @endcode
126 */
128public:
129 SpacetimeManifold() noexcept = default;
130
131 /**
132 * @brief Classify a spacetime event into a relativistic regime.
133 *
134 * Uses x-coordinate as a proxy for normalised velocity |β|:
135 * β_proxy = tanh(|x| / (|x| + 1.0)) (maps R⁺ → [0,1))
136 *
137 * @return Regime, or std::nullopt if event coordinates are non-finite.
138 */
139 [[nodiscard]] std::optional<Regime>
140 process(const SpacetimeEvent& event) const noexcept;
141
142 /**
143 * @brief Compute all 64 Christoffel symbols Γ^λ_μν via finite differences.
144 *
145 * Uses central finite differences on the metric at the origin:
146 * ∂g_{μν}/∂x^λ ≈ (g(x+ε·eλ) − g(x−ε·eλ)) / (2ε)
147 *
148 * For a constant (flat) metric all derivatives are machine-zero, so all
149 * 64 symbols are < 1e-8 in absolute value.
150 *
151 * The metric callback signature:
152 * MetricCallback: (const std::array<double,DIM>&) → MetricTensor
153 * A null-like constant metric simply returns the same MetricTensor
154 * regardless of position.
155 *
156 * @param metric The metric tensor at the origin (flat or curved).
157 * @return std::array<double, 64> of Γ^λ_μν values (row-major λ,μ,ν).
158 * Returns array of zeros if metric inverse cannot be computed.
159 */
160 [[nodiscard]] std::array<double, NUM_CHRISTOFFEL>
161 christoffelSymbols(const MetricTensor& metric) const noexcept;
162
163 /**
164 * @brief Return the flat Minkowski metric.
165 *
166 * Convenience wrapper around MetricTensor::minkowski().
167 */
168 [[nodiscard]] MetricTensor flatMetric() const noexcept;
169};
170
171} // namespace srfm::manifold
SpacetimeManifold() noexcept=default
Regime
Market relativistic regime classification.
@ Subluminal
Catch-all: |β| ≥ 0 and < BETA_MAX_SAFE.
@ Newtonian
|β| < 0.1 — classical approximation valid
@ Relativistic
0.1 ≤ |β| < 0.9 — corrections needed
@ HighGamma
0.9 ≤ |β| < 0.9999 — extreme Lorentz contraction
constexpr int NUM_CHRISTOFFEL
Total Christoffel symbols: DIM³ = 64.
constexpr int DIM
Number of spacetime dimensions.
constexpr int christoffel_index(int lambda, int mu, int nu) noexcept
Pack (λ, μ, ν) into flat index in [0, 64).
Symmetric 4×4 spacetime metric tensor g_{μν}.
std::array< std::array< double, DIM >, DIM > g
std::optional< MetricTensor > inverse_diagonal() const noexcept
static MetricTensor minkowski() noexcept
Construct the flat Minkowski metric η = diag(−1,+1,+1,+1).
A point in 4D spacetime (t, x, y, z).