Skip to content

zeta(s), zeta(s, a); gradient, divergence and curl - #2476

Open
Rafael-SOWNet wants to merge 1 commit into
masterfrom
feature/zeta-and-vector-operators
Open

Rafael-SOWNet wants to merge 1 commit into
masterfrom
feature/zeta-and-vector-operators

Conversation

@Rafael-SOWNet

Copy link
Copy Markdown
Member

The names decided on #2182 (comment of 2026-11-15, edited 2026-11-16): the Riemann and Hurwitz zeta functions, and the gradient, divergence and curl, spelled out.

Zeta

zeta(s) and zeta(s, a), read like gamma, with DLMF 25.11's Hurwitz convention; riemannzeta(s) and hurwitzzeta(s, a) are accepted on input. One node, Zetaf(Argument, Parameter): the Riemann function is a = 1, and zeta(s, 1) prints as zeta(s). zeta alone stays a variable and zeta (s) with a space stays zeta * s, as gamma (s) does. Zeta and HurwitzZeta are not read.

  • Exact values: ζ(0) = −1/2; ζ(2m) as a rational multiple of π^(2m) (to s = 600); ζ(−n, a) = −B_(n+1)(a)/(n+1) for rational a (to n = 300), so ζ(−1) = −1/12 and ζ(−11) = 691/32760; a whole s ≥ 2 with a whole or half-whole a written in ζ(s): ζ(2, 3) = π²/6 − 5/4, ζ(3, 1/2) = 7ζ(3). The pole s = 1 and a = 0, −1, −2, … are NaN, as gamma(0) is; the domain condition is not s = 1 and (not a in ZZ or a > 0).
  • Evaluation: Euler–Maclaurin (DLMF 25.11.5 with 2.10.1) for every s ≠ 1 and every a, real or complex; digits lost to cancellation are counted and the sum is taken again with that many more; the Riemann function left of 0 is reflected through Γ(1 − s) (DLMF 25.4.1). It declines beyond about |s| ≈ 40,000.
  • Against mpmath: 300 random points (real s in [−15, 15], complex |Im s| ≤ 40, Hurwitz a real in [−6, 6] and complex) at 100 digits, worst relative error 4.9e-100. ζ(1/2 + 14.134725141734693790457251983562i) agrees with mpmath at 200 digits to all 100; ζ(−60.5, 0.7) to all 100 (mpmath at its default precision is wrong there).
  • d/da ζ(s, a) = −s ζ(s + 1, a); d/ds stays a derivative node. Prints zeta(s); LaTeX \operatorname{\zeta}\left(s\right) by the register's rule for a Greek letter that could be a variable (as phi is \operatorname{\varphi}); SymPy sympy.zeta(s, a). Not compiled (no sound algorithm over double); the refusal goes through Binders.Refusal, so MathS.Shaders declines with the same message.

The gradient, divergence and curl

form behaviour
gradient(f, [x, y, z]) the column of ∂f/∂xᵢ
divergence(F, [x, y, z]) Σ ∂Fᵢ/∂xᵢ, for a vector written out with a component per variable
curl(F, [x, y, z]) [∂F₃/∂y − ∂F₂/∂z, ∂F₁/∂z − ∂F₃/∂x, ∂F₂/∂x − ∂F₁/∂y]
variables a vector of distinct names, or one name, as jacobian takes them
curl with other than 3 variables, or a field of the wrong length InvalidArgumentParseException at parse time, as cross does
one argument, gradient(x^2), divergence(x), curl(F) FunctionArgumentCountException, saying to give the variables
grad(f, x), div(F, x) parse errors; grad, div, curl alone stay variables

Checked against the definitions and against jacobian (the gradient is its transposed row, the divergence its trace, the curl from its off-diagonal entries); div curl F = 0 and curl grad f = 0 hold at negative and complex sample points.

Records

BREAKING-CHANGES.md, measured on the 2.7.0 package: the zeta names threw UnrecognizedFunctionParseException; gradient(x^2), divergence(x) and curl(x) were products; the two-argument operators were parse errors. curl(x) becoming a refusal follows #2453's treatment of gradient and divergence: a name in the register does not read as a product. The grammar adds the six names and removes the five refusals; master's grammar was regenerated unchanged first and matched byte for byte.

Full check on this commit: 20,736 unit tests, 0 failed; MCP 450, Terminal 69, F# 134, Interactive 19; AOT 81/81; BoundCheck 0 disagreements, RootCheck 596/596, CasBench 120/121 with 0 wrong, SimpSweep 10463/10463, RuleCheck clean, CanonCheck and Confluence at their baselines.

Not in this PR: limits through zeta stay unevaluated, there are no integration rules for it, and Comparison.md (a measured table) updates on the next sympyparity run.

Closes #2182.

🤖 Generated with Claude Code

zeta(s) and zeta(s, a), also riemannzeta(s) and hurwitzzeta(s, a), were refused by name and are now
Entity.Zetaf, built by MathS.Zeta: the Hurwitz zeta function of DLMF 25.11, sum_(n >= 0) 1/(n + a)^s
continued to every s but its pole at 1, with no value at a = 0, -1, -2, ..., and the Riemann one at
a = 1. zeta alone is still a variable and zeta (s) with a space the product zeta * s, as gamma is.

It is exact at s = 0 and the even numbers, zeta(2m) a rational times pi^(2m), and at s = -n, where it
is -B_(n + 1)(a)/(n + 1) for every rational a. At a whole s >= 2 and a whole or half-whole a it is
written in zeta(s), so zeta(3, 1/2) is 7 zeta(3). The pole and a non-positive whole a are NaN.

Elsewhere it is evaluated to the working precision, for real and complex s and a, by the
Euler-Maclaurin formula, summing to w = a + N with w at least 0.4 W + |s|/2 for W working digits.
Digits lost to cancellation, left of 0 or near a zero, are counted and the sum taken again with as
many more, and the Riemann function left of 0 is reflected through Gamma(1 - s). 300 random points,
Riemann and Hurwitz, real and complex, a negative and complex, agree with mpmath to 5e-100 at 100
digits, as does the first zero on the critical line at the decimals written, and zeta(3) to 200
digits.

Its derivative in a is -s zeta(s + 1, a); in s it is left a derivative. It prints as zeta(s) and
zeta(s, a), draws as \operatorname{\zeta}, and exports to sympy.zeta. Neither compiler has it, and
Binders.Refusal names it, so Compile and MathS.Shaders decline it with one message.

gradient(f, x), divergence(F, x) and curl(F, x) are computed into derivatives when parsed, as
jacobian is, in the variables listed as a vector or one name. The gradient and the curl are columns,
and the curl is taken in three variables only. One argument is refused saying to give the
variables: gradient(x^2) and divergence(x) were refused by name, and curl(x) was a product. grad and
div stay variables.

Part of #2182.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codecov

codecov Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.78231% with 31 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.98%. Comparing base (423d3aa) to head (441ed36).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
.../AngouriMath/Core/Entity/Continuous/Number/Zeta.cs 84.33% 11 Missing and 15 partials ⚠️
...ources/AngouriMath/Core/Antlr/AngouriMathParser.cs 99.60% 1 Missing and 1 partial ⚠️
...ntity/Continuous/Entity.Continuous.Zeta.Classes.cs 71.42% 2 Missing ⚠️
...nuous/Solvers/EquationSolver/InvertNode.Classes.cs 0.00% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2476      +/-   ##
==========================================
+ Coverage   86.97%   86.98%   +0.01%     
==========================================
  Files         324      326       +2     
  Lines       71847    72233     +386     
  Branches    20953    21037      +84     
==========================================
+ Hits        62490    62835     +345     
- Misses       5024     5048      +24     
- Partials     4333     4350      +17     
Flag Coverage Δ
cpp 37.77% <ø> (ø)
csharp 87.51% <95.78%> (+0.01%) ⬆️
fsharp 32.97% <ø> (ø)
interactive 39.81% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
Sources/AngouriMath/Convenience/MathS.cs 90.88% <100.00%> (+0.10%) ⬆️
Sources/AngouriMath/Core/Antlr/AngouriMathLexer.cs 99.27% <ø> (+0.01%) ⬆️
Sources/AngouriMath/Core/Antlr/ParsingHelpers.cs 93.03% <100.00%> (+1.56%) ⬆️
Sources/AngouriMath/Core/Domains.Classes.cs 100.00% <100.00%> (ø)
...Math/Core/Transformations/Matching/MatchPattern.cs 86.56% <100.00%> (+0.05%) ⬆️
...urces/AngouriMath/Functions/Compilation/Binders.cs 95.55% <100.00%> (+2.22%) ⬆️
...ngouriMath/Functions/Continuous/Differentiation.cs 86.70% <100.00%> (+0.21%) ⬆️
...nuous/Evaluation.Continuous.Arithmetics.Classes.cs 88.46% <100.00%> (+0.11%) ⬆️
...unctions/Output/Latex/Latex.Arithmetics.Classes.cs 96.00% <100.00%> (-1.75%) ⬇️
...ns/Output/ToString/ToString.Arithmetics.Classes.cs 100.00% <100.00%> (ø)
... and 7 more

... and 11 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

A register of function names, by what a mathematician calls each

1 participant