Softanza
StartFrançais
Softanza
The library documents itself · Numeric & optimization

stzPolynomial

23 own methods · 7 forms written with extensions, listed under their method

the source: base/number/stzPolynomial.ring(opens in a new tab) · All classes · The area reference: Numeric & optimization

Under each method, its extensions (Q CS XT Z ZZ IB W U): bold and ticked, it exists; struck, it does not. The extensions and what they mean

Examples: 0 come from the library's tests; 18 were composed from each method's signature and run for this page, on a fresh object, for example o1 = new stzPolynomial([1, -3, -5, 5, -6, 8]). 5 methods have none yet. Examples run on 2026-10-03 12:54 inside the library at commit 0e72e2e2c.

Method
Explanation, as the source carries it
init
(no comment in the source: the name reads as a sentence) initno extension
Coefficients
READING THE POLYNOMIALalso written: Coeffsno extension
Degree
The degree: 0 for a constant, n for x^n. The zero polynomial has no meaningful degree; it answers 0.
composed example
o1 = new stzPolynomial([1, -3, -5, 5, -6, 8])
? o1.Degree()
#--> 5
composed from the signature, run for this page
no extension
LeadingCoefficient
(no comment in the source: the name reads as a sentence) leading coefficientalso written: Leading
composed example
o1 = new stzPolynomial([1, -3, -5, 5, -6, 8])
? o1.LeadingCoefficient()
#--> 1
composed from the signature, run for this page
no extension
IsMonic
(no comment in the source: the name reads as a sentence) is monic
composed example
o1 = new stzPolynomial([1, -3, -5, 5, -6, 8])
? o1.IsMonic()
#--> 1
composed from the signature, run for this page
no extension
IsZeroPolynomial
(no comment in the source: the name reads as a sentence) is zero polynomial
composed example
o1 = new stzPolynomial([1, -3, -5, 5, -6, 8])
? o1.IsZeroPolynomial()
#--> 0
composed from the signature, run for this page
no extension
Monic
The same polynomial scaled to leading coefficient 1 -- the form the companion matrix needs.QCSXTZZZIBWU
ValueAt
EVALUATION ------------------------------------------------------ p(x) by Horner's rule -- n multiplications, and numerically the steadiest way to evaluate a polynomial.also written: At · Eval
composed example
o1 = new stzPolynomial([1, -3, -5, 5, -6, 8])
? o1.ValueAt(2)
#--> -40
composed from the signature, run for this page
no extension
Derivative
p'(x)'s coefficients: the power rule, term by term.
composed example
o1 = new stzPolynomial([1, -3, -5, 5, -6, 8])
? @@( o1.Derivative() )
#--> [ 5, -12, -15, 10, -6 ]
composed from the signature, run for this page
QCSXTZZZIBWU
CompanionMatrix
Assembled by the engine, not here. It looks like four lines of glue -- the sign, which row carries the coefficients, the monic division, the leading-zero case -- and every one of those is a decision a second implementation gets subtly differently. poly.zig owns it, so every language over the engine builds the same matrix.
composed example
o1 = new stzPolynomial([1, -3, -5, 5, -6, 8])
? @@( o1.CompanionMatrix() )
#--> [ [ 3, 5, -5, 6, -8 ], [ 1, 0, 0, 0, 0 ], [ 0, 1, 0, 0, 0 ], [ 0, 0, 1, 0, 0 ], [ 0, 0, 0, 1, 0 ] ]
composed from the signature, run for this page
QCSXTZZZIBWU
ComplexRoots
Past degree four no formula exists, so the general method is the companion matrix's eigenvalues -- and that whole chain lives in poly.zig over eigen_general.zig's Francis QR. This method binds arguments and marshals; it does not assemble a matrix and it does not decide anything.also written: Roots
composed example
o1 = new stzPolynomial([1, -3, -5, 5, -6, 8])
? @@( o1.ComplexRoots() )
#--> [ @noname, @noname, @noname, @noname, @noname ]
composed from the signature, run for this page
no extension
RealRootsWithin
(no comment in the source: the name reads as a sentence) real roots within
composed example
o1 = new stzPolynomial([1, -3, -5, 5, -6, 8])
? @@( o1.RealRootsWithin(2) )
#--> [ -2.00, -0.00, -0.00, 1.00, 4.00 ]
composed from the signature, run for this page
no extension
RealRoots
(no comment in the source: the name reads as a sentence) real roots
composed example
o1 = new stzPolynomial([1, -3, -5, 5, -6, 8])
? @@( o1.RealRoots() )
#--> [ -2.00, 1.00, 4.00 ]
composed from the signature, run for this page
no extension
NumberOfRealRoots
(no comment in the source: the name reads as a sentence) number of real roots
composed example
o1 = new stzPolynomial([1, -3, -5, 5, -6, 8])
? o1.NumberOfRealRoots()
#--> 3
composed from the signature, run for this page
no extension
HasRealRoot
(no comment in the source: the name reads as a sentence) has real root
composed example
o1 = new stzPolynomial([1, -3, -5, 5, -6, 8])
? o1.HasRealRoot()
#--> 1
composed from the signature, run for this page
no extension
HasComplexRoot
TRUE when any root is genuinely complex (beyond the tolerance).
composed example
o1 = new stzPolynomial([1, -3, -5, 5, -6, 8])
? o1.HasComplexRoot()
#--> 1
composed from the signature, run for this page
no extension
Plus
ARITHMETIC
composed example
o1 = new stzPolynomial([1, -3, -5, 5, -6, 8])
? @@( o1.Plus([ 2, 3 ]) )
#--> [ 1, -3, -5, 5, -4, 11 ]
composed from the signature, run for this page
QCSXTZZZIBWU
Minus
(no comment in the source: the name reads as a sentence) minus
composed example
o1 = new stzPolynomial([1, -3, -5, 5, -6, 8])
? @@( o1.Minus([ 2, 3 ]) )
#--> [ 1, -3, -5, 5, -8, 5 ]
composed from the signature, run for this page
QCSXTZZZIBWU
Times
THE DOUBLE LOOP IS KEPT FOR SMALL DEGREES, and not out of caution: it is EXACT for integer coefficients, while the FFT route goes through irrational twiddle factors and comes back a few rounding errors away from a whole number. Below the crossover the direct method is both faster and more accurate, so preferring it is not a compromise. Above it, O(n log n) wins by enough that the rounding is worth paying.
composed example
o1 = new stzPolynomial([1, -3, -5, 5, -6, 8])
? @@( o1.Times([ 2, 3 ]) )
#--> [ 2, -3, -19, -5, 3, -2, 24 ]
composed from the signature, run for this page
QCSXTZZZIBWU
TimesViaTransform
The same product through the frequency domain -- exposed so the guard can compare the two routes on the SAME polynomials rather than having to grow one past the crossover to reach this code.
composed example
o1 = new stzPolynomial([1, -3, -5, 5, -6, 8])
? @@( o1.TimesViaTransform([ 2, 3 ]) )
#--> [ 2, -3, -19, -5.00, 3, -2, 24 ]
composed from the signature, run for this page
QCSXTZZZIBWU
Content
DISPLAYno extension
Show
(no comment in the source: the name reads as a sentence) showno extension
ToString
(no comment in the source: the name reads as a sentence) to string
composed example
o1 = new stzPolynomial([1, -3, -5, 5, -6, 8])
? o1.ToString()
#--> x^5 - 3x^4 - 5x^3 + 5x^2 - 6x + 8
composed from the signature, run for this page
no extension