Skip to main content

SU2

Struct SU2 

Source
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

Source

pub fn matrix(&self) -> &Array2<Complex64>

Access the underlying 2×2 unitary matrix

Source

pub fn identity() -> Self

Identity element: I₂

Source

pub fn pauli_x() -> Array2<Complex64>

Get Pauli X generator (σ_x / 2)

Returns: (1/2) * [[0, 1], [1, 0]]

Source

pub fn pauli_y() -> Array2<Complex64>

Get Pauli Y generator (σ_y / 2)

Returns: (1/2) * [[0, -i], [i, 0]]

Source

pub fn pauli_z() -> Array2<Complex64>

Get Pauli Z generator (σ_z / 2)

Returns: (1/2) * [[1, 0], [0, -1]]

Source

pub fn rotation_x(theta: f64) -> Self

Rotation around X-axis by angle θ

Uses closed form: U = cos(θ/2) I + i sin(θ/2) σ_x

Source

pub fn rotation_y(theta: f64) -> Self

Rotation around Y-axis by angle θ

Uses closed form: U = cos(θ/2) I + i sin(θ/2) σ_y

Source

pub fn rotation_z(theta: f64) -> Self

Rotation around Z-axis by angle θ

Uses closed form: U = cos(θ/2) I + i sin(θ/2) σ_z

Source

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³:

  1. Generate 4 independent standard Gaussian variables (μ=0, σ=1)
  2. 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));
Source

pub fn inverse(&self) -> Self

Group inverse: U⁻¹ = U† (conjugate transpose for unitary matrices)

Source

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†

Source

pub fn act_on_vector(&self, v: &[Complex64; 2]) -> [Complex64; 2]

Act on a 2D vector: ψ → U ψ

Source

pub fn trace(&self) -> Complex64

Trace of the matrix: Tr(U)

Source

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.

Source

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_ρσ).

Source

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
Source

pub fn to_matrix(&self) -> [[Complex64; 2]; 2]

Convert to 2×2 array format

Source

pub fn from_matrix(arr: [[Complex64; 2]; 2]) -> Self

Create from 2×2 array format

Source

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 stabilityatan2 stability
θ ≈ 0Poor (derivative ∞)Good
θ ≈ π/2GoodGood
θ ≈ πGoodGood

The atan2 formulation avoids the derivative singularity at θ = 0 where d(acos)/dx → ∞.

§Returns

Same as log(), but with improved numerical stability.

Source

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 Clone for SU2

Source§

fn clone(&self) -> SU2

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SU2

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for SU2

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

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

Matrix dimension in the fundamental representation. Read more
Source§

type Algebra = Su2Algebra

Associated Lie algebra type. Read more
Source§

fn identity() -> Self

The identity element e ∈ G. Read more
Source§

fn compose(&self, other: &Self) -> Self

Group composition (multiplication): g₁ · g₂ Read more
Source§

fn inverse(&self) -> Self

Group inverse: g⁻¹ Read more
Source§

fn conjugate_transpose(&self) -> Self

Adjoint representation element (for matrix groups: conjugate transpose). Read more
Source§

fn distance_to_identity(&self) -> f64

Geodesic distance from identity: d(g, e) Read more
Source§

fn exp(tangent: &Su2Algebra) -> Self

Exponential map: 𝔤 → G Read more
Source§

fn log(&self) -> LogResult<Su2Algebra>

Logarithm map: G → 𝔤 (inverse of exponential) Read more
Source§

fn adjoint_action(&self, algebra_element: &Su2Algebra) -> Su2Algebra

Adjoint representation: Ad_g: 𝔤 → 𝔤 Read more
Source§

fn distance(&self, other: &Self) -> f64

Distance between two group elements: d(g, h) Read more
Source§

fn is_near_identity(&self, tolerance: f64) -> bool

Check if this element is approximately the identity. Read more
Source§

fn trace_identity() -> f64

Trace of the identity element Read more
Source§

fn reorthogonalize(&self) -> Self

Project element back onto the group manifold using Gram-Schmidt orthogonalization. Read more
Source§

fn geodesic(&self, other: &Self, t: f64) -> Option<Self>

Geodesic interpolation between two group elements. Read more
Source§

impl Mul<&SU2> for &SU2

Group multiplication: U₁ * U₂

Source§

type Output = SU2

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &SU2) -> SU2

Performs the * operation. Read more
Source§

impl Mul<&SU2> for SU2

Source§

type Output = SU2

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &SU2) -> SU2

Performs the * operation. Read more
Source§

impl MulAssign<&SU2> for SU2

Source§

fn mul_assign(&mut self, rhs: &SU2)

Performs the *= operation. Read more
Source§

impl PartialEq for SU2

Source§

fn eq(&self, other: &SU2) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl 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³.

Source§

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)

Source§

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.

Source§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T, Right> ClosedMul<Right> for T
where T: Mul<Right, Output = T> + MulAssign<Right>,

Source§

impl<T, Right> ClosedMulAssign<Right> for T
where T: ClosedMul<Right> + MulAssign<Right>,

Source§

impl<T> Scalar for T
where T: 'static + Clone + PartialEq + Debug,