Reference

Everything in the library

Every export of @ratmath/symbolic, with what it takes and what it returns. Anything called x, a or b below is text, an Expr, a number or a tree; options.assume is an Assumptions object or the description assume takes.

Expressions

ExportWhat it does
sym(x)An Expr from text, a number, a tree or an Expr.
Expr.tree, .variables, toString(), toTeX(), subs(map), diff(name), evaluate(values, bits), approx(values), same(other), and every operation below as a method: expand factor collect apart simplify normal rewrite equals sign.
tree(x)The plain tree of anything read as an expression.
substitute(x, map)Replace variables by expressions, all at once. Returns a tree.
evaluate(x, values, bits)A certified enclosure (a Core RationalInterval) of the value at exact values of the variables. Throws where undefined.
toTeX(x)TeX for an expression.
parse, format, differentiateAnalytic's parser, printer and derivative, on plain trees.
num, v, op, callBuilders for tree nodes.

Assumptions

ExportWhat it does
assume(spec)An Assumptions object from { name: fact }. A fact is a word (positive negative nonnegative nonpositive nonzero integer real), a comparison ("> 2"), an interval ("in (0, 1]"), a Core chain, a [lo, hi] pair, a RationalInterval or a Region; several joined by commas.
A.sign(x)"positive" "negative" "zero" "nonnegative" "nonpositive" "nonzero" or "unknown".
A.range(x)A range certain to contain the expression: { lo, hi, loClosed, hiClosed } with null for an unbounded end.
A.proves(condition)true (proven), false (proven false) or null (undecided) for "u > v", >=, <, <=, !=, = or "integer(u)".
A.isInteger(x)True when the expression is certainly a whole number.
A.samples(names, count)Exact test points that satisfy the assumptions.
A.and(spec)The assumptions with more added.

Normal form

ExportWhat it does
expand(x, options)The normal form: one fraction, multiplied out, common factors cancelled. Also exported as together and cancel.
normal(x, options){ expr, numerator, denominator, cancelled, kernels }. cancelled lists what was divided out.
factor(x, options)Numerator and denominator factored over the rationals; kernels count as variables.
collect(x, name, options)Grouped by powers of one variable.
apart(x, name, options)Partial fractions over the rationals, for a rational function of one variable.
isZero(x, options)true when the normal form is 0, "nonzero" when it is a nonzero number, otherwise false (nothing proven).
simplify(x, options)The smallest of the normal form, the factored form and the normal form after the provable rules.

Rules

ExportWhat it does
rule(from, to, { when, where, name })A rule. Pattern variables end in _. when lists conditions such as "a_ > 0".
rewrite(x, rules, options){ expr, steps, blocked, conditions }. Options: assume, conditional (apply undecided rules and return their conditions), maxSteps, check, tidy.
match(pattern, target)The bindings that make the pattern equal to the target, or null.
rulesrules.powers, rules.logs.expand, rules.logs.combine, rules.trig.expand, rules.trig.reduce, rules.hyperbolic.
spotCheck(a, b, A, count, bits)Compare two expressions at exact test points: { agreed, refuted }.

Equality

ExportWhat it does
equal(a, b, options)A Verdict: verdict is "equal", "different" or "undecided"; method; witness for different; agreedAt for undecided; value is true, false or null.

Solving

ExportWhat it does
solve(equation, name, options)A Solutions object for "lhs = rhs" (or an expression, meaning = 0) in one variable over the reals. Options: assume, range: [lo, hi] (keep solutions in the range and list the members of periodic families), interval: [a, b] (search for certified sign changes when no method applies).
Solutionssolutions, rejected ({ value, reason } for candidates that failed the check), complete, all, set (a RealSet when the solutions fill intervals), conditions, notes, steps, values. Iterable.
Solutionvalue, kind ("exact", "algebraic", "numeric"), verified ("proven", "sign change", "enclosed"), period and member(n) for a family, where, enclosure(bits), approx().
solveInequality(inequality, name, options)The RealSet where <, <=, >, >= or != holds. Options: assume, range (needed for periodic inequalities).
solveSystem(equations, variables, options)A SystemSolutions object for a list of equations in several unknowns (default: every letter, sorted). Linear systems by Gauss–Jordan with letters allowed in the coefficients; others by substitution and resultants. Option assume.
SystemSolutionsvariables, kind ("linear" or "nonlinear"), solutions (each { values: { x: Expr, … }, free, verified }; a free unknown is its own value), rejected, complete, conditions, notes, steps. Iterable.
RealSetpieces ({ lo, hi, loClosed, hiClosed }, null for an unbounded end), isEmpty, isAll, contains(q), intersect(other), union(other), complement(), toRegionText(). solveInequality reads a chain a < b <= c as the intersection.
solutions.within(lo, hi)The solutions in an interval, families listed member by member, as Exprs in order; within("[0, 2*pi)") for open and closed ends.

Calculus

ExportWhat it does
integrate(f, name, options)An Antiderivative: found, result, verified ("proven" or "checked"), checkedAt, steps. With { from, to } also value (exact, or null when F(b) − F(a) is not the integral), enclosure (certified quadrature, for rational ends), agrees, note. Option assume.
limit(f, name, at, options)A Limit: kind ("finite", "inf", "-inf", "none", "numeric", "unknown"), value, method, confirmed, enclosure, reason. at is an expression, "inf" or "-inf"; option side: "left" | "right".
taylor(f, name, about, order){ polynomial, coefficients, lowest, order, about }: exact coefficients of (x − about)^(lowest + i); lowest is negative at a pole.
sum(f, index, from, to, options)A Sum: value (an Expr, "inf", "-inf" or null), antidifference (proven, or null), method, verified ("proven", "checked" for a table value, or null), diverges, conditions, steps, note. to may be "inf". Option assume.
eliminate(curve, parameter = "t"){ equation, standard, equations, dropped, method, verified, steps }: the equation of a parametrised curve by resultants (rational, sin/cos or exp in the parameter), each factor tested against the parametrisation. See Eliminating a parameter
reverseOrder(f, { outer, inner }){ pieces, text, original, reversed, value, agree }: the region of an iterated integral with the other variable outside, and both integrals compared. See Eliminating a parameter
implicitDiff(F, x = "x", y = "y", { order }){ first, second, steps, at(point) }: y′=−Fx/Fyy' = -F_x/F_y for a curve "lhs = rhs", and y′′y'' with order: 2. See School algebra.
leibniz(f, t, lower, upper, x = "x")ddx∫a(x)b(x)f dt\frac{d}{dx}\int_{a(x)}^{b(x)} f\,dt: { value, boundary, integral, steps }.
Expr methods.solve(name, options), .integrate(name, options), .limit(name, at, options), .taylor(name, about, order).

School algebra

ExportWhat it does
completeSquare(expr, x = "x"){ form, a, h, k, vertex, verified }: a(x−h)2+ka(x-h)^2 + k, checked by expanding.
compose(f, g, x = "x"){ value, unsimplified, domain, note }: f(g(x))f(g(x)), with the set where it is defined and a note when gg leaves the domain of ff.
sinusoid(expr, x = "x"){ fn, amplitude, A, B, C, D, period, frequency, phaseShift, midline, form, verified } for Asin⁡(Bx+C)+DA\sin(Bx + C) + D, also from asin⁡+bcos⁡a\sin + b\cos.

Step records

ExportWhat it does
explain.op(…)For op one of expand, factor, collect, apart, simplify, rewrite, equal, solve, solveInequality, solveSystem, integrate, limit, taylor, sum: run it with the same arguments and return a Derivation.
Derivationoperation, input, result (what the operation returns), steps, omitted (steps that could not be checked and are not shown), toString(), toTeX(). Iterable over its steps.
Steprule, detail, from and to (Exprs, for a step between two expressions), check ("proven", "test points", "by the result"), checkedAt.
expr.explain(op, …args)The same as explain[op](expr, …args).

Errors and plan

ExportWhat it does
SymbolicErrorThrown with a code: domain, division-by-zero, bad-rule, not-polynomial, not-univariate, too-large.
planThe phases still to come: empty, since all five are built.
Try itEdit the code and run it with @ratmath/symbolic and Core's Rational in scope. The last line's value is shown; PRINT(…) adds lines, TEX(…) typesets math.
Ctrl/⌘ + Enter runs