pub struct SU2 { /* private fields */ }Expand description
SU(2) group element represented as a 2×2 unitary matrix.
SU(2) is the group of 2×2 complex unitary matrices with determinant 1:
U ∈ SU(2) ⟺ U†U = I and det(U) = 1§Applications
- Represents rotations and spin transformations
- Acts on spinor fields: ψ → U ψ
- Preserves inner products (unitarity)
Implementations§
Source§impl SU2
impl SU2
Sourcepub fn pauli_x() -> Array2<Complex64>
pub fn pauli_x() -> Array2<Complex64>
Get Pauli X generator (σ_x / 2)
Returns: (1/2) * [[0, 1], [1, 0]]
Sourcepub fn pauli_y() -> Array2<Complex64>
pub fn pauli_y() -> Array2<Complex64>
Get Pauli Y generator (σ_y / 2)
Returns: (1/2) * [[0, -i], [i, 0]]
Sourcepub fn pauli_z() -> Array2<Complex64>
pub fn pauli_z() -> Array2<Complex64>
Get Pauli Z generator (σ_z / 2)
Returns: (1/2) * [[1, 0], [0, -1]]
Sourcepub fn rotation_x(theta: f64) -> Self
pub fn rotation_x(theta: f64) -> Self
Rotation around X-axis by angle θ
Uses closed form: U = cos(θ/2) I + i sin(θ/2) σ_x
Sourcepub fn rotation_y(theta: f64) -> Self
pub fn rotation_y(theta: f64) -> Self
Rotation around Y-axis by angle θ
Uses closed form: U = cos(θ/2) I + i sin(θ/2) σ_y
Sourcepub fn rotation_z(theta: f64) -> Self
pub fn rotation_z(theta: f64) -> Self
Rotation around Z-axis by angle θ
Uses closed form: U = cos(θ/2) I + i sin(θ/2) σ_z
Sourcepub fn random_haar<R: Rng>(rng: &mut R) -> Self
pub fn random_haar<R: Rng>(rng: &mut R) -> Self
Random SU(2) element uniformly distributed according to Haar measure
Requires the rand feature (enabled by default).
Samples uniformly from SU(2) ≅ S³ (the 3-sphere) using the quaternion representation and Gaussian sampling method.
§Mathematical Background
SU(2) is diffeomorphic to the 3-sphere S³ ⊂ ℝ⁴:
SU(2) = {(a,b,c,d) ∈ ℝ⁴ : a² + b² + c² + d² = 1}represented as matrices:
U = [[a+ib, c+id ],
[-c+id, a-ib]]§Haar Measure Sampling
To sample uniformly from S³:
- Generate 4 independent standard Gaussian variables (μ=0, σ=1)
- Normalize to unit length
This gives the uniform (Haar) measure on SU(2) due to the rotational invariance of the Gaussian distribution.
§References
- Shoemake, K.: “Uniform Random Rotations” (Graphics Gems III, 1992)
- Diaconis & Saloff-Coste: “Comparison Theorems for Random Walks on Groups” (1993)
§Examples
use lie_groups::SU2;
use rand::SeedableRng;
let mut rng = rand::rngs::StdRng::seed_from_u64(42);
let g = SU2::random_haar(&mut rng);
// Verify it's unitary
assert!(g.verify_unitarity(1e-10));Sourcepub fn inverse(&self) -> Self
pub fn inverse(&self) -> Self
Group inverse: U⁻¹ = U† (conjugate transpose for unitary matrices)
Sourcepub fn conjugate_transpose(&self) -> Self
pub fn conjugate_transpose(&self) -> Self
Hermitian conjugate transpose: U†
For unitary matrices U ∈ SU(2), we have U† = U⁻¹ This is used in gauge transformations: A’ = g A g†
Sourcepub fn distance_to_identity(&self) -> f64
pub fn distance_to_identity(&self) -> f64
Distance from identity (geodesic distance in Lie group manifold)
Computed as: d(U, I) = ||log(U)||_F (Frobenius norm of logarithm)
§Numerical Behavior
For valid SU(2) matrices, |Re(Tr(U))/2| ≤ 1 exactly. Small violations
(within UNITARITY_VIOLATION_THRESHOLD) are clamped silently. Larger
violations trigger a debug assertion, indicating matrix corruption.
Sourcepub fn angle_and_axis(&self) -> (f64, [f64; 3])
pub fn angle_and_axis(&self) -> (f64, [f64; 3])
Extract rotation angle θ and axis n̂ from SU(2) element.
For U = cos(θ/2)·I + i·sin(θ/2)·(n̂·σ), returns (θ, n̂).
§Returns
Tuple of:
angle: Rotation angle θ ∈ [0, 2π]axis: Unit 3-vector n̂ =[n_x, n_y, n_z](or[0,0,1]if θ ≈ 0)
§Usage in Topological Charge
For computing topological charge, the product F_μν · F_ρσ involves
the dot product of the orientation axes: (n_μν · n_ρσ).
Sourcepub fn verify_unitarity(&self, tolerance: f64) -> bool
pub fn verify_unitarity(&self, tolerance: f64) -> bool
Verify this is approximately in SU(2)
Checks both:
- Unitarity: U†U ≈ I
- Special: |det(U) - 1| < tolerance
Sourcepub fn from_matrix(arr: [[Complex64; 2]; 2]) -> Self
pub fn from_matrix(arr: [[Complex64; 2]; 2]) -> Self
Create from 2×2 array format
Sourcepub fn log_stable(&self) -> LogResult<Su2Algebra>
pub fn log_stable(&self) -> LogResult<Su2Algebra>
Compute logarithm using numerically stable atan2 formulation.
This is more stable than the standard log() method, especially for
rotation angles approaching π. Uses atan2(sin(θ/2), cos(θ/2)) instead
of acos(cos(θ/2)) for improved numerical conditioning.
§Stability Improvements
| Angle θ | acos stability | atan2 stability |
|---|---|---|
| θ ≈ 0 | Poor (derivative ∞) | Good |
| θ ≈ π/2 | Good | Good |
| θ ≈ π | Good | Good |
The atan2 formulation avoids the derivative singularity at θ = 0 where d(acos)/dx → ∞.
§Returns
Same as log(), but with improved numerical stability.
Sourcepub fn log_with_condition(&self) -> ConditionedLogResult<Su2Algebra>
pub fn log_with_condition(&self) -> ConditionedLogResult<Su2Algebra>
Compute logarithm with conditioning information.
Returns both the logarithm and a LogCondition
structure that provides information about the numerical reliability
of the result.
Unlike log(), this method also provides condition number information
so callers can assess the numerical reliability of the result near
the cut locus (θ → 2π, U → -I).
§Example
use lie_groups::SU2;
let g = SU2::rotation_x(2.9); // Close to π
let (log_g, cond) = g.log_with_condition().unwrap();
if cond.is_well_conditioned() {
println!("Reliable result: {:?}", log_g);
} else {
println!("Warning: condition number = {:.1}", cond.condition_number());
}§Cut Locus Behavior
The SU(2) cut locus is at θ = 2π (U = -I), where sin(θ/2) = 0 and the axis is undefined. As θ → 2π, the condition number diverges as 1/sin(θ/2). The method still returns a result — it’s up to the caller to decide whether to use it based on the conditioning information.
Trait Implementations§
Source§impl LieGroup for SU2
Implementation of the LieGroup trait for SU(2).
impl LieGroup for SU2
Implementation of the LieGroup trait for SU(2).
This provides the abstract group interface, making SU(2) usable in generic gauge theory algorithms.
§Mathematical Verification
The implementation satisfies all group axioms:
- Identity: Verified in tests (
test_identity) - Inverse: Verified in tests (
test_inverse) - Associativity: Follows from matrix multiplication
- Closure: Matrix multiplication of unitaries is unitary
Source§const MATRIX_DIM: usize = 2
const MATRIX_DIM: usize = 2
Source§type Algebra = Su2Algebra
type Algebra = Su2Algebra
Source§fn conjugate_transpose(&self) -> Self
fn conjugate_transpose(&self) -> Self
Source§fn distance_to_identity(&self) -> f64
fn distance_to_identity(&self) -> f64
Source§fn exp(tangent: &Su2Algebra) -> Self
fn exp(tangent: &Su2Algebra) -> Self
Source§fn log(&self) -> LogResult<Su2Algebra>
fn log(&self) -> LogResult<Su2Algebra>
Source§fn adjoint_action(&self, algebra_element: &Su2Algebra) -> Su2Algebra
fn adjoint_action(&self, algebra_element: &Su2Algebra) -> Su2Algebra
Ad_g: 𝔤 → 𝔤 Read moreSource§fn distance(&self, other: &Self) -> f64
fn distance(&self, other: &Self) -> f64
Source§fn is_near_identity(&self, tolerance: f64) -> bool
fn is_near_identity(&self, tolerance: f64) -> bool
Source§fn trace_identity() -> f64
fn trace_identity() -> f64
Source§fn reorthogonalize(&self) -> Self
fn reorthogonalize(&self) -> Self
Source§impl MulAssign<&SU2> for SU2
impl MulAssign<&SU2> for SU2
Source§fn mul_assign(&mut self, rhs: &SU2)
fn mul_assign(&mut self, rhs: &SU2)
*= operation. Read moreimpl Compact for SU2
SU(2) is compact.
All elements are bounded: ||U|| = 1 for all U ∈ SU(2). The group is diffeomorphic to the 3-sphere S³.
impl SemiSimple for SU2
SU(2) is semi-simple.
As a simple group, it is automatically semi-simple. (Simple ⊂ Semi-simple in the classification hierarchy)
impl Simple for SU2
SU(2) is simple.
It has no non-trivial normal subgroups. This is a fundamental result in Lie theory - SU(2) is one of the classical simple groups.
impl StructuralPartialEq for SU2
Auto Trait Implementations§
impl Freeze for SU2
impl RefUnwindSafe for SU2
impl Send for SU2
impl Sync for SU2
impl Unpin for SU2
impl UnsafeUnpin for SU2
impl UnwindSafe for SU2
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.