Difference between revisions of "SinFT"

From TORI
Jump to navigation Jump to search
 
m (Text replacement - "\$([^\$]+)\$" to "\\(\1\\)")
 
Line 1: Line 1:
[[SinFT]], or Sinus Transform, refers to the integral transform with kernel $K(x,y)=\sqrt{\frac{2}{\pi}} \sin(xy)$;
+
[[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
+
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$
+
\(\displaystyle g(x)=\,\)[[SinFT]]\(f\,(x) \displaystyle =\sqrt{\frac{2}{\pi}} \int_0^\infty \sin(xy) \, f(y) \, \mathrm d y\)
   
 
==[[SinFT]] and [[CosFT]]==
 
==[[SinFT]] and [[CosFT]]==
Line 9: Line 9:
 
[[SinFT]] often appears together with [[CosFT]];
 
[[SinFT]] often appears together with [[CosFT]];
   
the cosine transform of function $f$ appears as $g=\,$[[CosFT]]$f$ with rofmula
+
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$
+
\(\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.
+
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.
+
Then, [[SinFT]]\(^2=\,\)[[CosFT]]\(^2=\hat 1\), id est, the identity transform.
   
 
==Numerical implementation==
 
==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
+
[[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$
+
\(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)
 
The [[Numerical recipes in C]] (http://numerical.recipes)
Line 34: Line 34:
 
ftp://ftp.cs.stanford.edu/cs/robotics/scohen/nr/cosft.c</ref>
 
ftp://ftp.cs.stanford.edu/cs/robotics/scohen/nr/cosft.c</ref>
   
At given number $N-1$ of nodes,
+
At given number \(N-1\) of nodes,
the set of the nodes can be denoted with $x_n$ for $n=1 \,..\, N\!-\!1$,
+
the set of the nodes can be denoted with \(x_n\) for \(n=1 \,..\, N\!-\!1\),
   
$\displaystyle
+
\(\displaystyle
x_n=\sqrt{\frac{\pi}{N}}~ n$
+
x_n=\sqrt{\frac{\pi}{N}}~ n\)
   
then, for $f_n=f(x_n)$, at large $N\gg 1$,
+
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
+
the transform \(~g(x)=\frac{2}{\pi}\int_0^\infty f(y)\,\sin(x\,y)\,\mathrm d y~\) is approximated with
   
$\displaystyle
+
\(\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$
+
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==
Eigenfunctions $F$ of the [[SinFT]] appear as odd [[Oscillator function]]s;
+
Eigenfunctions \(F\) of the [[SinFT]] appear as odd [[Oscillator function]]s;
   
$F(x)=\,$[[OscillatorFunction]]$_{2n+1}(x)=\,$[[HermiteH]]$_{2n+1}(x)\,\exp(-x^2/2)$
+
\(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$.
+
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.
 
This property can be used for the testing of the numerical implementation of SFT.
   
 
In particular, the simplest eigenfunction
 
In particular, the simplest eigenfunction
   
$F(x)=x\,\exp(-x^2/2)$
+
\(F(x)=x\,\exp(-x^2/2)\)
   
 
is self-SinFT. This property is used in the [[C++]] test below.
 
is self-SinFT. This property is used in the [[C++]] test below.
   
 
==Test with self-SinFT in C++==
 
==Test with self-SinFT in C++==
[[File:Sinftes04t300.jpg|333px|thumb|$y\!=\!2x\exp(-x^2/2)$, its discrete representation with NP=4 and its [[SinFT]] transform evaluated through the [[SFT]] algorithm]]
+
[[File:Sinftes04t300.jpg|333px|thumb|\(y\!=\!2x\exp(-x^2/2)\), its discrete representation with NP=4 and its [[SinFT]] transform evaluated through the [[SFT]] algorithm]]
[[File:Sinftes16t300.jpg|333px|thumb|$y\!=\!2x\exp(-x^2/2)$, its discrete representation with NP=16 and its [[SinFT]] transform evaluated through the [[SFT]] algorithm]]
+
[[File:Sinftes16t300.jpg|333px|thumb|\(y\!=\!2x\exp(-x^2/2)\), its discrete representation with NP=16 and its [[SinFT]] transform evaluated through the [[SFT]] algorithm]]
 
The C++ implementation of [[SinFT]] can be arranged on the base of routine [[scft.cin]] by the [[Numerical recipes in C]]: <poem><nomathjax><nowiki>
 
The C++ implementation of [[SinFT]] can be arranged on the base of routine [[scft.cin]] by the [[Numerical recipes in C]]: <poem><nomathjax><nowiki>
 
#include <stdio.h>
 
#include <stdio.h>
Line 81: Line 81:
 
</nowiki></nomathjax></poem>
 
</nowiki></nomathjax></poem>
   
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.
+
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==
 
==Test with self-SinFT in Mathematica==

Latest revision as of 18:44, 30 July 2019

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\)

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++

\(y\!=\!2x\exp(-x^2/2)\), its discrete representation with NP=4 and its SinFT transform evaluated through the SFT algorithm
\(y\!=\!2x\exp(-x^2/2)\), its discrete representation with NP=16 and its SinFT transform evaluated through the SFT algorithm

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. *)

References

Keywords

CFT, CosFT, FFT, Integral transform, SFT, SinFT,