Special Functions API
These helpers expose the public math-primitive surface available in Oakfield. Scalar helpers return a number for real inputs and a two-element complex table {re, im} for complex inputs. Domain and convergence failures raise Lua errors instead of returning silent NaNs.
At a Glance
Section titled “At a Glance”| Family | Functions |
|---|---|
| Polygamma | digamma, trigamma, digamma_batch, trigamma_batch |
| Generalized harmonic | generalized_harmonic, generalized_harmonic_batch, generalized_harmonic_d1, generalized_harmonic_d1_batch, generalized_harmonic_d2, generalized_harmonic_d2_batch |
| Hyperexponential | hyperexp, hyperexp_deriv |
| q-hyperexponential | qhyperexp, qhyperexp_deriv, qhyperexp_deriv_complex |
| Other q-analogs | qnumber, qzeta, qdigamma |
Batch Inputs & Outputs
Section titled “Batch Inputs & Outputs”Batch helpers share the same container contract:
family_batch(values, [out]) -> results_or_outgeneralized_harmonic_batch(values, K, [out]) -> results_or_outgeneralized_harmonic_d1_batch(values, K, [out]) -> results_or_outgeneralized_harmonic_d2_batch(values, K, [out]) -> results_or_outvaluesmay be a Lua array, aFieldhandle, or afield_viewdescriptor fromooc.field_view_from_field(field).- If
outis omitted, Oakfield returns a new Lua array. - If
outis provided, Oakfield fills it in place and returns that same array,Field, orfield_view. - Complex results require a complex-capable output buffer. A real output view cannot receive complex values.
For throughput-sensitive loops, prefer Field or field_view inputs over Lua arrays to avoid per-element Lua marshalling.
Polygamma
Section titled “Polygamma”digamma(z) -> number | {re, im}trigamma(z) -> number | {re, im}digamma_batch(values, [out]) -> array | Field | field_viewtrigamma_batch(values, [out]) -> array | Field | field_viewThe classical polygamma entry points are:
Both helpers accept real or complex inputs. The batch forms evaluate the same kernels over a container of values.
local psi = ooc.digamma(1.5)local psi_c = ooc.digamma({0.75, 0.25})
local psi_many = ooc.digamma_batch({1.5, 2.5, {0.75, 0.25}})
local src = ooc.add_field(ctx, {3}, { type = "real_double", fill = 0.0 })src:set_values({1.5, 2.0, 2.5})
local dst = ooc.add_field(ctx, {3}, { type = "real_double", fill = 0.0 })ooc.digamma_batch(ooc.field_view_from_field(src), ooc.field_view_from_field(dst))Avoid poles at the non-positive integers. Away from poles, digamma and trigamma are the most routine research-grade primitives in this section.
Generalized Harmonic Ladder
Section titled “Generalized Harmonic Ladder”generalized_harmonic(a, K) -> number | {re, im}generalized_harmonic_batch(values, K, [out]) -> array | Field | field_viewgeneralized_harmonic_d1(a, K) -> number | {re, im}generalized_harmonic_d1_batch(values, K, [out]) -> array | Field | field_viewgeneralized_harmonic_d2(a, K) -> number | {re, im}generalized_harmonic_d2_batch(values, K, [out]) -> array | Field | field_viewOakfield exposes the finite generalized harmonic ladder
together with its first two derivatives with respect to a:
The derivative families use the same real/complex continuation rules as the scalar ladder.
local H = ooc.generalized_harmonic(0.75, 8)local dH = ooc.generalized_harmonic_d1(0.75, 8)local d2H = ooc.generalized_harmonic_d2({0.75, -0.25}, 8)
local sweep = ooc.generalized_harmonic_batch({0.5, 0.75, 1.0}, 8)Kmust be non-negative.- For real inputs,
amust stay positive. - Complex inputs use analytic continuation away from poles.
Hyperexponential
Section titled “Hyperexponential”hyperexp(lambda, epsilon, K) -> number | {re, im}hyperexp_deriv(lambda, epsilon, K) -> numberOakfield uses the finite hyperexponential helper
hyperexp is the preferred name. The older hyperexp_phi and hyperexp_phi_complex spellings are compatibility aliases for the same evaluator.
The derivative helper is with respect to lambda and is currently real-only:
local phi = ooc.hyperexp(2.0, 0.5, 8)local phi_c = ooc.hyperexp({1.2, 0.3}, {0.8, -0.1}, 8)local dphi = ooc.hyperexp_deriv(1.5, 0.4, 6)Kmust be positive.- Non-finite results raise Lua errors.
- Near singular parameter regimes, treat
hyperexp*as exploratory rather than a blind drop-in numeric primitive.
q-Hyperexponential
Section titled “q-Hyperexponential”qhyperexp(lambda, epsilon, K, q) -> number | {re, im}qhyperexp_deriv(lambda, epsilon, K, q) -> numberqhyperexp_deriv_complex(lambda, epsilon, K, q) -> {re, im}The q-deformed ladder is
qhyperexp is the preferred name. The older qhyperexp_phi and qhyperexp_phi_complex spellings remain as aliases. Likewise, qhyperexp_phi_deriv and qhyperexp_phi_deriv_complex are legacy aliases of the canonical derivative names.
local qphi = ooc.qhyperexp(1.5, 0.2, 12, 0.9)local qphi_c = ooc.qhyperexp({0.6, 0.4}, {0.3, -0.2}, 12, 0.9)local qd = ooc.qhyperexp_deriv(1.5, 0.2, 12, 0.9)local qd_c = ooc.qhyperexp_deriv_complex({0.6, 0.4}, {0.3, -0.2}, 12, 0.9)Kmust be positive.qhyperexp_derivis real-only.qhyperexp_deriv_complexalways returns a complex pair.- q-regime sensitivity is higher than in the classical families, so treat fault boundaries and validation checks as part of the workflow.
Other q-Analogs
Section titled “Other q-Analogs”Jackson q-Number
Section titled “Jackson q-Number”qnumber(value, q) -> number | {re, im}with the identity limit [x]_1 = x preserved by the safe evaluator.
local qn = ooc.qnumber(1.5, 0.8)local qn_c = ooc.qnumber({0.5, 0.2}, 0.8)q-Deformed Hurwitz Zeta
Section titled “q-Deformed Hurwitz Zeta”qzeta(s, a, q) -> numberlocal z = ooc.qzeta(2.5, 0.75, 0.9)qzeta is real-only. When convergence fails, the Lua error includes the reported fault, iteration count, and residual.
q-Digamma
Section titled “q-Digamma”qdigamma(z, q) -> number | {re, im}local qpsi = ooc.qdigamma(1.25, 0.9)local qpsi_c = ooc.qdigamma({1.0, -0.25}, 0.9)Like qzeta, qdigamma uses safe evaluators and raises explicit Lua errors when q-domain rules or convergence limits are violated.
Compatibility Aliases
Section titled “Compatibility Aliases”| Preferred name | Compatibility aliases |
|---|---|
hyperexp | hyperexp_phi, hyperexp_phi_complex |
hyperexp_deriv | hyperexp_phi_deriv |
qhyperexp | qhyperexp_phi, qhyperexp_phi_complex |
qhyperexp_deriv | qhyperexp_phi_deriv |
qhyperexp_deriv_complex | qhyperexp_phi_deriv_complex |
Fault Model
Section titled “Fault Model”Standalone math helpers raise Lua errors immediately when inputs fall outside their supported domains. The context-managed fault counters, fallback hooks, and pole utilities documented in special/context are for context-owned operator/runtime evaluation, not for bypassing these direct helper errors.