Expand description
Formal power series representations and algorithms. Formal power series with exact, lazily computed coefficients.
A FormalPowerSeries represents f(x) = Σ_{k≥0} a_k (x − a)^k (or a
Laurent series when f has a pole at a). Every coefficient is an
exact symbolic expression (Ex) — rational numbers for elementary
functions with rational Maclaurin coefficients, expressions such as
2/√π or ln 2 otherwise.
§Design
Coefficients are computed lazily and memoised; there is no fixed truncation order. A series is one of:
- a closed-form series (
exp,sin,cos,sinh,cosh,tan,tanh,atan,atanh,asin,asinh,erf,W,ln(a + c·xᵐ),(a + c·xᵐ)^α), whosek-th coefficient — and general termgeneral_term— are known in closed form; - an engine series for any other expression, expanded on demand by
the truncated-series engine behind
Ex::series(poles are allowed: negative exponents are available throughtruncate); - an explicit polynomial (finite coefficient list);
- a derived series:
add,sub,mul,scale,compose,derivative,integral,inverse(1/f, needsf(a) ≠ 0) orreversion(compositional inverse by Lagrange inversion, needsf(a) = 0,f'(a) ≠ 0) of other series. Derived coefficients are computed from the operands’ coefficients exactly, to any index.
Series are created with Ex::fps /
Ex::fps_maclaurin or
FormalPowerSeries::from_coefficients.
use symplex::prelude::*;
let ctx = Context::new();
let x = ctx.symbol("x");
let e = x.exp().fps_maclaurin(&x);
assert_eq!(e.coefficient(5).to_string(), "1/120");
assert_eq!(e.truncate(4).to_string(), "1/6*x^3 + 1/2*x^2 + x + 1");
// (e^x)² = e^{2x}: a_3 = 8/6 = 4/3
let sq = e.mul(&e).unwrap();
assert_eq!(sq.coefficient(3).to_string(), "4/3");Structs§
- Formal
Power Series - A formal power series
Σ a_k (x − point)^kwith exact, lazily computed coefficients. See the module docs for the design.