mathxlab.nt.dirichlet¶
Dirichlet characters and small numerical helpers.
Stability
Status: Experimental.
This project treats the documented names as the public surface, but details may still evolve.
If you need strict API guarantees, add __all__ = [...] to each module and version releases accordingly.
Design notes¶
Functions are designed for experiment-scale inputs (not cryptographic workloads).
Prefer explicit parameters (e.g.,
n_max) for reproducibility.
Examples¶
Evaluate a Dirichlet character¶
from mathxlab.nt.dirichlet import all_characters
chi = all_characters(5)[1]
print(chi(2))
Public API¶
Name |
Kind |
Summary |
|---|---|---|
|
function |
Compute Euler’s totient φ(n) by prime factorization. |
|
function |
Return the reduced residue system modulo |
|
class |
Dirichlet character modulo q. |
|
function |
Enumerate all Dirichlet characters modulo q. |
|
function |
Return the full character table as a matrix. |
|
function |
Compute the conductor of a character by brute-force divisor checks. |
|
function |
Compute the character orthogonality matrix for modulus q. |
Reference¶
Classes¶
- class mathxlab.nt.dirichlet.DirichletCharacter(modulus, params, _components)[source]¶
Bases:
objectDirichlet character modulo q.
The character is stored as a product of prime-power component characters.
- modulus¶
Modulus q.
- params¶
Parameter tuples, one per prime-power component.
Examples
>>> from mathxlab.nt.dirichlet import DirichletCharacter >>> DirichletCharacter
- property is_principal¶
Return True if χ is the principal character.
- table()[source]¶
Return the character table row for residues 0..q-1.
- Returns:
A complex NumPy array of shape (q,) containing χ(0), χ(1), …, χ(q-1).
- property conductor¶
Return the conductor of the character.
- Returns:
The smallest f | q such that χ(n) depends only on n mod f.
- property is_primitive¶
Return True if the character is primitive.
- Returns:
True iff conductor(χ) == q.
Functions¶
- mathxlab.nt.dirichlet.euler_phi(n)[source]¶
Compute Euler’s totient φ(n) by prime factorization.
- Parameters:
n – Positive integer.
- Returns:
φ(n).
Examples
>>> from mathxlab.nt.dirichlet import euler_phi >>> euler_phi
- mathxlab.nt.dirichlet.reduced_residues(q)[source]¶
Return the reduced residue system modulo
q(sorted).- Parameters:
q – Modulus (>= 1).
- Returns:
List of
ain[1, q]withgcd(a, q) = 1.
Examples
>>> from mathxlab.nt.dirichlet import reduced_residues >>> reduced_residues
- mathxlab.nt.dirichlet.all_characters(q)[source]¶
Enumerate all Dirichlet characters modulo q.
- Parameters:
q – Modulus (>= 1).
- Returns:
List of DirichletCharacter objects of length φ(q).
Examples
>>> from mathxlab.nt.dirichlet import all_characters >>> chars = all_characters(5) >>> len(chars) 4
- mathxlab.nt.dirichlet.character_table(q)[source]¶
Return the full character table as a matrix.
- Parameters:
q – Modulus.
- Returns:
Complex matrix of shape (φ(q), q) where rows are characters and columns are residues 0..q-1.
Examples
>>> from mathxlab.nt.dirichlet import character_table >>> character_table
- mathxlab.nt.dirichlet.conductor(chi)[source]¶
Compute the conductor of a character by brute-force divisor checks.
The conductor is the smallest f | q such that χ(n) depends only on n mod f.
This routine is intended for small q and experiment use.
- Parameters:
chi – Character modulo q.
- Returns:
The conductor f.
Examples
>>> from mathxlab.nt.dirichlet import conductor >>> conductor
- mathxlab.nt.dirichlet.orthogonality_matrix(q)[source]¶
Compute the character orthogonality matrix for modulus q.
- The matrix entries are:
M[i,j] = (1/φ(q)) * ∑_{a mod q, gcd(a,q)=1} χ_i(a) conj(χ_j(a))
For a correct implementation, M should be the identity.
- Parameters:
q – Modulus.
- Returns:
Complex matrix of shape (φ(q), φ(q)).
Examples
>>> from mathxlab.nt.dirichlet import orthogonality_matrix >>> orthogonality_matrix