Skip to main content

feynkit_kinematics/
weyl.rs

1//! Exact Weyl factorization for complex null momenta.
2
3use symbolica::atom::Atom;
4
5use crate::{FourMomentum, SymbolicKinematicsError};
6
7impl FourMomentum<Atom> {
8    /// The Weyl matrix `[[E+pz, px-i py], [px+i py, E-pz]]`.
9    ///
10    /// Its determinant is the mostly-minus invariant `p.p`. Components are
11    /// exact Symbolica expressions, suitable for precision-generic evaluators.
12    pub fn weyl_matrix(&self) -> [[Atom; 2]; 2] {
13        let [energy, px, py, pz] = self.components();
14        let i_py = Atom::i() * py;
15        [[energy + pz, px - &i_py], [px + i_py, energy - pz]]
16    }
17
18    /// Factor a nonzero null momentum into angle and square Weyl components.
19    ///
20    /// Returns `[angle, square]`, where `weyl_matrix()[i][j]` equals
21    /// `angle[i] * square[j]` on `p.p = 0`. The angle is the selected column;
22    /// the square is the selected row divided by its pivot. This fixes the
23    /// reciprocal rescaling freedom without introducing a square-root branch.
24    ///
25    /// The caller must select a nonzero entry `[row, column]` at evaluation
26    /// time and supply a null momentum. Selection can use primal values while
27    /// numerical evaluation retains all precision and Dual components. A chart
28    /// is valid only where its pivot remains nonzero. This method rejects an
29    /// out-of-range or identically zero pivot; it does not infer assumptions
30    /// about symbolic components or test the on-shell relation.
31    pub fn null_weyl_spinors(
32        &self,
33        pivot: [usize; 2],
34    ) -> Result<[[Atom; 2]; 2], SymbolicKinematicsError> {
35        let [row, column] = pivot;
36        if row >= 2 || column >= 2 {
37            return Err(SymbolicKinematicsError::InvalidWeylPivot(pivot));
38        }
39        let matrix = self.weyl_matrix();
40        let denominator = &matrix[row][column];
41        if denominator.is_zero() {
42            return Err(SymbolicKinematicsError::ZeroWeylPivot(pivot));
43        }
44        Ok([
45            [matrix[0][column].clone(), matrix[1][column].clone()],
46            [&matrix[row][0] / denominator, &matrix[row][1] / denominator],
47        ])
48    }
49
50    /// Construct the complex null momentum whose Weyl matrix is `angle ⊗ square`.
51    ///
52    /// Mixing the angle of one null momentum with the square of another gives
53    /// a null vector orthogonal to both. No conjugation is applied: the two
54    /// spinors are independent complex components. This is the convention
55    /// `p = 1/2 <angle | gamma | square]` with `(E, px, py, pz)` ordering.
56    pub fn from_weyl_spinors(angle: &[Atom; 2], square: &[Atom; 2]) -> Self {
57        let diagonal = [&angle[0] * &square[0], &angle[1] * &square[1]];
58        let off_diagonal = [&angle[0] * &square[1], &angle[1] * &square[0]];
59        Self::from_args(
60            (&diagonal[0] + &diagonal[1]) / 2,
61            (&off_diagonal[0] + &off_diagonal[1]) / 2,
62            Atom::i() * (&off_diagonal[0] - &off_diagonal[1]) / 2,
63            (&diagonal[0] - &diagonal[1]) / 2,
64        )
65    }
66}
67
68#[cfg(test)]
69mod tests {
70    use super::*;
71    use symbolica::{atom::AtomCore, parse};
72
73    fn assert_zero(value: Atom) {
74        assert!(value.together().is_zero(), "{value}");
75    }
76
77    #[test]
78    fn determinant_and_all_charts_preserve_the_null_relation() {
79        let momentum = FourMomentum::from_args(parse!("e"), parse!("x"), parse!("y"), parse!("z"));
80        let matrix = momentum.weyl_matrix();
81        assert_zero(
82            &matrix[0][0] * &matrix[1][1] - &matrix[0][1] * &matrix[1][0] - momentum.mass_squared(),
83        );
84        let on_shell = parse!("x^2+y^2+z^2");
85        for (row, entries) in matrix.iter().enumerate() {
86            for (column, pivot) in entries.iter().enumerate() {
87                let [angle, square] = momentum.null_weyl_spinors([row, column]).unwrap();
88                let reconstructed = FourMomentum::from_weyl_spinors(&angle, &square);
89                for (actual, expected) in reconstructed
90                    .components()
91                    .into_iter()
92                    .zip(momentum.components())
93                {
94                    let difference = ((actual - expected) * pivot).together().expand();
95                    assert_zero(difference.replace(parse!("e^2")).with(on_shell.clone()));
96                }
97            }
98        }
99    }
100
101    #[test]
102    fn cross_spinors_form_the_transverse_null_pair() {
103        let a = [parse!("a0"), parse!("a1")];
104        let b = [parse!("b0"), parse!("b1")];
105        let c = [parse!("c0"), parse!("c1")];
106        let d = [parse!("d0"), parse!("d1")];
107        let first = FourMomentum::from_weyl_spinors(&a, &b);
108        let second = FourMomentum::from_weyl_spinors(&c, &d);
109        let transverse = [
110            FourMomentum::from_weyl_spinors(&a, &d),
111            FourMomentum::from_weyl_spinors(&c, &b),
112        ];
113        for vector in [&first, &second, &transverse[0], &transverse[1]] {
114            assert_zero(vector.mass_squared());
115        }
116        for vector in &transverse {
117            assert_zero(vector.dot(&first));
118            assert_zero(vector.dot(&second));
119        }
120        assert_zero(transverse[0].dot(&transverse[1]) + first.dot(&second));
121    }
122
123    #[test]
124    fn complex_axis_charts_and_invalid_pivots() {
125        // Each rank-one matrix with a single nonzero entry exercises a chart
126        // that cannot be replaced by one universally nonzero light-cone entry.
127        for row in 0..2 {
128            for column in 0..2 {
129                let mut angle = [Atom::num(0), Atom::num(0)];
130                let mut square = [Atom::num(0), Atom::num(0)];
131                angle[row] = Atom::i();
132                square[column] = Atom::num(2);
133                let momentum = FourMomentum::from_weyl_spinors(&angle, &square);
134                let [a, b] = momentum.null_weyl_spinors([row, column]).unwrap();
135                let reconstructed = FourMomentum::from_weyl_spinors(&a, &b);
136                for (actual, expected) in reconstructed
137                    .components()
138                    .into_iter()
139                    .zip(momentum.components())
140                {
141                    assert_zero(actual - expected);
142                }
143                assert!(matches!(
144                    momentum.null_weyl_spinors([1 - row, column]),
145                    Err(SymbolicKinematicsError::ZeroWeylPivot(_))
146                ));
147                assert!(matches!(
148                    momentum.null_weyl_spinors([row, 2]),
149                    Err(SymbolicKinematicsError::InvalidWeylPivot(_))
150                ));
151            }
152        }
153    }
154}