Repository navigation
Compiled special functions give their complex value in auto and complex mode; Arcsec and Arccsc are typed as complex out of domain - #436
Closed
enumeratio wants to merge 2 commits into
Conversation
…F1 and LambertW take the interpreter complex kernel in auto and complex mode, strict stays NaN, GPU declines a provably complex value; Arcsec/Arccsc type their complex part. Fix cortex-js#434
…ial-functions # Conflicts: # CHANGELOG.md
arnog
added a commit
that referenced
this pull request
Oct 15, 2026
… precision, integration gaps PR #436 (enumeratio, fix #434): the JavaScript target lowers HurwitzZeta, LerchPhi, PolyLog, EllipticK, the complete EllipticE, Hypergeometric2F1 and LambertW to the interpreter's complex kernel in `auto` and `complex` mode where the operand facts do not prove the value real; `strict` keeps the real kernel and its NaN; a complex operand takes the complex kernel in every mode. The verdict lives in one place (`complexContinuation`), read by both `isComplexValued` and the emitters. The GLSL and WGSL targets decline a provably complex value, now including a positive integer order on the cut `z > 1` (`PolyLog(2, 3)`, `LerchPhi(3, 2, 1)`). `Arcsec` and `Arccsc` of an operand of unknown magnitude type `complex | infinity | nan` instead of `number`, so the compiled lanes read the complex value. PR #440 (enumeratio, fix #439): `Argument` of a complex value passes the bignum parts to `Arctan2`, so `N(Argument(e + iπ), 25)` carries 25 digits. Also from #439: `Transpose` of an operand with no known shape is typed `unknown` (a union such as `matrix | vector` is transposed member by member), so `MatrixMultiply(q, Transpose(q))` with a free `q` stays unevaluated instead of an `incompatible-type` error. PR #441 (KingArth0r): definite integrals of more families evaluate in closed form — an absolute value or sign of a non-affine argument is split at its exact roots; integer-cell sums (Floor, Ceil, Fract with an affine weight) and `|sin(kx + m)|` over many periods no longer grow with the cell count; `∫₀¹ {1/x} dx = 1 − γ` and `∫₀¹ ⌊1/x⌋ dx = +∞`; primitives for Erf, Erfc, BesselJ(1, ·), BesselI(1, ·), Digamma, Trigamma and PolyGamma of an affine argument (and `d/dx LogGamma = Digamma`); the nested exponential `∫ e^{x + e^x} dx`; the Bose moments `∫₀^∞ xⁿ/(e^{ax} − 1) dx`. With the Rubi rules loaded, a provider antiderivative with no value at a bound falls back to the built-in one. Loading the rules compiles each distinct pattern once, and an invalid `stepBudget` is rejected before compilation. The PR's profiling script and JSON record are not included. Review fixes on top of the PRs: a user definition with its own `compile` handler keeps its own lane; compiled `HurwitzZeta(1, z)` for a non-real `z` is the pole; the period shortcut declines outside radian mode; exact coefficients in the cell sums stay exact; a polygamma integral between two consecutive poles evaluates; the infinite-bound inert decision reads the heads that contain the variable. ROADMAP: the antiderivative of Sin and Cos ignores the degree angular unit (found by the review; pre-existing). Fix #434 Fix #439 Co-authored-by: enumeratio <314378874+enumeratio@users.noreply.github.com> Co-authored-by: KingArthur <118565558+KingArth0r@users.noreply.github.com>
Member
|
Merged by hand onto main as 403a216, with the CHANGELOG/ROADMAP conflict resolved. Two additions: a positive integer order on the cut z > 1 is also provably complex, so PolyLog(2, 3) and LerchPhi(3, 2, 1) decline on the shader targets too; and a user definition with its own compile handler keeps its own lane. Thank you. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix #434.
The JavaScript target now follows the compile mode for these heads, as
Sqrt,Ln,ArcsinandPoweralready do:autoandcomplexmode: where the facts about the operands don't prove the value real, the head takes the complex lane. It calls the interpreter's complex kernel through_SYS, the wayGammauses_SYS.cgamma.strictmode: the real kernel stays, and a complex value givesNaN.The fact that decides "real, complex or unknown" is in one place,
complexContinuation(compilation/complex-continuation.ts). BothisComplexValuedand the emitters read it.HurwitzZeta(s, a)a ≥ 0or integers_SYS.churwitzZetaLerchPhi(z, s, a)z ≤ 1(or integers ≤ 0), anda ≥ 0or integers_SYS.clerchPhiPolyLog(s, z)z ≤ 1or integers ≤ 0_SYS.cpolyLogEllipticK(m),EllipticE(m)m ≤ 1_SYS.cellipticK,_SYS.cellipticEHypergeometric2F1z ≤ 1, or the series terminates_SYS.chypergeometric2F1LambertW(x, k)x ≥ −1/eon branch 0;[−1/e, 0)on branch −1_SYS.clambertWGPU:
HurwitzZeta,LerchPhiandPolyLogdecline to compile when the value is provably complex (e.g.LerchPhi(3, 2.5, 1)). When it is only unknown, the real helper stays, so a shader over plain symbols still compiles. The other heads have no GPU lowering.ArcsecandArccsc: over a real operand of unknown magnitude they are now typedcomplex | infinity | nan, where before they were typednumber. They then take the complex lane, asArcoshdoes. CompiledArcsec(0.5)wasNaNand is now1.3170i.Tests:
NaNpins inzeta-values,polylog-order,lerch-phi-valuesanditem-374-hurwitz-negative-ordernow expect the interpreter's value.compile-complex-continuation.test.tschecks each head:autoandcomplexmode against.N();strictgivesNaN;Left out: incomplete
EllipticEandStieltjesGammakeep their real-only lowerings.