Design decisions

69. std.poly: formal power series over NTT on plain List<Mod<P>> (2026-11-21)

  1. std.poly operates directly on List<Mod<P>> with explicit output length n (inv, log, exp, pow, sqrt, plus deriv, integral).
    • Reason: Using plain List<Mod<P>> (lowest degree first) gives zero-overhead interop with std.ntt.convolve<P>, Comb<M>, and list comprehensions without introducing a wrapper Poly<P> type. Requiring explicit truncation length n: Int (modulo x^n) matches every contest FPS call site (ucup5s06a, ucup5s03a, ucup5s05f) and avoids sentinel defaults. inv uses half-size Newton doubling (5 NTTs of size 2m per step), integral uses linear-time modular inverses 1..=m, pow handles leading zeros and large k via exp(k * log(...)), and sqrt returns ?List<Mod<P>> via Tonelli-Shanks + Newton doubling.
    • Reverse: Remove stdlib/poly.cp, remove its rows from stdlib/README.md, site/content/stdlib.md, editors/vscode/, spec/lib/math.md §2.5, and plan/STDLIB.md, and switch the four migrated ports back to lib.math.poly.