Given a nonzero polynomial with integer coefficients and roots that are on the imaginary and on the real line such that if a
is a root then so is -a
, return another polynomial with the roots rotated by 90 degrees.
Details
The polynomial can be given in any reasonable format, e.g. as a list of coefficients. The symmetry condition that a
is a root if and only if -a
is a root too enforces the rotated polynomial to have real integer coefficients as well.
Examples
In the following the polynomials are given as a list of coefficient of the monomials in descending degree. (i.e. the constant comes last)
The polynomial x^2-1
has roots {1,-1}
. Rotating them by 90°
means multiplying by i
(the imaginary unit), so the output polynomial should have the roots {i,-i}
, which is x^2 + 1
.
Input / Output
[1 0 10 0 -127 0 -460 0 576] [1 0 -10 0 -127 0 460 0 576]
[1 0 -4 0] [1 0 4 0]
[1] [1]
x
, so that my submission can string-replacex
with(i*x)
? Can my format a function that evaluates the polynomial, so that my submission is to compose it with the functionx -> i*x
? \$\endgroup\$