I’d like to share stair-division, a small package for synthetic division (Ruffini’s rule). You provide a polynomial’s coefficients and a value a; it computes the division by (x - a) and draws the three-row tableau, including the products, running sums, and boxed remainder.
It also supports successive divisions as a stacked staircase, with a factorization line when every remainder is zero. This can be useful for algebra worksheets, solutions, and teaching the method.
#import "@preview/stair-division:0.1.0": ruffini, ruffini-factor
// Divide x³ - 2x² + 1 by (x - 2), with teaching arrows.
#ruffini((1, -2, 0, 1), 2, trail: true)
// Factor x³ - 6x² + 11x - 6 using the supplied roots.
#ruffini-factor((1, -6, 11, -6), (1, 2, 3))
Options include rational coefficients and roots, a custom variable, colors, and English or Spanish labels (lang: "es"). Use quoted fractions such as "1/3" to specify rational inputs exactly. Roots must be supplied; the package does not search for them.
The package uses native Typst tables, has no dependencies, is MIT-licensed, and works with Typst 0.14.0 and later.
Version 0.1.0 is already available on Universe. A 0.1.1 patch is under review, fixing repeated zero roots and tightening fraction-string and float handling. The example above uses the currently published version.
Feedback and examples of how you use it in teaching materials are welcome.
