DCTI

DCTI is one of realizations of the Discrete Cos transform operator. The name is created in analogy with DCT by Wikipedia and notations by the Numerical recipes in C .

DCTI, or Discrete Cos Transform of kind I, is orthogonal transform, that repalces an array $$F$$ of length $$N\!+\!1$$ with elements $$F_n~$$, $$~n=0 .. N$$ to the array $$G$$ with elements
 * $$ \!\!\!\!\!\!\!\!\!\!(1) ~ ~ ~ \displaystyle G_k = (\mathrm{DCTI}_N F)_k = \frac{1}{2} F_0 + \frac{(-1)^k}{2} F_{N}  + \sum_{n=1}^{N-1} F_n \cos\! \left(\frac{\pi}{N} n k \right)~$$ for $$~k=0, .. N$$

Normalized form
The orthonormaized transform can be defined with operator $$\Phi_{\mathrm C1,N}$$, that acts on array $$F$$ in the following way:
 * $$ \!\!\!\!\!\!\!\!\!\!(2) ~ ~ ~ ~ (\Phi_{\mathrm C1,N}~ F)_k=

\sqrt{\frac{2}{N}} ~(\mathrm{DCT1}_N~ F)_k= \sqrt{\frac{2}{N}} \left( \frac{1}{2} F_0 + \frac{(-1)^k}{2} F_{N} + \sum_{n=1}^{N-1} F_n \cos \left(\frac{\pi}{N} n k \right)\right) $$

Operator $$\Phi_{\mathrm C1, N}$$ is its own inverse; $$(\Phi_{\mathrm C1,N})^2~ F = F$$

Numerical implementation
the C++ numerical implementation of the discrete cos transtorm of First kind consists of 3 files zfour1.cin, zrealft.cin, zcosft1.cin; these files should be loaded to the working directory in order to compile the examples. For the application in wave optics, z_type should be defined as double" or complex(double); however, for other applications, such a type may be defined in other ways too. The name of the functions and sense of the arguments are chosen following notations by the Numerical recipes in C, the call of the transform of array $$F$$ of length $$N\!+\!1$$ has form zcosft1(F-1,N);  after such a call, values of the elements of array $$F$$ are replaced with values calculated with the expression (1) above. For $$N=2^q$$, the evaluation requires of order of $$Nq$$ operations

Approximation of the CosFourier
The CosFourier operator transforms a function $$F$$ of non–negative argument to function $$G$$ in the following way:
 * $$\!\!\!\!\!\!\!\!\!\!\! (3) ~ ~ ~ \displaystyle G(x) = \mathrm{CosFourier} F(x) = \sqrt{\frac{2}{\pi}} \int_0^\infty ~\cos(xy)~ F(y)~ \mathrm d y $$

For the discrete approximation of this operator, assume some large natural number $$N$$. Let $$x_n=\sqrt{\pi/N}~ n$$. Let function $$F$$ be smooth and quickly decay at infinity. Then, the transform of $$F$$ can be approximated as follows:


 * $$\!\!\!\!\!\!\!\!\!\!\! (4) ~ ~ ~ \displaystyle G(x) = \mathrm{CosFourier} F(x) \approx

\sqrt{\frac{2}{\pi}} \left ( \frac{1}{2} F(0) + \sum_{n=1}^{N} ~\cos(x x_n)~ F(x_n) \right)~ \sqrt{{\pi}/N} $$

For $$x=x_m$$, this can be written as follows:


 * $$\!\!\!\!\!\!\!\!\!\!\! (5) ~ ~ ~ G_m=\displaystyle G(x_m) = \mathrm{CosFourier} F(x_m) \approx\sqrt{\frac{2}{N}}

\left ( \frac{1}{2} F(0) + \frac{ (-1)^m}{2} F(x_N) + \sum_{n=1}^{N} ~\cos(x_m x_n)~ F(x_n)~\right) $$ $$ \displaystyle \approx \sqrt{\frac{2}{N}} \left ( \frac{1}{2} F_0 + \frac{ (-1)^m}{2} F_N + \sum_{n=1}^{N-1} ~\cos\left(\frac{\pi}{N} mn\right)~ F_n\right) $$

At the transformation, it is assumed, that $$F(x)$$ can be neglected as $$x\ge x_N$$. In such a way,


 * $$\!\!\!\!\!\!\!\!\!\!\! (6) ~ ~ ~ \displaystyle G_m \approx \sqrt{\frac{2}{N}} ~ (\mathrm{DCTI}_N~ F)_m= (\Phi_{C1,N}~ F)_m$$