MathVerse Complex
Complex number arithmetic, analysis, special functions, and matrix algebra over f64.
Features
- Full
Complextype — arithmetic operators, polar form, principal roots, exponentiation - Transcendental functions — trigonometric, hyperbolic, inverse trigonometric, logarithmic
- Complex analysis — contour integration, residue calculus, Laurent series, conformal mappings
- Special functions — gamma, zeta, polylogarithm, Bessel, Airy, Fresnel over complex domain
- Complex matrix algebra — LU decomposition, determinant, inverse, eigenvalues
- Zero external dependencies
Module Overview
| Module | Purpose |
|---|---|
Complex (root) |
Core type, arithmetic, transcendental functions |
analysis |
Residues, contour integrals, conformal mappings, Cauchy-Riemann checks |
special_functions |
Gamma, zeta, polylog, erf, Bessel, Airy, Fresnel |
matrix |
Complex matrix algebra and decompositions |
Installation
[]
= "0.1"
Quick Start
use Complex;
Per-Module Documentation
Complex — Core Type
Construction
let a = new; // 1 + 2i
let b = real; // 5 + 0i
let c = i; // 0 + 1i
let d = polar; // 0 + 2i (r·e^(iθ))
let e: Complex = 3.0.into; // From<f64>
let f: Complex = .into; // From<(f64, f64)>
Properties
| Method | Formula |
|---|---|
norm() |
√(re² + im²) |
norm_sq() |
re² + im² |
arg() |
atan2(im, re) ∈ (-π, π] |
conjugate() |
re - im·i |
signum() |
z / |z| (unit magnitude) |
is_zero() |
re == 0 && im == 0 |
Functions
| Method | Formula / Notes |
|---|---|
sqrt() |
Principal square root via polar form |
exp() |
ez = ere(cos im + i·sin im) |
ln() |
Principal: ln|z| + i·arg(z) |
pow(p) |
e^(p·ln z), principal branch |
sin/cos/tan |
Complex trigonometric functions |
sinh/cosh/tanh |
Complex hyperbolic functions |
asin/acos/atan |
Inverse trigonometric functions |
Arithmetic
Implements Add, Sub, Mul, Div, Neg:
let z1 = new;
let z2 = new;
let sum = z1 + z2; // (4, 6)
let prod = z1 * z2; // (-5, 10)
let quot = z1 / z2; // (0.44, 0.08)
analysis — Complex Analysis
Residues
use ;
// f(z) = 1/(z-1), residue at z=1 is 1
let f = ;
let residue = residue_simple_pole;
Contour Integration
// ∮ z dz around unit circle = 0
let f = ;
let result = contour_integral_circle;
Analyticity & Conformal Mappings
is_analytic(&f, z, tol)— checks Cauchy-Riemann equationsmobius_transform(z,a,b,c,d)— Möbius transform w = (az+b)/(cz+d)argument_principle(f,z₀,r,n)— zeros minus poles countlaurent_series_coefficients(...)— positive and negative power coefficients
special_functions — Complex Special Functions
Gamma Function
Lanczos approximation with reflection formula for Re(z) < 0.5.
use ComplexSpecialFunctions;
let g = gamma;
// Γ(5) = 24
Error Functions & Bessel
let e = erf;
// erf(1) ≈ 0.8427
let j0 = bessel_j;
// J₀(1) ≈ 0.7652
matrix — Complex Matrix Algebra
use ;
let mut a = new;
a.set;
a.set;
a.set;
a.set;
let b = vec!;
let x = a.solve.unwrap;
// x ≈ [1.0, 1.0]
Supports LU decomposition, determinant, inverse, power, matrix exp/ln, Hermitian/unitary checks.
Future Scope
- Eigenvalue decomposition (QR algorithm)
- SVD (singular value decomposition)
- Matrix exponential via Padé approximation
- Fast Fourier Transform on complex arrays
- Quaternion support
- SIMD-accelerated operations
License
MIT — see LICENSE.