Reverse of a univariate polynomial #
The main definition is reverse
. Applying reverse
to a polynomial f : R[X]
produces
the polynomial with a reversed list of coefficients, equivalent to X^f.natDegree * f(1/X)
.
The main result is that reverse (f * g) = reverse f * reverse g
, provided the leading
coefficients of f
and g
do not multiply to zero.
If i ≤ N
, then revAt N i
returns N - i
, otherwise it returns i
.
Essentially, this embedding is only used for i ≤ N
.
The advantage of revAt N i
over N - i
is that revAt
is an involution.
Equations
- Polynomial.revAt N = { toFun := fun i => if i ≤ N then N - i else i, inj' := (_ : Function.Injective (Polynomial.revAtFun N)) }
Instances For
reflect N f
is the polynomial such that (reflect N f).coeff i = f.coeff (revAt N i)
.
In other words, the terms with exponent [0, ..., N]
now have exponent [N, ..., 0]
.
In practice, reflect
is only used when N
is at least as large as the degree of f
.
Eventually, it will be used with N
exactly equal to the degree of f
.
Equations
- Polynomial.reflect N x = match x with | { toFinsupp := f } => { toFinsupp := Finsupp.embDomain (Polynomial.revAt N) f }
Instances For
The reverse of a polynomial f is the polynomial obtained by "reading f backwards".
Even though this is not the actual definition, reverse f = f (1/X) * X ^ f.natDegree
.