Gamma and zeta
The two functions the rest of analytic number theory leans on, at any complex argument and to any precision, as rectangles proved to contain the value. They are also functions of Taylor models, so they can be integrated round contours and searched for zeros like anything else in the package.
import { gamma, rgamma, logGamma, zeta, zetaZeros } from "@ratmath/complex";
gamma(5); // 24 ± 5.4e-20
gamma("1/2"); // 1.7724538509 ± 1.7e-21, which is √π
gamma("1 + i"); // 0.49801566812 - 0.1549498283i ± 4.2e-22
gamma("1 + i", { bits: 160 }); // the same to fifty digits
rgamma(-3); // exactly 0: 1/Γ is entire
zeta(2); // 1.64493406685 ± 1.7e-21, π²/6
zeta(-1); // -0.083333333333, which is −1/12
zeta("1/2 + 14i"); // 0.02224114261 - 0.103258123266i
zetaZeros(10, 35); // five zeros, each proved to have real part exactly 1/2
Gamma
Three classical facts, each with a remainder that can be bounded.
- Stirling's series, for far to the right: where is at most times the first term left out.
- The recurrence moves any far enough right for the series to reach the precision asked.
- The reflection formula handles the far left.
The computation goes through , which is entire, so nothing is divided until the last step. gamma refuses at the poles 0, −1, −2, …; rgamma is 0 there. logGamma, for Re z > 0, is the branch that is real on the positive axis, which is not always the principal logarithm of Γ(z).
Zeta
For Re s ≥ 0 the Euler–Maclaurin formula, with any and :
and are chosen so that the bound is below the precision wanted. To the left of Re s = 0 the functional equation is used. As with gamma, the work is done on the entire function , exported as zetaTimesSMinus1.
Enclosures in, models in
Give a Rect or a Disc and the result encloses every value over it. Give a Taylor model, or write gamma(z) or zeta(z) in a formula, and the result is a model of the function on the disc, with the remainder bounds above taken over the whole disc. That is what lets the rest of the package work on them:
residue("gamma(z)", -3, { radius: "1/2" }); // -0.16666666667: the residue at −n is (−1)ⁿ/n!
residue("zeta(z)", 1, { radius: "1/2" }); // 1
singularities("gamma(z)", rect([-7/2, 1], [-1, 1])); // simple poles at 0, −1, −2, −3
countZeros("zeta(z)", rect([0, 1], [10, 30])); // 3
The zeros of zeta, and the Riemann hypothesis for each
zetaZeros(t1, t2) finds every zero with imaginary part between t1 and t2. The search is zeros on the strip 0 ≤ Re s ≤ 1, so each zero is isolated, proved simple, and the count is proved complete.
Then each zero is shown to lie on the critical line Re s = 1/2 exactly, not merely near it. The functional equation and pair every zero with , its mirror image in the critical line. Take a small disc centred on the line. It is its own mirror image. If it is proved to hold exactly one zero, that zero is its own mirror image, and so its real part is 1/2. The proof that the disc holds exactly one zero is Rouché's theorem on a Taylor model of ζ, zeroCount() === 1.
Each entry's onCriticalLine records whether that proof went through, and allOnCriticalLine is the hypothesis verified for the range searched.
| call | returns |
|---|---|
| gamma(z, { bits }), rgamma(z), logGamma(z) | A Rect (or a model, for a model) |
| zeta(s, { bits }), zetaTimesSMinus1(s) | A Rect (or a model) |
| zetaZeros(t1, t2, { bits }) | { zeros: [{ t, enclosure, onCriticalLine }], count, complete, allOnCriticalLine }; t is the interval holding the zero's height |
@ratmath/complex and Core's Rational in scope. The last line's value is shown; PRINT(…) adds lines, TEX(…) typesets math.