XLPack 6.1
Excel Worksheet Function Numerical Library Reference Manual
Loading...
Searching...
No Matches

◆ WCost1f()

Function WCost1f ( N As  Long,
R As  Variant 
)

One-dimensional cosine transform

Purpose
WCost1f computes the one-dimensional Fourier transform of an even sequence within a real array. This is referred to as the forward transform or Fourier analysis, transforming the sequence from physical to spectral space.
R(0) = (1/2)R(0)/(N-1) + ΣR(j)/(N-1) + (1/2)R(N-1)/(N-1) (Σ for j = 1 to N-2)
R(k) = R(0)/(N-1) + Σ2x[j)cos(πjk/(N-1)) + (-1)^k R(N-1)/(N-1) (Σ for j = 1 to N-2) (k = 1 to N-2)
R(N-1) = (1/2)R(0)/(N-1) + ΣR(j)(-1)^k/(N-1) + (1/2)(-1)^(N-1) R(N-1)/(N-1) (Σ for j = 1 to N-2)
This transform is normalized since a call to WCost1f followed by a call to WCost1b (or vice-versa) reproduces the original array subject to algorithmic constraints, roundoff error, etc.
Returns
N x 1
Column 1
Rows 1 to NCosine transformed data sequence
Parameters
[in]NThe length of the sequence to be transformed. (N >= 1)
The transform is most efficient when N - 1 is a product of small primes.
[in]R(N) The sequence to be transformed.
Reference
FFTPACK
Example
Compute the cosine transform of the data sequence by WCost1f. Then compute its backward transform by WCost1b and confirm that the original data sequence is restored.

WCost1f

WCost1b