# SinFT

SinFT, or Sinus Transform, refers to the integral transform with kernel \(K(x,y)=\sqrt{\frac{2}{\pi}} \sin(xy)\);

for function \(f\), the SinFT\(f\) appears as \(g\) defined with

\(\displaystyle g(x)=\,\)SinFT\(f\,(x) \displaystyle =\sqrt{\frac{2}{\pi}} \int_0^\infty \sin(xy) \, f(y) \, \mathrm d y\)

## Contents

## SinFT and CosFT

SinFT often appears together with CosFT;

the cosine transform of function \(f\) appears as \(g=\,\)CosFT\(f\) with rofmula

\(\displaystyle g(x)=\sqrt{\frac{2}{\pi}} \int_0^\infty \cos(xy) \, f(y) \, \mathrm d y\)

It is assumed that function \(f\) decays (or, at least, quickly oscillates) at infinity, in such a way that the integral converges.

Then, SinFT\(^2=\,\)CosFT\(^2=\hat 1\), id est, the identity transform.

## Numerical implementation

SinFT can be implemented numerically through the SFT transform at the uniform grid at \(N\) nodes; for array \(f\), the SFT \(g\) is defined with

\(g_m=\,\)SFT\(\displaystyle f_m=\) \(\sum_{n=1}^{N-1} \sin\left( \frac{\pi}{N} \,m\,n \right) \, f_n\)

The Numerical recipes in C (http://numerical.recipes)
suggest the implementation through routines
four1 and realft; however, for the serious applications, specification "float" should be replaced to something appropriate, for example, double, or complex double.
^{[1]}^{[2]}^{[3]}^{[4]}

At given number \(N-1\) of nodes, the set of the nodes can be denoted with \(x_n\) for \(n=1 \,..\, N\!-\!1\),

\(\displaystyle x_n=\sqrt{\frac{\pi}{N}}~ n\)

then, for \(f_n=f(x_n)\), at large \(N\gg 1\), the transform \(~g(x)=\frac{2}{\pi}\int_0^\infty f(y)\,\sin(x\,y)\,\mathrm d y~\) is approximated with

\(\displaystyle g(x_m) \approx g_m = \sqrt{\frac{2}{N}}\, \sum_{n=1}^{N-1} \, \sin\left( \frac{\pi}{N} \,m\,n \right) \, f_n\)

## Eigenfunctions

Eigenfunctions \(F\) of the SinFT appear as odd Oscillator functions;

\(F(x)=\,\)OscillatorFunction\(_{2n+1}(x)=\,\)HermiteH\(_{2n+1}(x)\,\exp(-x^2/2)\)

at even integer \(n\), eigenfunction \(F\) has eigenvalue unity; for odd \(n\), the eigenvalue is \(-1\). This property can be used for the testing of the numerical implementation of SFT.

In particular, the simplest eigenfunction

\(F(x)=x\,\exp(-x^2/2)\)

is self-SinFT. This property is used in the C++ test below.

## Test with self-SinFT in C++

The C++ implementation of SinFT can be arranged on the base of routine scft.cin by the Numerical recipes in C:

#include <stdio.h>

#include <math.h>

#include "scft.cin"

#define NP 16

int main(){ int i; double data[NP+1];

double d=sqrt(M_PI/NP);

double x;

for(i=0;i<NP;i++){ x=i*d; data[i]=x*exp(-.5*x*x); }

for(i=0;i<NP;i++) printf("%2d %19.14f\n",i,data[i]);

sinft(data-1,NP);

for(i=0;i<NP;i++) {

data[i]*=sqrt(2./NP) ;

printf("%2d %19.14f\n",i,data[i]);}

}

The graphical illustration of this test is shown in figures at right. At \(\mathrm{NP}=4\), the deviation of the segmented line (that shows the discrete representation of the First oscillator function) from the smooth original curve is clearly seen. However, the graphical resolution does not allow to see the deviation of the estimate of the discrete sin transform from its original; the deviation is of order of \(10^{-3}\). Amazing, that in this case, the curve is represented with only 3 points, as value of the function (and that of the discrete representation) at zero is always zero. This deviation sickly reduces at the increase of number of points; at NP=32, it becomes smaller than the rounding errors at the "double" variables. In this sense, the discrete numerical implementation of SinFT through the SFT algorithm is precise.

## Test with self-SinFT in Mathematica

The test above can be implemented also in Mathematica:

Sqrt[2/Pi] Integrate[x Exp[-x^2/2] Sin[p x], {x, 0, Infinity}]

NP = 16; d = Sqrt[2/NP]

a[n_] = n*d *Exp[-(n*d)^2/2]

b[m_] = Sqrt[2/Pi] Sum[d a[n] Sin[d^2 m n], {n, 1, NP - 1}]

N[Table[a[m], {m, 1, NP}]]

N[Table[b[m], {m, 1, NP}]]

(* The last two lines provide the almost identical outputs. The 16 points are sufficient to perform the SinFT of the simplest eigenfunction with 6 decimal digits. *)