polylib::minpoly -- approximate
minimal polynomial
Introductionpolylib::minpoly(a, n, x) computes a
univariate polynomial f in the variable x of
degree n with integer coefficients such that
a equals a root of f up to the precision
given by DIGITS, and such that the sum of squares of its
coefficients is minimal among all polynomials with this property.
Call(s)polylib::minpoly(a, n, x)
Parametersa |
- | arithmetical expression that can be converted to a floating point number |
n |
- | positive integer |
x |
- | identifier |
Returnspolylib::minpoly returns a polynomial in
x. Its coefficient ring is Expr, all of its
coefficients are integers.
Side
Effectspolylib::minpoly is sensitive to the environment
variable DIGITS.
Related
Functionslllint, stats::linReg, numeric::lagrange
Example
1We compute a polynomial of degree 4 that has a root
close to PI (up to 6
decimal digits) and small integer coefficients:
>> DIGITS:=6: polylib::minpoly(PI, 4, x); delete DIGITS:
4 3 2
poly(7 x - 16 x - 16 x - 6 x - 9, [x])
If the root has to be even closer to PI, bigger coefficients are needed:
>> DIGITS:=20: polylib::minpoly(PI, 4, x); delete DIGITS
4 3 2
poly(- 1951 x + 6379 x - 422 x + 283 x - 4468, [x])
Backgroundnumeric::minpoly