mathxlab.nt.convolution

Dirichlet convolution 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

Dirichlet convolution on a prefix

from mathxlab.nt.convolution import ones, identity, dirichlet_convolution
res = dirichlet_convolution(ones(10), identity(10), n_max=10)
print(res.values[1:6])

Public API

Name

Kind

Summary

ConvolutionResult

class

Result of a Dirichlet convolution computed on a prefix.

dirichlet_convolution

function

Compute the Dirichlet convolution (f*g)(n) for n <= n_max.

epsilon

function

Return the identity element ε for Dirichlet convolution on [0..n_max].

ones

function

Return the constant-one function 1(n)=1 for n>=1.

identity

function

Return the identity arithmetic function id(n)=n.

Reference

Classes

class mathxlab.nt.convolution.ConvolutionResult(n_max, values)[source]

Bases: object

Result of a Dirichlet convolution computed on a prefix.

n_max

Maximum n (inclusive).

values

List where values[n] = (f*g)(n) for 0..n_max.

Examples

>>> from mathxlab.nt.convolution import ConvolutionResult
>>> ConvolutionResult

Functions

mathxlab.nt.convolution.dirichlet_convolution(f, g, *, n_max)[source]

Compute the Dirichlet convolution (f*g)(n) for n <= n_max.

The inputs are expected to be lists indexed by n with at least n_max+1 entries.

Parameters:
  • f – Function values f[n].

  • g – Function values g[n].

  • n_max – Maximum n.

Returns:

ConvolutionResult with values list.

Raises:

ValueError – If input lists are too short.

Examples

>>> from mathxlab.nt.convolution import ones, identity, dirichlet_convolution
>>> f = ones(10); g = identity(10)
>>> dirichlet_convolution(f, g).values[1:6]
[1, 3, 4, 7, 6]
mathxlab.nt.convolution.epsilon(n_max)[source]

Return the identity element ε for Dirichlet convolution on [0..n_max].

ε(1) = 1, ε(n)=0 for n != 1.

Parameters:

n_max – Maximum n.

Returns:

List eps with eps[1]=1.

Examples

>>> from mathxlab.nt.convolution import epsilon
>>> epsilon
mathxlab.nt.convolution.ones(n_max)[source]

Return the constant-one function 1(n)=1 for n>=1.

Parameters:

n_max – Maximum n.

Returns:

List one with one[n]=1 for n>=1.

Examples

>>> from mathxlab.nt.convolution import ones
>>> ones
mathxlab.nt.convolution.identity(n_max)[source]

Return the identity arithmetic function id(n)=n.

Parameters:

n_max – Maximum n.

Returns:

List id with id[n]=n.

Examples

>>> from mathxlab.nt.convolution import identity
>>> identity