How to Compute a Discrete-Fourier Transform Coefficients Directly in Java?
The Discrete Fourier Transform (DFT) generally varies from 0 to 360. There are basically N-sample DFT, where N is the number of samples. It ranges from n=0 to N-1. We can get the co-efficient by getting the cosine term which is the real part and the sine term which is the imaginary part.
The formula of DFT:
Input: Enter the values of simple linear equation ax+by=c 3 4 5 Enter the k DFT value 2 Output: (-35.00000000000003) - (-48.17336721649107i) Input: Enter the values of simple linear equation ax+by=c 2 4 5 Enter the k DFT value 4 Output: (-30.00000000000001) - (-9.747590886987172i)
- First, let us declare the value of N is 10
- We know the formula of DFT sequence is X(k)= e^jw ranges from 0 to N-1
- Now we first take the inputs of a, b, c, and then we try to calculate in “ax+by=c” linear form
- We try to take the function in an array called ‘newvar’.
newvar[i] = (((a*(double)i) + (b*(double)i)) -c);
- Now let us take the input variable k, and also declare sin and cosine arrays so that we can calculate real and imaginary parts separately.
- Now let us take real and imaginary variables
- Calculating imaginary variables and real variables like
- Now we will print this output in a+ ib form
Enter the values of simple linear equation ax+by=c Enter the k DFT value (-35.00000000000003) - (-48.17336721649107i)
Time complexity: O(n)
Auxiliary space: O(n) for array