rpoly | R Documentation |
Compute the coefficients of a polynomial with real coefficients, given its real zeroes (roots) and one representative for each complex pair. If complex numbers are given in polar form, there is an option to specify the complex arguments as multiples of π.
rpoly(x = numeric(0), arg = numeric(0), real = numeric(0), argpi = FALSE, monic = TRUE)
x |
if |
arg |
the complex arguments corresponding to the moduli in |
real |
the real roots of the polynomial. This argument is not needed when
|
argpi |
if |
monic |
if |
The complex zeroes of polynomials with real coefficients come in
complex conjugated pairs. Only one representative from each pair
should be supplied to rpoly
. The other is added
automatically. Of course, all real roots should be supplied, if any.
If x
is complex, it should contain all real roots and one
representative for each comple pair.
Otherise, if x
is not complex, it contains the moduli of the
numbers and arg
contains the complex arguments. The two should
be of equal length.
With the default FALSE
for argpi
, the k-th root of the
polynomial is x[k]*cos(arg[k]) + i*x[k]*sin(arg[k])
. If
argpi
is TRUE
it is x[k]*cos(pi*arg[k]) + i*x[k]*sin(pi*arg[k])
.
By default, a monic polinomial (the coefficient of the highest order
term is 1) is created but if monic
is FALSE
, the
constant term of the polynomial is set to 1 .
The options for argpi = TRUE
and/or monic = FALSE
are
convenient in some applications, e.g., time series analysis and
digital signal processing.
a real vector containing the coefficients of the polynomial.
When argpi
is TRUE
, \cos(π a) is computed using
cospi(a)
. So this may differ slightly from the equivalent
result obtained with argpi = FALSE
and b = pi*a
, which
is computed as cos(b) = cos(pi*a)
, see the example.
Georgi N. Boshnakov
sim_numbers
## z-1 rpoly(real = 1) ## roots 1, i, -i; p3(z) = (z-1)(z-i)(z+i) p3 <- rpoly(c(1, 1i)) p3 polyroot(p3) ## using polar for the complex roots (i = e^(i pi/2)) p3a <- rpoly(1, pi/2, real = 1) p3a ## mathematically, p3a is the same as p3 ## but the numerical calculation here gives a slight discrepancy p3a == p3 p3a - p3 ## using argpi = TRUE is somewhat more precise: p3b <- rpoly(1, 1/2, real = 1, argpi = TRUE) p3b p3b == p3 p3b - p3 ## indeed, in this case the results for p3b and p3 are identical: identical(p3b, p3) ## two ways to expand (z - 2*exp(i*pi/4))(z - 2*exp(-i*pi/4)) rpoly(2, pi/4) rpoly(2, 1/4, argpi = TRUE) ## set the constant term to 1; can be used, say, for AR models rpoly(2, pi/4, monic = FALSE) rpoly(2, 1/4, argpi = TRUE, monic = FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.