Problem with results

1

I would like to know, in the program I enter with 10 values, and the program calculates the discrete transform of the cosine-II, using this sequence of 10 numbers:

3
5
7
9
7
5
3
5
8
9

Why the first value of 30.000000 and not 61.000000 ??

Here is the code snippet with the account:

for(i = 0; i < N; i++)
{
    DCT = 0;

    for(j = 0; j < N; j++)
    {
        DCT += vetor[i] * cos((PI/N * (j + 0.5) )* i); //Formula da transformada discreta do cosseno
    }

    printf("%lf\n", DCT);
}
    
asked by anonymous 03.06.2015 / 03:44

1 answer

1
        DCT += vetor[i] * cos((PI/N * (j + 0.5)) * i);

A formula is poorly implemented.

        DCT += vetor[j] * cos((PI/N * (j + 0.5)) * i);
        //           ^
    
03.06.2015 / 10:11