Numbers can be JS integers, bigints, strings such as "3/4" or "0.1" (decimals are exact), Core Rationals, or Core intervals such as R`1/2:1`. Functions marked R return a Refinement: .quick is the float preview, .exact() or await .settle() gives the certified answer. When a hypothesis fails (a log of something that can reach 0, a divisor that can be 0, a point outside the domain), the library throws an AnalyticError with a code and a reason. It does not return a bound it cannot prove.
Formulas
call
returns
notes
fn(text, { variable, params })
AnalyticFunction or PiecewiseFunction
Text, an AST, or the piecewise form "rule if region; …; rule otherwise"
f.value(x, { digits = 20, maxBits = 8192 })
R RationalInterval
a point interval for rational-only formulas; bits double until the digits are met or maxBits is reached
an end at "inf" / "-inf" or where f is undefined; singular lists interior singular points. ±Infinity is a proven divergence; an integral that cannot be decided throws undecided
f.taylor(c, n = 6, { digits })
RationalInterval[]
enclosures of f⁽ᵏ⁾(c)/k! for k = 0…n, n ≤ 16; exact points for rational values; removable quotients are divided as series
f.derivative()
a new function
symbolic and simplified
f.model(D, { order, bits, centre })
TaylorModel
certified on the domain D
f.regular()
a function
the same function with holes of its rational summands cancelled; used by range and integral
f.float(x)
number
no guarantee
f.with({ a: "3/8" })
a new function
other parameter values (sliders)
f.toString()
string
calculator notation that parses back
Grammar: + - * / ^ (or **), parentheses, implicit products (2x, 3(x+1), 2sin(x)), -x^2 = -(x^2), ^ right-associative. Functions: exp log ln log1p sqrt cbrt sin cos tan asin acos atan sinh cosh tanh erf erfc abs min max (arcsin arccos arctan too), sec csc cot sech csch coth asinh acosh atanh (written out in the others as they are read), and the special functions gamma lgamma digamma trigamma beta(a, b) besselJ(n, x) Si fresnelS fresnelC; constants pi e. A name of three or more letters written against a parenthesis, such as foo(x), is refused as an unknown function rather than read as a product. A power with an odd denominator, x^(1/3), is the real root and is defined for negative x. Ranges and integrals may cross points where the function is not smooth (abs, cbrt at 0); there the bounds come from interval evaluation. It is the same grammar and the same plain AST as @ratmath/graphics.
order (rational poles), source: "log" (asymptotes of ln), value (a hole's limit)
extrema(f, [a, b], opts)
max, min, flat, possible, constant
value, unique, touching
inflections(f, [a, b], opts)
inflection, possible
value, unique, touching
simplestBetween(a, b)
Rational
smallest denominator in [a, b]
All four are R. Options: variable, params, tolerance (bracket width, default 10⁻⁶), pieces (starting pieces, 16), maxDepth (48), maxMultiplicity, flatBits, maxBoxes (2000 per piece), maxMs (8000 in all), sliceMs (15). Previews are { kind: "guess", at }. A stretch of the interval with no record certainly holds none.
kind or field
meaning
exact
f(at) = 0 exactly, at a rational point
everywhere, constant
the function is identically zero (for zeros) or constant (for extrema) on [lo, hi]; one record covers the stretch
sign-change
f has opposite proven signs at lo and hi; with unique, exactly one zero inside
isolated
exactly one zero inside, but f keeps its sign (found through sqrt, abs or an even power)
possible
undecided: maybe no zero, maybe several; atMost: m bounds the count with multiplicity
undefined
f is not defined somewhere on the bracket
bound
proven max |f| on a possible bracket of a flat function
budget
the bracket was left when the work budget ran out
touching
f′ (or f″) has the same proven sign at both ends: no feature, or a pair of them inside
Piecewise
call
returns
notes
piecewise([[region, rule], …], opts)
PiecewiseFunction
first matching piece wins
where`2:!x:8`
Region
template tag; values may be interpolated
new Region(text | x => bool, { variable, params })
Region
.test(x), .match(x) → { n }, .intervals(a, b), .breakpoints(a, b)
f is a formula in t and y, an array of formulas for a system (vars names the unknowns), or a JS function (t, y) => model with an optional float twin for previews.
Boundary value problems
call
returns
notes
bvp({ f, interval, left, right, digits = 8, vars, time, params, guess, order })
R BVPSolution
f is y″ as a formula in x, y and dy; each end gives { y } or { dy }. Solved by certified shooting
s.at(x), s.slopeAt(x)
RationalInterval
enclosures of y(x) and y′(x)
s.start, s.unknown, s.linear, s.unique, s.tube
the left-end value that was solved for and which one it is; unique is proven for linear problems; tube is the ODESolution
A region is a box { x: [0, 1], y: [0, 2] }, iterated bounds { x: [0, 1], y: ["0", "x^2"] }, region text such as "0:x:1 && 0:y:x", or a Core MultiRegion (R.region).
f is a formula, a function or a piecewise function; kind is "full", "sine" or "cosine" (half-range)
S.a, S.b, S.coefficient(n), S.amplitude(n)
RationalIntervals
a[0] is a₀, so the mean is a₀/2
S.partial(N)
AnalyticFunction
the partial sum, for plotting
S.value(x, N)
RationalInterval
the partial sum at a point
S.meanSquare(), S.meanSquareError(N)
RationalInterval
(1/L)∫f² and (1/L)∫(f − SN)², by Parseval
Sequences and series
call
returns
notes
sequence(term, { variable = "n", from = 1 })
Sequence
term(n), terms(count), limit(), monotone(), bounds(), limsup(), liminf(), accumulation(), supremum(), infimum(), nFor(ε), series(). n! is read as a factorial. See Sequences
A δ for ε with its proof, and the independent recheck of an nFor or deltaFor certificate. See ε, N and δ
recursive(next, { start, variable = "x" })
RecursiveSequence
terms(count), fixedPoints([a, b]), limit([a, b]) proven by contraction
sum(term, { variable = "n", from = 1 })
Series
partial(N); divergenceTest, ratioTest, rootTest, comparisonTest, integralTest, alternatingTest, tests(); convergence(); termsForError(ε) for alternating series; sum({ digits }) with a proven tail. See Series and convergence tests
powerSeries(coefficient, { index = "n", from = 0, centre = 0 })
PowerSeries
radius(), interval() with both ends examined, partial(N), at(x), value(x), derivative(), integral(). See Power series
taylorRemainder(f, { about, order, on })
{ coefficients, M, radius, bound, actual, holds }
Lagrange's bound beside the true maximum error
functionSequence(term, { variable = "x", index = "n" })
first(), second(), normal(), gaussian(), mean(), at(u, v), area(region). See Surfaces and curvature
metric({ E, F, G }, [u, v])
Metric
christoffel(), gaussian(), geodesic({ from, direction, until }), transport(path, [a, b], vector), geodesicCurvature(path, t), gaussBonnet(region). See Geodesics and Gauss-Bonnet
tidy(tree)
formula tree
quotient of polynomials in variables and calls, with sin² + cos² = 1 used and common factors cancelled
ode.solve({ …, track: false })
skips tracking the initial value, which is faster for a single starting point over a short span
Fourier transforms
call
returns
notes
fourierTransform(f, { convention, support })
FourierTransform
at(ω) as { re, im } enclosures, formula for the standard pairs (checked against the integrals), check(ω), parseval(), inversion(x). See The Fourier transform
inverseFourier(F).at(x)
{ re, im }
from a formula for F
convolution(f, g)
object
at(x) enclosed; theorem(x) checks it against the product of the transforms
heatLine({ k, initial })
object
the heat equation on the whole line: at(x, t), viaTransform(x, t), check(x, t), heat()
dft(values), fft(values)
object
exact in the field of n-th roots of unity; fft counts its multiplications and compares with the definition. See The discrete Fourier transform
the alias frequency, exact samples of a sinusoid, enclosed samples of a formula
Numerical methods, with their true errors
call
returns
notes
floatParts(x, typed?)
object
sign, exponent, mantissa, bits, the exact rational the double is, its ulp and neighbours; with the typed decimal, the exact representation error. See Floating point, exactly
exactOf(x), nearestDouble(q), floatOp(op, a, b)
a double as a rational, the double nearest a rational, and one operation with the rounding it added
roundoff(formula, inputs)
object
the calculation in doubles and exactly, digitsLost, and steps showing where the digits go
iterations each with its true error against the certified root, and the observed order; newton(f, x0, { exact: true }) iterates in exact fractions. See Root-finding methods
a simulated run with fixed steps, backtracking or the exact line search for quadratics; exact fractions for polynomial objectives. See Gradient descent
Euler, Heun, midpoint, RK4 and Adams-Bashforth with the true global error at every step, observed order, and the stability interval. See Euler to Runge-Kutta
[[region, rule], …] or null when the text is not piecewise
Try itEdit the code and run it with @ratmath/analytic and Core's R, Rational, RationalInterval in scope. The last line's value is shown; PRINT(…) adds lines, TEX(…) typesets math.