Discrete sine transform




In mathematics, the discrete sine transform (DST) is a Fourier-related transform similar to the discrete Fourier transform (DFT), but using a purely real matrix. It is equivalent to the imaginary parts of a DFT of roughly twice the length, operating on real data with odd symmetry (since the Fourier transform of a real and odd function is imaginary and odd), where in some variants the input and/or output data are shifted by half a sample.


A related transform is the discrete cosine transform (DCT), which is equivalent to a DFT of real and even functions. See the DCT article for a general discussion of how the boundary conditions relate the various DCT and DST types.




Contents






  • 1 Applications


  • 2 Informal overview


  • 3 Definition


    • 3.1 DST-I


    • 3.2 DST-II


    • 3.3 DST-III


    • 3.4 DST-IV


    • 3.5 DST V–VIII


    • 3.6 Inverse transforms


    • 3.7 Computation




  • 4 References





Applications


DSTs are widely employed in solving partial differential equations by spectral methods, where the different variants of the DST correspond to slightly different odd/even boundary conditions at the two ends of the array.



Informal overview




Illustration of the implicit even/odd extensions of DST input data, for N=9 data points (red dots), for the four most common types of DST (types I–IV).


Like any Fourier-related transform, discrete sine transforms (DSTs) express a function or a signal in terms of a sum of sinusoids with different frequencies and amplitudes. Like the discrete Fourier transform (DFT), a DST operates on a function at a finite number of discrete data points. The obvious distinction between a DST and a DFT is that the former uses only sine functions, while the latter uses both cosines and sines (in the form of complex exponentials). However, this visible difference is merely a consequence of a deeper distinction: a DST implies different boundary conditions than the DFT or other related transforms.


The Fourier-related transforms that operate on a function over a finite domain, such as the DFT or DST or a Fourier series, can be thought of as implicitly defining an extension of that function outside the domain. That is, once you write a function f(x){displaystyle f(x)}f(x) as a sum of sinusoids, you can evaluate that sum at any x{displaystyle x}x, even for x{displaystyle x}x where the original f(x){displaystyle f(x)}f(x) was not specified. The DFT, like the Fourier series, implies a periodic extension of the original function. A DST, like a sine transform, implies an odd extension of the original function.


However, because DSTs operate on finite, discrete sequences, two issues arise that do not apply for the continuous sine transform. First, one has to specify whether the function is even or odd at both the left and right boundaries of the domain (i.e. the min-n and max-n boundaries in the definitions below, respectively). Second, one has to specify around what point the function is even or odd. In particular, consider a sequence (a,b,c) of three equally spaced data points, and say that we specify an odd left boundary. There are two sensible possibilities: either the data is odd about the point prior to a, in which case the odd extension is (−c,−b,−a,0,a,b,c), or the data is odd about the point halfway between a and the previous point, in which case the odd extension is (−c,−b,−a,a,b,c)


These choices lead to all the standard variations of DSTs and also discrete cosine transforms (DCTs).
Each boundary can be either even or odd (2 choices per boundary) and can be symmetric about a data point or the point halfway between two data points (2 choices per boundary), for a total of 2=16{displaystyle 2times 2times 2times 2=16}2times 2times 2times 2=16 possibilities. Half of these possibilities, those where the left boundary is odd, correspond to the 8 types of DST; the other half are the 8 types of DCT.


These different boundary conditions strongly affect the applications of the transform, and lead to uniquely useful properties for the various DCT types. Most directly, when using Fourier-related transforms to solve partial differential equations by spectral methods, the boundary conditions are directly specified as a part of the problem being solved.



Definition


Formally, the discrete sine transform is a linear, invertible function F : RN-> RN (where R denotes the set of real numbers), or equivalently an N × N square matrix. There are several variants of the DST with slightly modified definitions. The N real numbers x0, ...., xN − 1 are transformed into the N real numbers X0, ..., XN − 1 according to one of the formulas:



DST-I


Xk=∑n=0N−1xnsin⁡N+1(n+1)(k+1)]k=0,…,N−1{displaystyle X_{k}=sum _{n=0}^{N-1}x_{n}sin left[{frac {pi }{N+1}}(n+1)(k+1)right]quad quad k=0,dots ,N-1}{displaystyle X_{k}=sum _{n=0}^{N-1}x_{n}sin left[{frac {pi }{N+1}}(n+1)(k+1)right]quad quad k=0,dots ,N-1}

The DST-I matrix is orthogonal (up to a scale factor).


A DST-I is exactly equivalent to a DFT of a real sequence that is odd around the zero-th and middle points, scaled by 1/2. For example, a DST-I of N=3 real numbers (a,b,c) is exactly equivalent to a DFT of eight real numbers (0,a,b,c,0,−c,−b,−a) (odd symmetry), scaled by 1/2. (In contrast, DST types II–IV involve a half-sample shift in the equivalent DFT.) This is the reason for the N + 1 in the denominator of the sine function: the equivalent DFT has 2(N+1) points and has 2π/2(N+1) in its sinusoid frequency, so the DST-I has π/(N+1) in its frequency.


Thus, the DST-I corresponds to the boundary conditions: xn is odd around n = −1 and odd around n=N; similarly for Xk.



DST-II


Xk=∑n=0N−1xnsin⁡N(n+12)(k+1)]k=0,…,N−1{displaystyle X_{k}=sum _{n=0}^{N-1}x_{n}sin left[{frac {pi }{N}}left(n+{frac {1}{2}}right)(k+1)right]quad quad k=0,dots ,N-1}{displaystyle X_{k}=sum _{n=0}^{N-1}x_{n}sin left[{frac {pi }{N}}left(n+{frac {1}{2}}right)(k+1)right]quad quad k=0,dots ,N-1}

Some authors further multiply the XN − 1 term by 1/2 (see below for the corresponding change in DST-III). This makes the DST-II matrix orthogonal (up to a scale factor), but breaks the direct correspondence with a real-odd DFT of half-shifted input.


The DST-II implies the boundary conditions: xn is odd around n = −1/2 and odd around n = N − 1/2; Xk is odd around k = −1 and even around k = N − 1.



DST-III


Xk=(−1)k2xN−1+∑n=0N−2xnsin⁡N(n+1)(k+12)]k=0,…,N−1{displaystyle X_{k}={frac {(-1)^{k}}{2}}x_{N-1}+sum _{n=0}^{N-2}x_{n}sin left[{frac {pi }{N}}(n+1)left(k+{frac {1}{2}}right)right]quad quad k=0,dots ,N-1}{displaystyle X_{k}={frac {(-1)^{k}}{2}}x_{N-1}+sum _{n=0}^{N-2}x_{n}sin left[{frac {pi }{N}}(n+1)left(k+{frac {1}{2}}right)right]quad quad k=0,dots ,N-1}

Some authors further multiply the xN − 1 term by 2 (see above for the corresponding change in DST-II). This makes the DST-III matrix orthogonal (up to a scale factor), but breaks the direct correspondence with a real-odd DFT of half-shifted output.


The DST-III implies the boundary conditions: xn is odd around n = −1 and even around n = N − 1; Xk is odd around k = −1/2 and odd around k = N − 1/2.



DST-IV


Xk=∑n=0N−1xnsin⁡N(n+12)(k+12)]k=0,…,N−1{displaystyle X_{k}=sum _{n=0}^{N-1}x_{n}sin left[{frac {pi }{N}}left(n+{frac {1}{2}}right)left(k+{frac {1}{2}}right)right]quad quad k=0,dots ,N-1}{displaystyle X_{k}=sum _{n=0}^{N-1}x_{n}sin left[{frac {pi }{N}}left(n+{frac {1}{2}}right)left(k+{frac {1}{2}}right)right]quad quad k=0,dots ,N-1}

The DST-IV matrix is orthogonal (up to a scale factor).


The DST-IV implies the boundary conditions: xn is odd around n = −1/2 and even around n = N − 1/2; similarly for Xk.



DST V–VIII


DST types I–IV are equivalent to real-odd DFTs of even order. In principle, there are actually four additional types of discrete sine transform (Martucci, 1994), corresponding to real-odd DFTs of logically odd order, which have factors of N+1/2 in the denominators of the sine arguments. However, these variants seem to be rarely used in practice.



Inverse transforms


The inverse of DST-I is DST-I multiplied by 2/(N + 1). The inverse of DST-IV is DST-IV multiplied by 2/N. The inverse of DST-II is DST-III multiplied by 2/N (and vice versa).


As for the DFT, the normalization factor in front of these transform definitions is merely a convention and differs between treatments. For example, some authors multiply the transforms by 2/N{displaystyle {sqrt {2/N}}}sqrt{2/N} so that the inverse does not require any additional multiplicative factor.



Computation


Although the direct application of these formulas would require O(N2) operations, it is possible to compute the same thing with only O(N log N) complexity by factorizing the computation similar to the fast Fourier transform (FFT). (One can also compute DSTs via FFTs combined with O(N) pre- and post-processing steps.)


A DST-III or DST-IV can be computed from a DCT-III or DCT-IV (see discrete cosine transform), respectively, by reversing the order of the inputs and flipping the sign of every other output, and vice versa for DST-II from DCT-II. In this way it follows that types II–IV of the DST require exactly the same number of arithmetic operations (additions and multiplications) as the corresponding DCT types.



References



  • S. A. Martucci, "Symmetric convolution and the discrete sine and cosine transforms," IEEE Trans. Signal Process. SP-42, 1038–1051 (1994).

  • Matteo Frigo and Steven G. Johnson: FFTW, http://www.fftw.org/. A free (GPL) C library that can compute fast DSTs (types I–IV) in one or more dimensions, of arbitrary size. Also M. Frigo and S. G. Johnson, "The Design and Implementation of FFTW3," Proceedings of the IEEE 93 (2), 216–231 (2005).

  • Takuya Ooura: General Purpose FFT Package, http://www.kurims.kyoto-u.ac.jp/~ooura/fft.html. Free C & FORTRAN libraries for computing fast DSTs in one, two or three dimensions, power of 2 sizes.


  • Press, WH; Teukolsky, SA; Vetterling, WT; Flannery, BP (2007), "Section 12.4.1. Sine Transform", Numerical Recipes: The Art of Scientific Computing (3rd ed.), New York: Cambridge University Press, ISBN 978-0-521-88068-8.mw-parser-output cite.citation{font-style:inherit}.mw-parser-output .citation q{quotes:"""""""'""'"}.mw-parser-output .citation .cs1-lock-free a{background:url("//upload.wikimedia.org/wikipedia/commons/thumb/6/65/Lock-green.svg/9px-Lock-green.svg.png")no-repeat;background-position:right .1em center}.mw-parser-output .citation .cs1-lock-limited a,.mw-parser-output .citation .cs1-lock-registration a{background:url("//upload.wikimedia.org/wikipedia/commons/thumb/d/d6/Lock-gray-alt-2.svg/9px-Lock-gray-alt-2.svg.png")no-repeat;background-position:right .1em center}.mw-parser-output .citation .cs1-lock-subscription a{background:url("//upload.wikimedia.org/wikipedia/commons/thumb/a/aa/Lock-red-alt-2.svg/9px-Lock-red-alt-2.svg.png")no-repeat;background-position:right .1em center}.mw-parser-output .cs1-subscription,.mw-parser-output .cs1-registration{color:#555}.mw-parser-output .cs1-subscription span,.mw-parser-output .cs1-registration span{border-bottom:1px dotted;cursor:help}.mw-parser-output .cs1-ws-icon a{background:url("//upload.wikimedia.org/wikipedia/commons/thumb/4/4c/Wikisource-logo.svg/12px-Wikisource-logo.svg.png")no-repeat;background-position:right .1em center}.mw-parser-output code.cs1-code{color:inherit;background:inherit;border:inherit;padding:inherit}.mw-parser-output .cs1-hidden-error{display:none;font-size:100%}.mw-parser-output .cs1-visible-error{font-size:100%}.mw-parser-output .cs1-maint{display:none;color:#33aa33;margin-left:0.3em}.mw-parser-output .cs1-subscription,.mw-parser-output .cs1-registration,.mw-parser-output .cs1-format{font-size:95%}.mw-parser-output .cs1-kern-left,.mw-parser-output .cs1-kern-wl-left{padding-left:0.2em}.mw-parser-output .cs1-kern-right,.mw-parser-output .cs1-kern-wl-right{padding-right:0.2em}

  • R. Chivukula and Y. Reznik, "Fast Computing of Discrete Cosine and Sine Transforms of Types VI and VII," Proc. SPIE Vol. 8135, 2011. [1]




Popular posts from this blog

Guess what letter conforming each word

Port of Spain

Run scheduled task as local user group (not BUILTIN)