Victor,
1) why Y = y[0]/N; is inside of i-loop? So in every iteratin Y value is reset...
The i-loop goes over the domain on which I am evaluating the series: n=1000 points, so it's nice and smooth to plot. The i-loop should look like (my mistake)
for ( i = 0; i < n; i++ )
2) why N and n ? But, N is number of points...
N would be the number of discrete points of the finite series approximation.
-------
Let me try to give a simple example of what I'm trying to do:
Let the input function be sin(x) of which I'm evaluating at N=4 discrete points over the interval x=[0...1), to get the discrete sequence:
double y[N+2];
for ( i = 0; i < N; i++ )
y = sin(2.0*PI*i/N);
which fills the first N elements of the array as y[] = {0.0, 1.0, 0.0, -1.0}.
Then, I do an in-place forward transform and I get the CCS array:
y[] = {0.0, 0.0, -0.0, -2.0, 0.0, 0.0},
which is to be interpreted as the complex sequence of (N+2)/2 = 3 complex numbers as
Z[] ={ 0.00+0.00i, -0.00-2.00i, 0.00+0.00i}.
Now, if I understand correctly, the above array Z contains:
- the first complex coefficient: R0 + 0.0i = 0.0 + 0.0i,
- the first half of the full sequence, which for N=4 is: R1 + I1 = -0.0 - 2.0i and R2 + I2 = 0.0 + 0.0i,
- plus the (would-be-redundant) symmetric conjugate half "sequence": R3 + I3 = -0.0 + 2.0i.
I think so far my interpretation is correct and this is the correct result.
Now, my question is how to interpret (and use) this sequence to evaluate the first N members of the sum in the discrete Fourier series:
f(x) ~ sin(x) = sum_{j=0}^{N-1} Z_j * exp(2 * PI * i * j * x).
(I'm evaluating the x in n=1000 discrete points with the i-loop just to plot f(x).)
Maybe j should go from -N/2 to N/2-1 ?
Thanks for your help,
Jozsef