genpoly -- create a polynomial
using the ``b''-adic expansion
Introductiongenpoly(n, b, x) creates a polynomial
p in the indeterminate x such that
p(b)=n.
Call(s)genpoly(n, b, x)
Parametersn |
- | an integer, a polynomial of type DOM_POLY, or a polynomial expression |
b |
- | an integer greater than 1 |
x |
- | the indeterminate: an identifier |
Returnsa polynomial if the first argument is a polynomial or an integer. Otherwise, a polynomial expression.
Related
Functionsgenident, indets, int2text, mods, numlib::g_adic, numeric::lagrange, poly, text2int
Detailsgenpoly(n, b, x) creates a polynomial p in the variable
x from the b-adic expansion of
n, such that p(b)=n. The integer coefficients
of the resulting polynomial are greater than -b/2 and less
than or equal to b/2.mods). From this expansion the
polynomial p=sum(c[i]*x^i, i=0..m) is created. The
polynomial is defined over the coefficient ring Expr.genpoly is a (multivariate)
polynomial, then it must be defined over the
coefficient ring Expr and
must have only integer coefficients. The third argument x
must not be a variable of the polynomial. In this case each integer
coefficient is converted into a polynomial in x as
described above. The result is a polynomial in the variable
x, followed by the variables of the given polynomial.
(x is the main variable of the returned polynomial.)n may also be a polynomial expression. In this case, it is converted
into a polynomial using poly, then genpoly is
applied as described above, and the result is again converted into a
polynomial expression.DOM_POLY; otherwise it is a
polynomial expression.genpoly is a function of the system kernel.
Example
1We create a polynomial p in the
indeterminate x such that p(7) = 15. The
coefficients of p are between -3 and
3:
>> p := genpoly(15, 7, x)
poly(2 x + 1, [x])
>> p(7)
15
Here is an example with a polynomial expression as input:
>> p := genpoly(15*y^2 - 6*y + 3*z, 7, x)
2 2
y + 3 z - x y + y + 2 x y
The return value has the same type as the first argument:
>> p := genpoly(poly(15*y^2 + 8*z, [y, z]), 7, x)
2 2
poly(2 x y + x z + y + z, [x, y, z])
We check the result:
>> p(7, y, z)
2
8 z + 15 y