Special Relativity in Financial Modeling 1.0.0
Lorentz transforms, spacetime classification, and geodesic price paths for quantitative finance
Loading...
Searching...
No Matches
christoffel.cpp
Go to the documentation of this file.
1/// @file src/tensor/christoffel.cpp
2/// @brief Christoffel symbols of the second kind — AGT-04
3///
4/// Computes Γ^λ_μν = ½ g^λσ (∂_μ g_νσ + ∂_ν g_μσ − ∂_σ g_μν)
5/// using central finite differences for the metric partial derivatives.
6
7#include "srfm/tensor.hpp"
8#include "srfm/constants.hpp"
9
10namespace srfm::tensor {
11
12// ─── Construction ─────────────────────────────────────────────────────────────
13
15 : metric_(metric)
16 , h_(h) {}
17
18// ─── Private: Central Finite Difference for ∂g_μν/∂x^sigma ─────────────────
19
20MetricMatrix ChristoffelSymbols::metric_derivative(const SpacetimePoint& x,
21 int sigma) const {
22 SpacetimePoint xp = x;
23 SpacetimePoint xm = x;
24 xp(sigma) += h_;
25 xm(sigma) -= h_;
26
27 // (g(x+hê_σ) − g(x−hê_σ)) / (2h) — O(h²) central difference
28 return (metric_.evaluate(xp) - metric_.evaluate(xm)) / (2.0 * h_);
29}
30
31// ─── compute ──────────────────────────────────────────────────────────────────
32
34 // Initialise all symbols to zero.
35 ChristoffelArray result;
36 for (int l = 0; l < SPACETIME_DIM; ++l) {
37 result[l] = MetricMatrix::Zero();
38 }
39
40 // We need the inverse metric g^λσ to raise the first index.
41 std::optional<MetricMatrix> g_inv_opt = metric_.inverse(x);
42 if (!g_inv_opt) {
43 // Singular metric → return zero symbols (degenerate manifold point).
44 return result;
45 }
46 const MetricMatrix& g_inv = *g_inv_opt;
47
48 // Precompute ∂g_μν/∂x^σ for all four coordinate directions.
49 // dg[sigma](mu, nu) = ∂g_μν/∂x^σ
50 std::array<MetricMatrix, SPACETIME_DIM> dg;
51 for (int s = 0; s < SPACETIME_DIM; ++s) {
52 dg[s] = metric_derivative(x, s);
53 }
54
55 // Γ^λ_μν = ½ Σ_σ g^{λσ} (∂_μ g_{νσ} + ∂_ν g_{μσ} − ∂_σ g_{μν})
56 for (int lambda = 0; lambda < SPACETIME_DIM; ++lambda) {
57 for (int mu = 0; mu < SPACETIME_DIM; ++mu) {
58 for (int nu = 0; nu < SPACETIME_DIM; ++nu) {
59 double sum = 0.0;
60 for (int sigma = 0; sigma < SPACETIME_DIM; ++sigma) {
61 // Three-term bracket (metric compatibility condition)
62 double bracket =
63 dg[mu](nu, sigma) // ∂_μ g_{νσ}
64 + dg[nu](mu, sigma) // ∂_ν g_{μσ}
65 - dg[sigma](mu, nu); // ∂_σ g_{μν}
66
67 sum += g_inv(lambda, sigma) * bracket;
68 }
69 result[lambda](mu, nu) = 0.5 * sum;
70 }
71 }
72 }
73
74 return result;
75}
76
77// ─── contract ─────────────────────────────────────────────────────────────────
78
80 const FourVelocity& u) const {
81 // result^λ = Σ_{μ,ν} Γ^λ_{μν} u^μ u^ν
82 FourVelocity result = FourVelocity::Zero();
83
84 for (int lambda = 0; lambda < SPACETIME_DIM; ++lambda) {
85 double sum = 0.0;
86 for (int mu = 0; mu < SPACETIME_DIM; ++mu) {
87 for (int nu = 0; nu < SPACETIME_DIM; ++nu) {
88 sum += gamma[lambda](mu, nu) * u(mu) * u(nu);
89 }
90 }
91 result(lambda) = sum;
92 }
93
94 return result;
95}
96
97} // namespace srfm::tensor
FourVelocity contract(const ChristoffelArray &gamma, const FourVelocity &u) const
ChristoffelArray compute(const SpacetimePoint &x) const
ChristoffelSymbols(const MetricTensor &metric, double h=constants::DEFAULT_FD_STEP)
std::optional< MetricMatrix > inverse(const SpacetimePoint &x) const
MetricMatrix evaluate(const SpacetimePoint &x) const
Physical and financial constants for the SRFM system.
std::array< MetricMatrix, SPACETIME_DIM > ChristoffelArray
Definition tensor.hpp:148
Eigen::Vector< double, SPACETIME_DIM > FourVelocity
A tangent vector at a spacetime point (four-velocity: dx^μ/dτ).
Definition types.hpp:44
Eigen::Matrix< double, SPACETIME_DIM, SPACETIME_DIM > MetricMatrix
The covariant metric tensor g_μν: a 4×4 symmetric matrix.
Definition types.hpp:47
Eigen::Vector< double, SPACETIME_DIM > SpacetimePoint
Definition types.hpp:41
static constexpr int SPACETIME_DIM
Dimensionality of the financial spacetime manifold (1 time + 3 assets).
Definition types.hpp:21
Tensor Calculus & Covariance Engine — AGT-04 public API.