Your own series
Many functions are known by their power series and nothing else: special functions, generating functions, solutions found by undetermined coefficients. series turns coefficients aₖ into a Taylor model, f(x) = Σ aₖ (x − c)ᵏ, on a domain you choose. The hard part is the remainder: the coefficients alone never prove how big the tail Σ over k > p is. So series asks you to name the argument, checks what a computer can check, and records what it cannot.
Four rules for the tail
| Rule | Hypothesis | Tail bound | What is checked |
|---|---|---|---|
alternating | the terms aₖ(x − c)ᵏ alternate in sign and shrink in size | between 0 and the first omitted term | the next 32 terms, for every x in the domain |
ratio | |aₖ₊₁|·r ≤ q·|aₖ| beyond p, with q < 1 and r the radius of the domain | at most the first omitted term divided by 1 − q | the next 32 terms |
lagrange | you give M ≥ max |f⁽ᵖ⁺¹⁾| on the domain | M·rᵖ⁺¹/(p+1)! | nothing: M is your claim |
explicit | you give the error bound | your bound | nothing |
A computer can check finitely many terms, and a rule is about all of them. So a model built with any rule is marked assumed, and describe() lists exactly what was assumed. A rule that fails on the checked terms is refused.
import { series, Domain } from "@ratmath/analytic";
import { R } from "@ratmath/core";
const D = Domain(R`0:1/2`, { centre: 0 });
// log(1 + x) = x − x²/2 + x³/3 − …
const L = series(D, { coefficient: (k) => (k === 0 ? R`0` : R`${k % 2 ? 1 : -1}/${k}`), degree: 20, order: 20, rule: "alternating" });
L.at(R`1/4`); // encloses log(5/4)
L.assumed; // true: terms beyond the next 32 are assumed to keep alternating
L.describe();
// e^x with Lagrange: on [0, 1/2] every derivative of e^x is below 2
series(D, { coefficient: (k) => R`1/${fact(k)}`, degree: 15, order: 15, rule: "lagrange", M: 2 });
The alternating rule really is checked: on [−1/2, 1/2] the log(1 + x) series is refused, because for negative x every term is negative.
Worked check: log(1 + x) at 1/4
Keep degree 16 on [0, 1/2]. The first omitted term is at most (1/2)¹⁷/17 ≈ 5.8·10⁻⁷ anywhere on the domain, so the model's remainder is about that wide. At x = 1/4 alone the error is far smaller, (1/4)¹⁷/17 ≈ 3.4·10⁻¹², but a model promises a bound for the whole domain, and evaluating it at a point keeps the domain-wide remainder. For a sharper value at one point, use a narrower domain or a higher degree. The built-in log gets log(5/4) from its own series, so the two enclosures must overlap; the demo compares them.
Build one from a formula
Write the coefficient as a formula in k and choose a rule. The coefficients must come out as exact rationals.
Once you have the model
A series model is an ordinary Taylor model, so everything on the Taylor models page applies: compose it with exp or sin, multiply it by other models, take its range or integral. The assumption travels with it, and describe() on the final result still says what was assumed.
@ratmath/analytic and Core's R, Rational, RationalInterval in scope. The last line's value is shown; PRINT(…) adds lines, TEX(…) typesets math.