\documentclass[a4paper]{article}
\title{Fourier transform in \texttt{GraceGTK}}
\author{P. Vincent}
\begin{document}
\maketitle
\section{Classical Fourier transformation}
\label{secCF}
Let us define the Fourier integral by
\begin{equation}
\label{eqFI}
  F(X) \: = \: a \int_{-\infty}^{+\infty} f(x) \: \exp(\pm i c X x) \;  dx
  \quad \Leftrightarrow \quad
  F \: = \: \mathcal{F}^{\pm}_{a,c} \,f,
\end{equation}
where $a$ and $c$ are two real constants and $i^2=-1$. 
Various values for the two
constants and the sign in the exponential are commonly used.
\section{Discrete Fourier Transform}
\label{secDFT}
The discrete Fourier transform (DFT) is defined in FFTW library by
\begin{equation}
  \label{eqDFT}
  \tilde F_k \: = \: \sum_{j=0}^{N-1} f_j
  \: \exp\left( \pm i 2 \pi \, \frac{k}{N} \: j \right).
\end{equation}
Let us identify (\ref{eqDFT}) with a discrete computation of
(\ref{eqFI}) for a function $\tilde f$ null outside $[0,N-1]$,
with $f_j = \tilde f(j)$ and $\tilde X_k = k/N$:
\begin{equation}
  \label{eqFt}
  \tilde F(\tilde X) \: = \: \int_{-\infty}^{+\infty} \tilde f(\tilde x)
  \exp\left( \pm i 2 \pi  \: \tilde X \tilde x \right)
  \: d\tilde x.  
  \quad \Leftrightarrow \quad
  \tilde F = \mathcal{F}^{\pm}_{1,2\pi} \,\tilde f
\end{equation}
Let us now connect $\tilde F$ to the wanted transformed $F$.\\
 Noting $  x = A + b \, \tilde x, \quad b>0\;$
and substituting $\tilde x$ to $x$ into (\ref{eqFI}), we get
\begin{eqnarray}
  F(X) &=&  a \int_{-\infty}^{+\infty}  f(A+b\tilde x)
  \:  \exp[\pm i c X ( A + b \, \tilde x)] \:  b \, d\tilde x
  \\
  \label{eqFtx}
  &=& ab\: \exp(\pm i c A X)
  \int_{-\infty}^{+\infty} \tilde f(\tilde x)
  \:  \exp(\pm i b c X \, \tilde x) \:  d\tilde x
\end{eqnarray}
We can identify (\ref{eqFt}) with the integral in (\ref{eqFtx})
if $b c X \equiv 2 \pi  \: \tilde X$.\\
Thus,
\begin{equation}
  \label{eqFtF}
  X_k = \frac{2 \pi}{bc} \: \frac{k}{N}
  \quad \Rightarrow \quad
  F(X_k) \: = \: ab\: \exp(\pm i c A X_k) \: \tilde F_k
\end{equation}
For a function $f$ null outside $[A,B]$, the coefficient $b$ is given by
\begin{displaymath}
  B = A + b(N-1)
\quad \Rightarrow \quad
b = (B-A) / (N-1).
\end{displaymath}
%% 
\subsection{Fourier transform in \texttt{GraceGTK}}
\subsubsection{Choice of parameters}
\texttt{GraceGTK} interface gives the following choices.
\begin{itemize}
\item
  \textit{Forward} transform: the sign in the exponential is minus.
\item
 \textit{Backward} transform: the sign in the exponential is plus.
\item
  \textit{Input segment}: as explain above, classical Fourier
  transforms ans DFT are related but not identical. If you choose
  \begin{itemize}
  \item
    \textit{Index}, you compute only the DFT,
  \item   
    \textit{[Xmin ,Xmax]}, you compute the classical Fourier transform
  \end{itemize}
\item   
  $X$-scale: allows choose $a$ and $c$ in formula (\ref{eqFI}):
  \begin{itemize}
  \item 
    \textit{index} means $a = 1, \; c = 1$,
  \item 
    \textit{frequency} means $a = 1, \; c = 2 \pi$
  \item   
    \textit{angular frequency} means $a = 1/\sqrt{2 \pi}, \; c=1$.
  \end{itemize}
\item
  \textit{Output segment}~\\
  The DFT is periodical, i.e. $\tilde F_{k+N} = \tilde F_k$, thus it
  is possible to choose the abscissas interval for the computed
  transform.
  Moreover, the transform of a real function shows the Hermitian
  symmetry, i.e. $\tilde F_{N-k} = F_k^*$ and in that case the full
  period is not needed, thus the program offers three possible answers:
  \textit{``Positive'', "Positive half length"} and \textit{"Centered"}.
\end{itemize}
\subsubsection{Call in \texttt{GraceGTK} scripts}
Three forms are possibles, the first is not compatible with Grace-5.
\begin{enumerate}
\item 
  \texttt{FFT(set ,intyp ,filter ,xscale ,outtyp ,outseg)}
\item 
  \texttt{FFT(set ,intyp ,filter ,xscale ,outtyp)}
\item 
  \texttt{FFT(set ,filter)}
\end{enumerate}
The arguments are:
\begin{itemize}
\item
  \texttt{set}: the set ident, e.g. \texttt{G1.S0}
\item   
  \texttt{intyp}: \texttt{REAL} or \texttt{COMPLEX}
\item   
  \texttt{filter}: \texttt{NONE, TRIANGULAR, WELCH, HANNING, HAMMING} or \texttt{PARZEN}
\item   
  \texttt{xscale}: \texttt{INDEX, FREQUENCY} or \texttt{PERIOD}
\item   
  \texttt{outtyp}: \texttt{MAGNITUDE, PHASE, COEFFICIENTS} or \texttt{COMPLEX}
\item   
  \texttt{outseg}: \texttt{POSITIVE, HALF} or \texttt{CENTER}
\end{itemize}
%%
\subsubsection{Examples}
Two examples are given in doc/examples directory:
\begin{center}
\texttt{ng\_fourier.agr} and \texttt{ng\_fourier2.agr}  
\end{center}
and can be launched via \texttt{Help/Examples/GraceGTK} menu.
\end{document}

;;; Local Variables: ***
;;; ispell-local-dictionary: "english" ***
;;; End: ***
