FourierDCT[list]
finds the Fourier discrete cosine transform of a list of real numbers.
FourierDCT[list,m]
finds the Fourier discrete cosine transform of type m.
FourierDCT
FourierDCT[list]
finds the Fourier discrete cosine transform of a list of real numbers.
FourierDCT[list,m]
finds the Fourier discrete cosine transform of type m.
Details
- Possible types m of discrete cosine transform for a list
of length
giving a result
are: -
1 (DCT-I) 
2 (DCT-II) 
3 (DCT-III) 
4 (DCT-IV) 
- FourierDCT[list] is equivalent to FourierDCT[list,2].
- The inverse discrete cosine transforms for types 1, 2, 3, and 4 are types 1, 3, 2, and 4, respectively.
- The list given in FourierDCT[list] can be nested to represent an array of data in any number of dimensions.
- The array of data must be rectangular.
- If the elements of list are exact numbers, FourierDCT begins by applying N to them.
- FourierDCT can be used on SparseArray objects.
Examples
open all close allBasic Examples (2)
Find a discrete cosine transform:
FourierDCT[{0, 0, 1, 0, 1}]Find the inverse discrete cosine transform:
FourierDCT[%, 3]Find a discrete cosine transform of type 1 (DCT-I):
FourierDCT[{1, 0, 0, 1, 2}, 1]Find the inverse discrete cosine transform:
FourierDCT[%, 1]Scope (2)
Use machine arithmetic to compute the discrete cosine transform:
v = {0, 1, 2, 3, 4, 3, 2, 1, 0};FourierDCT[v]Use 24-digit precision arithmetic:
FourierDCT[N[v, 24]]A two-dimensional discrete cosine transform:
m = RandomReal[1, {3, 4}];FourierDCT[m]A five-dimensional discrete cosine transform:
m = RandomReal[1, {5, 5, 5, 5, 5}];Max[FourierDCT[m]]Generalizations & Extensions (2)
Applications (3)
Compressing Image Data (1)
ArrayPlot[data = 256 - Import["ExampleData/ocelot.jpg", "Data"]]t = FourierDCT[data];The diagonal spectra shows exponential decay:
ListLogPlot[Abs@Diagonal[t], Joined -> True, PlotRange -> All]Truncate modes in each axis, effectively compressing by a factor of
:
truncate[data_, f_] :=
Module[{i, j},
{i, j} = Floor[Dimensions[data] / Sqrt[f]];
PadRight[Take[data, i, j], Dimensions[data], 0.]
];{ArrayPlot[FourierDCT[truncate[t, 4], 3]], ArrayPlot[FourierDCT[truncate[t, 9], 3]], ArrayPlot[FourierDCT[truncate[t, 16], 3]]}Cosine Series Expansion (1)
Get an expansion for an even function as a sum of cosines:
f[x_] := Exp[-100(x - 1 / 2) ^ 2];The function values on a uniformly spaced grid with
points on
:
n = 25;
xg = N[Range[0, n - 1]] / n;
fg = Map[f, xg];
fp = ListPlot[Transpose[{xg, fg}], PlotRange -> All]Compute the DCT-III and renormalize:
cc = FourierDCT[fg, 3] / Sqrt[n];The function has, in effect, been periodized with a particular symmetry:
Show[fp, Plot[Sum[cc[[r]] * Cos[Pi(r - 1 / 2)x], {r, Length[cc]}], {x, -1, 3}, PlotRange -> All], PlotRange -> All]Plot the expansion error where the points are defined:
Plot[f[x] - Sum[cc[[r]] * Cos[Pi(r - 1 / 2)x], {r, Length[cc]}], {x, 0, 1 - 1 / n}, PlotRange -> All]Chebyshev Basis Expansion (1)
Get an expansion for a function in the Chebyshev polynomials:
f[x_] := 1 / (1 + (5x) ^ 2);The values of the function at the Chebyshev nodes:
n = 47;
cnodes = N[Cos[Pi Range[0, n] / n]];
fc = Map[f, cnodes];
pf = ListPlot[Transpose[{cnodes, fc}], PlotRange -> All]Find the Chebyshev coefficients:
cc = FourierDCT[fc, 1] * Sqrt[2 / n];
cc[[{1, -1}]] /= 2;Plot[f[x] - Sum[ChebyshevT[i - 1, x] * cc[[i]], {i, Length[cc]}], {x, -1, 1}, PlotRange -> All]Properties & Relations (3)
DCT-I and DCT-IV are their own inverses:
data = RandomReal[1, 7];Chop[FourierDCT[FourierDCT[data, 1], 1] - data]Chop[FourierDCT[FourierDCT[data, 4], 4] - data]DCT-II and DCT-III are inverses of each other:
data = RandomReal[1, 10];Chop[FourierDCT[FourierDCT[data, 2], 3] - data]Chop[FourierDCT[FourierDCT[data, 3], 2] - data]The DCT is equivalent to matrix multiplication:
dctII[n_] := (1/Sqrt[n])Table[Cos[Pi(r - 1 / 2)(s - 1) / n], {s, n}, {r, n}]MatrixForm[dctII[7]]data = RandomReal[1, 7];Chop[dctII[7].data - FourierDCT[data]]Possible Issues (1)
FourierDCT always returns normalized results:
TableForm[Table[FourierDCT[ConstantArray[1, 5], type], {type, 1, 4}]]To get unnormalized results, you can multiply by the normalization:
nc[n_, 1] = Sqrt[(n - 1) / 2];
nc[n_, 2 | 3] = Sqrt[n];
nc[n_, 4] = Sqrt[n / 2];unnormalizedDCT[data_, type_] := FourierDCT[data, type] * nc[Length[data], type]TableForm[Table[unnormalizedDCT[ConstantArray[1, 5], type], {type, 1, 4}]]See Also
FourierDST Fourier FourierCosTransform FourierCosCoefficient FourierCosSeries
Net Encoders: AudioMFCC
Tech Notes
Related Guides
History
Text
Wolfram Research (2007), FourierDCT, Wolfram Language function, https://reference.wolfram.com/language/ref/FourierDCT.html.
CMS
Wolfram Language. 2007. "FourierDCT." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/FourierDCT.html.
APA
Wolfram Language. (2007). FourierDCT. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/FourierDCT.html
BibTeX
@misc{reference.wolfram_2026_fourierdct, author="Wolfram Research", title="{FourierDCT}", year="2007", howpublished="\url{https://reference.wolfram.com/language/ref/FourierDCT.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_fourierdct, organization={Wolfram Research}, title={FourierDCT}, year={2007}, url={https://reference.wolfram.com/language/ref/FourierDCT.html}, note=[Accessed: 13-June-2026]}