Difference between revisions of "File:BesselTestExp200.jpg"

From TORI
Jump to navigation Jump to search
(Importing image file)
 
 
Line 1: Line 1:
  +
Test of the 0-order [[discrete Bessel]] transform at the grid of 8 points with self-Bessel Gaussian
Importing image file
 
  +
  +
$f(x)=\exp(-x^2/2)$
  +
  +
shown with thin black line. Circles show its representation at the mesh of 8 nodes.
  +
  +
==Description==
  +
  +
Function $f(x)=\exp(-x^2/2)$ is self-Bessel, as the [[Bessel transform]]
  +
  +
$\displaystyle
  +
g(x)=\int_0^\infty J_0(xy)\, f(y) \, y \, \mathrm d y$
  +
  +
is itself, $f\!=\!g$.
  +
  +
Curve $y=f(x)$ is shown with thin solid line.
  +
  +
The small red circles show its representation at the discrete mesh.
  +
The big blue circles show the [[discrete Bessel]] transform.
  +
  +
As $f$ is self-Bessel, the red circles happen to be inside the blue circles.
  +
For the [[discrete Bessel]] transform with 8 nodes, relation $f=g$ is repoduced with 7 decimal digits.
  +
  +
==[[C++]] Generator of curves==
  +
<poem><nomathjax><nowiki>
  +
#include<math.h>
  +
#include<stdio.h>
  +
#include<stdlib.h>
  +
#define DB double
  +
#define DO(x,y) for(x=0;x<y;x++)
  +
DB jnp(int n,DB x){ return .5*( jn(n-1,x)-jn(n+1,x) ) ; } // Derivative of n th Bessel
  +
DB jnz(int v, int k){ DB x,t; t=M_PI*(k+.5*v-.25); x= t - (v*v-.25)*.5/t;
  +
x-= jn(v,x)/jnp(v,x); // Newton adjustment of the root
  +
x-= jn(v,x)/jnp(v,x);
  +
x-= jn(v,x)/jnp(v,x);
  +
return x; } // the k th zero of v th Bessel
  +
void ado(FILE *O, int X, int Y)
  +
{ fprintf(O,"%c!PS-Adobe-2.0 EPSF-2.0\n",'%');
  +
fprintf(O,"%c%cBoundingBox: 0 0 %d %d\n",'%','%',X,Y);
  +
fprintf(O,"/M {moveto} bind def\n");
  +
fprintf(O,"/L {lineto} bind def\n");
  +
fprintf(O,"/S {stroke} bind def\n");
  +
fprintf(O,"/s {show newpath} bind def\n");
  +
fprintf(O,"/C {closepath} bind def\n");
  +
fprintf(O,"/F {fill} bind def\n");
  +
fprintf(O,"/O {.04 0 360 arc C S} bind def\n");
  +
fprintf(O,"/o {.02 0 360 arc C S} bind def\n");
  +
fprintf(O,"/times-Roman findfont 20 scalefont setfont\n");
  +
fprintf(O,"/W {setlinewidth} bind def\n");
  +
fprintf(O,"/RGB {setrgbcolor} bind def\n");}
  +
  +
int main(){ int m,n,v,k; DB s, x,y; FILE *o;
  +
int M=8;
  +
DB X[M+1],W[M+1],T[M+1][M+1],TT[M+1][M+1], F[M],G[M];
  +
DB S=jnz(0,M+1);
  +
DB qs=sqrt(1./S);
  +
DB q=sqrt(2./S);
  +
for(n=1;n<M+1;n++){ x=jnz(0,n); X[n]=x*qs; y=W[n]=q/fabs(j1(x));
  +
printf("%3d %20.16lf %20.16lf\n",n,X[n],W[n]); }
  +
for(m=1;m<=M;m++){ printf("%2d",m); for(n=1;n<=M;n++){ T[m][n]=W[m]*j0(X[m]*X[n])*W[n]; }}
  +
for(m=1;m<=M;m++){printf("\n");
  +
for(n=1;n<=M;n++){printf("%14.10lf",T[m][n]); }}
  +
printf("\n");
  +
for(m=1;m<=M;m++){printf("\n");
  +
for(n=1;n<=M;n++){ s=0.;
  +
for(k=1;k<=M;k++) s+=T[m][k]*T[k][n] ;
  +
TT[m][n]=s;printf("%14.10lf",TT[m][n]);
  +
}}
  +
printf("\n\n");
  +
for(m=1;m<=M;m++){x=X[m]; y=exp(-x*x/2.); F[m]=y*W[m]; printf("%14.10lf",F[m]); }
  +
printf("\n");
  +
for(m=1;m<=M;m++){ s=0.; for(n=1;n<=M;n++) s+=T[m][n]*F[n];
  +
G[m]=s;}
  +
for(m=1;m<=M;m++) printf("%14.10lf",G[m]);
  +
printf("\n");
  +
o=fopen("besselTestEx.eps", "w"); ado(o,520,120);
  +
#define M(x,y) fprintf(o,"%8.4lf %8.4lf M\n",0.+x, 0.+y);
  +
#define L(x,y) fprintf(o,"%8.4lf %8.4lf L\n",0.+x, 0.+y);
  +
#define O(x,y) fprintf(o,"%8.4lf %8.4lf O\n",0.+x, 0.+y);
  +
#define o(x,y) fprintf(o,"%8.4lf %8.4lf o\n",0.+x, 0.+y);
  +
fprintf(o,"10 10 translate 100 100 scale\n");
  +
DO(n,6){M(n,1)L(n,0)}
  +
DO(n,3){M(0,n/2.)L(5,n/2.)}
  +
fprintf(o,"2 setlinecap 2 setlinejoin .006 W S\n");
  +
  +
M(0,1) DO(n,500){x=.01*(n+1); y=exp(-x*x/2.); L(x,y)}
  +
fprintf(o,"1 setlinecap 1 setlinejoin S\n");
  +
fprintf(o,"1 0 0 RGB .016 W\n");
  +
for(m=1;m<=M;m++) o(X[m],F[m]/W[m])
  +
fprintf(o,"0 0 1 RGB .01 W\n");
  +
for(m=1;m<=M;m++) O(X[m],G[m]/W[m])
  +
fprintf(o,"showpage\n%c%cTrailer\n",'%','%'); fclose(o);
  +
system("epstopdf besselTestEx.eps");
  +
system("open besselTestEx.pdf");
  +
return 0;
  +
}
  +
</nowiki></nomathjax></poem>
  +
  +
==[[Latex]] Generator of labels==
  +
<poem><nomathjax><nowiki>
  +
\documentclass[12pt]{article}
  +
\usepackage{geometry}
  +
\usepackage{graphicx}
  +
\usepackage{rotating}
  +
\paperwidth 513pt
  +
\paperheight 116pt
  +
\topmargin -110pt
  +
\oddsidemargin -92pt
  +
\newcommand \ing {\includegraphics}
  +
\newcommand \sx {\scalebox}
  +
\newcommand \rot {\begin{rotate}}
  +
\newcommand \ero {\end{rotate}}
  +
\begin{document}
  +
\begin{picture}(410,116)
  +
%\put(2,4){\ing{03}}
  +
\put(2,4){\ing{besselTEstEx}}
  +
\put(2,107){\sx{1.4}{$y$}}
  +
\put(2,60){\sx{1.4}{$\frac 1 2$}}
  +
\put(2,9){\sx{1.4}{0}}
  +
\put(10,0){\sx{1.4}{0}}
  +
\put(108,0){\sx{1.4}{1}}
  +
\put(208,0){\sx{1.4}{2}}
  +
\put(309,0){\sx{1.4}{3}}
  +
\put(409,0){\sx{1.4}{4}}
  +
\put(505,0){\sx{1.5}{$x$}}
  +
\put(76,77){\sx{1.3}{\rot{-28}$y\!=\! \exp(-x^2/2)$\ero }}
  +
\end{picture}
  +
\end{document}
  +
</nowiki></nomathjax></poem>
  +
  +
==Output==
  +
Coordinates of the nodes and the weight of the [[discrete Bessel]] of zero order with 9 nodes:
  +
<poem>
  +
1 0.4586366203331863 0.5195285071552201
  +
2 1.0527624177874750 0.7926530133638713
  +
3 1.6503968491849170 0.9935886501286754
  +
4 2.2488240306434886 1.1602517418890868
  +
5 2.8475519209198557 1.3058173905056820
  +
6 3.4464253249241210 1.4367104029426190
  +
7 4.0453800503454875 1.5566359753601471
  +
8 4.6443847886932446 1.6679612725451483
  +
</poem>
  +
  +
Values of the Gaussian and its [[discrete Bessel]] at these notes:
  +
  +
0.4676629801 0.4554250733 0.2545299239 0.0925535614 0.0226533673 0.0037855363 0.0004350617 0.0000345345 <br>
  +
0.4676629900 0.4554250520 0.2545299536 0.0925535273 0.0226534013 0.0037855066 0.0004350816 0.0000344505
  +
  +
==References==
  +
<references/>
  +
  +
[[Category:Bessel function]]
  +
[[Category:Bessel transform]]
  +
[[Category:C++]]
  +
[[Category:Discrete Bessel]]
  +
[[Category:Example]]
  +
[[Category:Explicit plot]]
  +
[[Category:Exponent]]
  +
[[Category:Latex]]
  +
[[Category:Makoto Morinaga]]

Latest revision as of 08:31, 1 December 2018

Test of the 0-order discrete Bessel transform at the grid of 8 points with self-Bessel Gaussian

$f(x)=\exp(-x^2/2)$

shown with thin black line. Circles show its representation at the mesh of 8 nodes.

Description

Function $f(x)=\exp(-x^2/2)$ is self-Bessel, as the Bessel transform

$\displaystyle g(x)=\int_0^\infty J_0(xy)\, f(y) \, y \, \mathrm d y$

is itself, $f\!=\!g$.

Curve $y=f(x)$ is shown with thin solid line.

The small red circles show its representation at the discrete mesh. The big blue circles show the discrete Bessel transform.

As $f$ is self-Bessel, the red circles happen to be inside the blue circles. For the discrete Bessel transform with 8 nodes, relation $f=g$ is repoduced with 7 decimal digits.

C++ Generator of curves


#include<math.h>
#include<stdio.h>
#include<stdlib.h>
#define DB double
#define DO(x,y) for(x=0;x<y;x++)
DB jnp(int n,DB x){ return .5*( jn(n-1,x)-jn(n+1,x) ) ; } // Derivative of n th Bessel
DB jnz(int v, int k){ DB x,t; t=M_PI*(k+.5*v-.25); x= t - (v*v-.25)*.5/t;
                x-= jn(v,x)/jnp(v,x); // Newton adjustment of the root
                x-= jn(v,x)/jnp(v,x);
                x-= jn(v,x)/jnp(v,x);
                return x; } // the k th zero of v th Bessel
void ado(FILE *O, int X, int Y)
{ fprintf(O,"%c!PS-Adobe-2.0 EPSF-2.0\n",'%');
        fprintf(O,"%c%cBoundingBox: 0 0 %d %d\n",'%','%',X,Y);
        fprintf(O,"/M {moveto} bind def\n");
        fprintf(O,"/L {lineto} bind def\n");
        fprintf(O,"/S {stroke} bind def\n");
        fprintf(O,"/s {show newpath} bind def\n");
        fprintf(O,"/C {closepath} bind def\n");
        fprintf(O,"/F {fill} bind def\n");
        fprintf(O,"/O {.04 0 360 arc C S} bind def\n");
        fprintf(O,"/o {.02 0 360 arc C S} bind def\n");
        fprintf(O,"/times-Roman findfont 20 scalefont setfont\n");
        fprintf(O,"/W {setlinewidth} bind def\n");
        fprintf(O,"/RGB {setrgbcolor} bind def\n");}

int main(){ int m,n,v,k; DB s, x,y; FILE *o;
int M=8;
DB X[M+1],W[M+1],T[M+1][M+1],TT[M+1][M+1], F[M],G[M];
DB S=jnz(0,M+1);
DB qs=sqrt(1./S);
DB q=sqrt(2./S);
for(n=1;n<M+1;n++){ x=jnz(0,n); X[n]=x*qs; y=W[n]=q/fabs(j1(x));
                        printf("%3d %20.16lf %20.16lf\n",n,X[n],W[n]); }
for(m=1;m<=M;m++){ printf("%2d",m); for(n=1;n<=M;n++){ T[m][n]=W[m]*j0(X[m]*X[n])*W[n]; }}
for(m=1;m<=M;m++){printf("\n");
for(n=1;n<=M;n++){printf("%14.10lf",T[m][n]); }}
printf("\n");
for(m=1;m<=M;m++){printf("\n");
for(n=1;n<=M;n++){ s=0.;
                        for(k=1;k<=M;k++) s+=T[m][k]*T[k][n] ;
                        TT[m][n]=s;printf("%14.10lf",TT[m][n]);
                }}
printf("\n\n");
for(m=1;m<=M;m++){x=X[m]; y=exp(-x*x/2.); F[m]=y*W[m]; printf("%14.10lf",F[m]); }
printf("\n");
for(m=1;m<=M;m++){ s=0.; for(n=1;n<=M;n++) s+=T[m][n]*F[n];
                 G[m]=s;}
for(m=1;m<=M;m++) printf("%14.10lf",G[m]);
printf("\n");
o=fopen("besselTestEx.eps", "w"); ado(o,520,120);
#define M(x,y) fprintf(o,"%8.4lf %8.4lf M\n",0.+x, 0.+y);
#define L(x,y) fprintf(o,"%8.4lf %8.4lf L\n",0.+x, 0.+y);
#define O(x,y) fprintf(o,"%8.4lf %8.4lf O\n",0.+x, 0.+y);
#define o(x,y) fprintf(o,"%8.4lf %8.4lf o\n",0.+x, 0.+y);
fprintf(o,"10 10 translate 100 100 scale\n");
DO(n,6){M(n,1)L(n,0)}
DO(n,3){M(0,n/2.)L(5,n/2.)}
fprintf(o,"2 setlinecap 2 setlinejoin .006 W S\n");

M(0,1) DO(n,500){x=.01*(n+1); y=exp(-x*x/2.); L(x,y)}
fprintf(o,"1 setlinecap 1 setlinejoin S\n");
fprintf(o,"1 0 0 RGB .016 W\n");
for(m=1;m<=M;m++) o(X[m],F[m]/W[m])
fprintf(o,"0 0 1 RGB .01 W\n");
for(m=1;m<=M;m++) O(X[m],G[m]/W[m])
fprintf(o,"showpage\n%c%cTrailer\n",'%','%'); fclose(o);
system("epstopdf besselTestEx.eps");
system("open besselTestEx.pdf");
return 0;
}

Latex Generator of labels


\documentclass[12pt]{article}
\usepackage{geometry}
\usepackage{graphicx}
\usepackage{rotating}
\paperwidth 513pt
\paperheight 116pt
\topmargin -110pt
\oddsidemargin -92pt
\newcommand \ing {\includegraphics}
\newcommand \sx {\scalebox}
\newcommand \rot {\begin{rotate}}
\newcommand \ero {\end{rotate}}
\begin{document}
\begin{picture}(410,116)
%\put(2,4){\ing{03}}
\put(2,4){\ing{besselTEstEx}}
\put(2,107){\sx{1.4}{$y$}}
\put(2,60){\sx{1.4}{$\frac 1 2$}}
\put(2,9){\sx{1.4}{0}}
\put(10,0){\sx{1.4}{0}}
\put(108,0){\sx{1.4}{1}}
\put(208,0){\sx{1.4}{2}}
\put(309,0){\sx{1.4}{3}}
\put(409,0){\sx{1.4}{4}}
\put(505,0){\sx{1.5}{$x$}}
\put(76,77){\sx{1.3}{\rot{-28}$y\!=\! \exp(-x^2/2)$\ero }}
\end{picture}
\end{document}

Output

Coordinates of the nodes and the weight of the discrete Bessel of zero order with 9 nodes:

  1 0.4586366203331863 0.5195285071552201
  2 1.0527624177874750 0.7926530133638713
  3 1.6503968491849170 0.9935886501286754
  4 2.2488240306434886 1.1602517418890868
  5 2.8475519209198557 1.3058173905056820
  6 3.4464253249241210 1.4367104029426190
  7 4.0453800503454875 1.5566359753601471
  8 4.6443847886932446 1.6679612725451483

Values of the Gaussian and its discrete Bessel at these notes:

0.4676629801 0.4554250733 0.2545299239 0.0925535614 0.0226533673 0.0037855363 0.0004350617 0.0000345345
0.4676629900 0.4554250520 0.2545299536 0.0925535273 0.0226534013 0.0037855066 0.0004350816 0.0000344505

References

File history

Click on a date/time to view the file as it appeared at that time.

Date/TimeThumbnailDimensionsUserComment
current06:10, 1 December 2018Thumbnail for version as of 06:10, 1 December 20181,419 × 321 (54 KB)Maintenance script (talk | contribs)Importing image file

The following page uses this file:

Metadata