11
1
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]
May I take in the degree of the polynomial as well as the polynomial – Rohan Jhunjhunwala – 2017-05-14T15:19:59.953
Yes I think that is acceptable. – flawr – 2017-05-14T16:01:47.993
All your examples use monic polynomials. Can we assume the input polynomial will be monic? Does the output polynomial have to be monic? – Dennis – 2017-05-14T16:05:20.040
No it can also have other leading coefficients than 1, and the output is also just defined up to a integral multiple. – flawr – 2017-05-14T16:07:53.850
It seems the format doesn't have to be a list of coefficients. How far do the reasonable formats go? Can my format be a string expression in the indeterminate
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
? – xnor – 2017-05-14T19:48:52.720In the coefficient list form, can our output polynomial have leading zeroes? Can the coefficient be floats like
4.0
? Complex numbers like4.0+0j
? – xnor – 2017-05-14T19:57:50.193Yes, any of them are acceptable. – flawr – 2017-05-14T21:11:40.250
@xnor String representations are valid too as long as they produce integer (i.e. real) coefficients. – flawr – 2017-05-15T09:39:20.030