Please help with creating the code as follows: Task 1: Write a program DFT-Horner to evaluate a given polynomial at the n complex roots of unity using Horner’s rule. This is just computing the DFT of the coefficients of the polynomial.Input: Input for this program will be the coefficients of the polynomial represented as a sequence of n (complex) numbers in a file, where each component is a double. (A real coefficient will be represented by a single component, and a complex coefficient will be represented by two components.)Output: Output for this program will be the evaluations of the polynomial a(x) at the n complex roots of unity, i.e., DF Tn(a). The program should output the n components of the DFT. Each component should contain both real and imaginary parts, both rounded to 3 decimal places.Example: The polynomial a(x) = 1+2x+3x2 can be represented as a coefficient vector a = (1.000, 2.000, 3.000). The DFT of the coefficients of a is the vector (6.000 + 0.000i, −1.500 − 0.866i, −1.500 + 0.866i).Hint: Python has built-in support for complex data types. If you are coding in Java, create a “Com-plexNumber” class to represent a complex number. It should have two variables, real and imaginary, bothof type double. It should also contain relevant complex number operations like addition, multiplication, reading from the input stream, writing to the output stream, etc. This will be useful for the above function and for the FFT function later. The part below is meant ot help you with what I am looking for when you create the code Example Task 1: DFT of a polynomial DFT-Horner <input_file.txt> <output_file.txt>where input_file.txt contains the polynomial coefficients, this query should read the coefficients from input_file.txt, compute the DFT of the polynomial coefficients, and output the result tooutput_file.txt.Example:task1_input.txt1.0002.0003.000DFT-Horner task1_input.txt task1_output.txttask1_output.txt6.000 0.000-1.500 -0.866-1.500 0.866 Note: n=3 in this example

icon
Related questions
Question

Please help with creating the code as follows:

Task 1: Write a program DFT-Horner to evaluate a given polynomial at the n complex roots of unity using Horner’s rule. This is just computing the DFT of the coefficients of the polynomial.
Input: Input for this program will be the coefficients of the polynomial represented as a sequence of n (complex) numbers in a file, where each component is a double. (A real coefficient will be represented by a single component, and a complex coefficient will be represented by two components.)
Output: Output for this program will be the evaluations of the polynomial a(x) at the n complex roots of unity, i.e., DF Tn(a). The program should output the n components of the DFT. Each component should contain both real and imaginary parts, both rounded to 3 decimal places.
Example: The polynomial a(x) = 1+2x+3x2 can be represented as a coefficient vector a = (1.000, 2.000, 3.000). The DFT of the coefficients of a is the vector (6.000 + 0.000i, −1.500 − 0.866i, −1.500 + 0.866i).
Hint: Python has built-in support for complex data types. If you are coding in Java, create a “Com-plexNumber” class to represent a complex number. It should have two variables, real and imaginary, both
of type double. It should also contain relevant complex number operations like addition, multiplication, reading from the input stream, writing to the output stream, etc. This will be useful for the above function and for the FFT function later.

The part below is meant ot help you with what I am looking for when you create the code

Example Task 1: DFT of a polynomial

DFT-Horner <input_file.txt> <output_file.txt>
where input_file.txt contains the polynomial coefficients, this query should read the coefficients from input_file.txt, compute the DFT of the polynomial coefficients, and output the result to
output_file.txt.
Example:
task1_input.txt
1.000
2.000
3.000
DFT-Horner task1_input.txt task1_output.txt
task1_output.txt
6.000 0.000
-1.500 -0.866
-1.500 0.866

Note: n=3 in this example

AI-Generated Solution
AI-generated content may present inaccurate or offensive content that does not represent bartleby’s views.
steps

Unlock instant AI solutions

Tap the button
to generate a solution