Difference between revisions of "File:Hermigaaplot.jpg"

From TORI
Jump to: navigation, search
(Importing image file)
 
 
Line 1: Line 1:
  +
Explicit plot of the [[Oscillator function]]s (coloured curves)
Importing image file
 
  +
and their approximations (black curves):
  +
  +
$y=F_n(x)=N_n^{-1/2} H_n(x)\exp(-x^2/2)$, $n=1$ .. $6$
  +
  +
$y=\tilde F_n(x)$, $n=1$ .. $6$
  +
==Description==
  +
The approximations are build with functions [[amos]] that
  +
determines the amplitude of oscillations of the oscillator function in vicinity of zero,
  +
and function [[qua]], that approximates the phase of oscillation in the quadratic potential.
  +
  +
  +
For real (and, in particular, for integer) values of argument $n$, function [[amos]] can be expressed through function [[Factorial]],
  +
  +
[[amos]]$(z)=\,$ $\displaystyle
  +
\frac{2^{-n/2}\, \sqrt{z!}}
  +
{\pi^{1/4}\, (x/2)!}
  +
$
  +
  +
In the code below, it is implemented as $~$ double Amp(int n) $~$ through function [[lof]] that, for real values of argument, behaves as $\ln$([[Factorial]]())
  +
  +
As for qua, it can be determined in such a way, that $\mathrm{qua}'(z)=\sqrt{1\!-\!z^2}$, id est,
  +
  +
$\mathrm{qua}(z)=\frac{1}{2}\big( z\,\sqrt{1\!-\!z^2}+\arcsin(z)\big)$
  +
  +
With function [[amos]] and [[qua]], the approximation of $n$th oscillator function is defined as follows:
  +
  +
$\tilde F_n(x)=\displaystyle \frac{\mathrm{amos}(n)}{\left(1-\frac{x^2}{2n+1}\right)^{1/4} }\,
  +
\cos\left(
  +
\left(2n\!+\!1+\frac{1/4}{2n\!+\!1}\right)
  +
\,
  +
\mathrm{qua}\!\left(\frac{x}{\sqrt{2n\!+\!1}}
  +
\right) -\frac{\pi n}{2}
  +
\right)$
  +
  +
==[[C++]] generator of curves==
  +
Files
  +
[[ado.cin]],
  +
[[fac.cin]],
  +
[[hermiteneve.txt]],
  +
[[hermitenodd.txt]]
  +
should be loaded in order to compile the code below.
  +
  +
<poem><nomathjax><nowiki>
  +
#include<math.h>
  +
#include<stdio.h>
  +
#include<stdlib.h>
  +
#include<complex>
  +
typedef std::complex<double> z_type;
  +
#define Re(x) ((x).real())
  +
#define Im(x) ((x).imag())
  +
#define DB double
  +
#define DO(x,y) for(x=0;x<y;x++)
  +
  +
DB HermiteH0[41][41]= // COEFFICIENTS OF EVEN normalized HERMITEH
  +
#include"hermiteneve.txt"
  +
;
  +
DB HermiteH1[41][41]= // COEFFICIENTS OF ODD normalized HERMITEH
  +
#include"hermitenodd.txt"
  +
;
  +
  +
DB hermiten(int n, DB x){ int m,M; DB s, xx;
  +
if(n>81){printf("hermite number %2d is not yet implemented (max. is 81)\n consider to stop..",n); getchar(); return 0;}
  +
xx=x*x; //printf("Herniten called with n=%3d x=%8.2lf\n",n,x);
  +
if(n/2*2==n){M=n/2; s=0.;for(m=M;m>0;m--) {s+=HermiteH0[M][m]; s*=xx;}
  +
return (HermiteH0[M][0]+s);}
  +
else{ M=(n-1)/2; s=0.; for(m=M;m>0;m--) {s+=HermiteH1[M][m]; s*=xx;}
  +
return (HermiteH1[M][0]+s)*x;}
  +
}
  +
  +
// #include"arcsin.cin"
  +
  +
DB qua(DB x) { return .5*(x*sqrt(1.-x*x)+asin(x));}
  +
  +
//DB Amp(int n){ return sqrt(Re(fac(0.+n))/sqrt(M_PI))/( exp((log(2.)/2.)*n)*Re(fac(.5*n)));}
  +
  +
#include "fac.cin"
  +
  +
DB Amp(int n){ return exp( -.5*log(2.)*n + (.5*Re(lof(0.+n))-Re(lof(.5*n))) )/sqrt(sqrt(M_PI));}
  +
//#include "amos.cin"
  +
  +
DB osb(int n,DB x){ //Later both n,x should be z_type, but not yet.
  +
DB q=2.*n+1.;
  +
DB Q=sqrt(q);
  +
DB t=x/Q;
  +
DB r=sqrt(1.-t*t); r=1./sqrt(r);
  +
DB a=(q+.25/q)*qua(t)-M_PI/2.*n;
  +
// printf("%2d %6.3lf q=%6.3lf Q=%6.3lf t=%6.3lf r=%6.3lf a=%6.3lf ",n,x,q,Q,t,r,a); getchar();
  +
return cos(a)*r;}
  +
  +
#include"ado.cin"
  +
  +
int main(){ // printf("%16d %16d\n",INT_MIN,INT_MAX);
  +
int M,m,n; DB x,xx,y,z,s;
  +
FILE *o; o=fopen("hermigaaplo4.eps", "w");
  +
ado(o,804,224);
  +
fprintf(o,"402 102 translate 100 100 scale 2 setlinecap 1 setlinejoin\n");
  +
#define M(x,y) fprintf(o,"%6.4lf %6.4lf M\n",x+0., y+0.);
  +
#define L(x,y) fprintf(o,"%6.4lf %6.4lf L\n",x+0., y+0.);
  +
  +
for(m=-4; m<5; m++) {M(m,-1)L(m,1)}
  +
for(n=-1; n<2; n++) {M(-4,n)L(4,n)}
  +
fprintf(o,".01 W 0 0 0 RGB S\n");
  +
  +
DO(n,201){x=.05*(n-100); y= hermiten(0,x)*exp(-x*x/2.); if(n==0)M(x,y) else L(x,y) } fprintf(o,"1 0 0 RGB .016 W S\n ");
  +
DO(n,201){x=.05*(n-100); y= hermiten(1,x)*exp(-x*x/2.); if(n==0)M(x,y) else L(x,y) } fprintf(o,"1 0 0 RGB .016 W S\n ");
  +
DO(n,201){x=.05*(n-100); y= hermiten(2,x)*exp(-x*x/2.); if(n==0)M(x,y) else L(x,y) } fprintf(o,"1 0 0 RGB .016 W S\n ");
  +
DO(n,201){x=.05*(n-100); y= hermiten(3,x)*exp(-x*x/2.); if(n==0)M(x,y) else L(x,y) } fprintf(o,"1 0 0 RGB .016 W S\n ");
  +
DO(n,201){x=.05*(n-100); y= hermiten(4,x)*exp(-x*x/2.); if(n==0)M(x,y) else L(x,y) } fprintf(o,"0 .7 0 RGB .016 W S\n ");
  +
DO(n,201){x=.05*(n-100); y= hermiten(5,x)*exp(-x*x/2.); if(n==0)M(x,y) else L(x,y) } fprintf(o,"0 0 1 RGB .016 W S\n ");
  +
DO(n,201){x=.05*(n-100); y= hermiten(6,x)*exp(-x*x/2.); if(n==0)M(x,y) else L(x,y) } fprintf(o,"1 0 1 RGB .016 W S\n ");
  +
  +
DO(m,7){DB a=Amp(m); DB xmax=sqrt(2*m+1.);
  +
DO(n,601){ x=-xmax+.012*(n+.5); if(x>xmax) break; y= a*osb(m,x); if(n==0)M(x,y) else L(x,y) } fprintf(o,"0 0 0 RGB .01 W S\n ");
  +
}
  +
  +
fprintf(o,"showpage\n%c%cTrailer\n",'%','%');
  +
fclose(o);
  +
system("epstopdf hermigaaplo4.eps");
  +
system("open hermigaaplo4.pdf");
  +
}
  +
</nowiki></nomathjax></poem>
  +
  +
==[[Latex]] generator of curves==
  +
  +
<poem><nomathjax><nowiki>
  +
\documentclass[12pt]{article}
  +
\usepackage{geometry}
  +
\paperwidth 806pt
  +
\paperheight 230pt
  +
\topmargin -104pt
  +
\oddsidemargin -73pt
  +
\pagestyle{empty}
  +
\usepackage{graphicx}
  +
\parindent 0pt
  +
\textwidth 700px
  +
\textheight 900px
  +
\newcommand \sx {\scalebox}
  +
\begin{document}
  +
\begin{picture}(800,223)
  +
\put(0,0){\includegraphics{hermigaaplo4}}
  +
\put(389,216){\sx{1.8}{$y$}}
  +
\put(388,194){\sx{1.8}{$1$}}
  +
\put(376,-1){\sx{1.8}{$-1$}}
  +
\put( 85,80){\sx{2}{$-3$}}
  +
\put(185,80){\sx{2}{$-2$}}
  +
\put(285,80){\sx{2}{$-1$}}
  +
\put(398,80){\sx{2}{$0$}}
  +
\put(498,80){\sx{2}{$1$}}
  +
\put(598,80){\sx{2}{$2$}}
  +
\put(698,80){\sx{2}{$3$}}
  +
\put(792,80){\sx{2}{$x$}}
  +
%Top Left
  +
\put(40,208){\sx{1.8}{$\tilde F_6(x)$}}
  +
\put(102,208){\sx{1.8}{$\tilde F_4(x)$}}
  +
\put(180,208){\sx{1.8}{$\tilde F_2(x)$}}
  +
\put(1,140){\sx{1.8}{$F_6(x)$}}
  +
%bottom left
  +
\put(10,58){\sx{1.8}{$F_5(x)$}}
  +
\put(22,10){\sx{1.8}{$\tilde F_5(x)$}}
  +
\put(140,10){\sx{1.8}{$\tilde F_3(x)$}}
  +
\put(233,10){\sx{1.8}{$\tilde F_1(x)$}}
  +
%
  +
\put(370,180){\sx{1.8}{$y=F_0(x)$}}
  +
\put(452,208){\sx{1.8}{$\tilde F_0(x)$}}
  +
\put(526,208){\sx{1.8}{$\tilde F_1(x)$}}
  +
\put(604,208){\sx{1.8}{$\tilde F_2$}}
  +
\put(646,208){\sx{1.8}{$\tilde F_3$}}
  +
\put(682,208){\sx{1.8}{$\tilde F_4$}}
  +
\put(734,208){\sx{1.8}{$\tilde F_5$}}
  +
\put(762,208){\sx{1.8}{$\tilde F_6$}}
  +
%
  +
\put(755,144){\sx{1.8}{$F_6(x)$}}
  +
%
  +
\put(611,58){\sx{1.8}{$y\!=\!F_6(x)$}}
  +
\end{picture}
  +
\end{document}
  +
</nowiki></nomathjax></poem>
  +
  +
==References==
  +
<references/>
  +
  +
[[Category:Amos]]
  +
[[Category:Approximations]]
  +
[[Category:Arcsin]]
  +
[[Category:C++]]
  +
[[Category:Exlicit plot]]
  +
[[Category:Factorial]]
  +
[[Category:HermiteH]]
  +
[[Category:Latex]]
  +
[[Category:Oscillator function]]
  +
[[Category:Qua]]

Latest revision as of 08:37, 1 December 2018

Explicit plot of the Oscillator functions (coloured curves) and their approximations (black curves):

$y=F_n(x)=N_n^{-1/2} H_n(x)\exp(-x^2/2)$, $n=1$ .. $6$

$y=\tilde F_n(x)$, $n=1$ .. $6$

Description

The approximations are build with functions amos that determines the amplitude of oscillations of the oscillator function in vicinity of zero, and function qua, that approximates the phase of oscillation in the quadratic potential.


For real (and, in particular, for integer) values of argument $n$, function amos can be expressed through function Factorial,

amos$(z)=\,$ $\displaystyle \frac{2^{-n/2}\, \sqrt{z!}} {\pi^{1/4}\, (x/2)!} $

In the code below, it is implemented as $~$ double Amp(int n) $~$ through function lof that, for real values of argument, behaves as $\ln$(Factorial())

As for qua, it can be determined in such a way, that $\mathrm{qua}'(z)=\sqrt{1\!-\!z^2}$, id est,

$\mathrm{qua}(z)=\frac{1}{2}\big( z\,\sqrt{1\!-\!z^2}+\arcsin(z)\big)$

With function amos and qua, the approximation of $n$th oscillator function is defined as follows:

$\tilde F_n(x)=\displaystyle \frac{\mathrm{amos}(n)}{\left(1-\frac{x^2}{2n+1}\right)^{1/4} }\, \cos\left( \left(2n\!+\!1+\frac{1/4}{2n\!+\!1}\right) \, \mathrm{qua}\!\left(\frac{x}{\sqrt{2n\!+\!1}} \right) -\frac{\pi n}{2} \right)$

C++ generator of curves

Files ado.cin, fac.cin, hermiteneve.txt, hermitenodd.txt should be loaded in order to compile the code below.


#include<math.h>
#include<stdio.h>
#include<stdlib.h>
#include<complex>
typedef std::complex<double> z_type;
#define Re(x) ((x).real())
#define Im(x) ((x).imag())
#define DB double
#define DO(x,y) for(x=0;x<y;x++)

DB HermiteH0[41][41]= // COEFFICIENTS OF EVEN normalized HERMITEH
#include"hermiteneve.txt"
;
DB HermiteH1[41][41]= // COEFFICIENTS OF ODD normalized HERMITEH
#include"hermitenodd.txt"
;

DB hermiten(int n, DB x){ int m,M; DB s, xx;
if(n>81){printf("hermite number %2d is not yet implemented (max. is 81)\n consider to stop..",n); getchar(); return 0;}
xx=x*x; //printf("Herniten called with n=%3d x=%8.2lf\n",n,x);
if(n/2*2==n){M=n/2; s=0.;for(m=M;m>0;m--) {s+=HermiteH0[M][m]; s*=xx;}
                                      return (HermiteH0[M][0]+s);}
  else{ M=(n-1)/2; s=0.; for(m=M;m>0;m--) {s+=HermiteH1[M][m]; s*=xx;}
                                      return (HermiteH1[M][0]+s)*x;}
}

// #include"arcsin.cin"

DB qua(DB x) { return .5*(x*sqrt(1.-x*x)+asin(x));}

//DB Amp(int n){ return sqrt(Re(fac(0.+n))/sqrt(M_PI))/( exp((log(2.)/2.)*n)*Re(fac(.5*n)));}

#include "fac.cin"

DB Amp(int n){ return exp( -.5*log(2.)*n + (.5*Re(lof(0.+n))-Re(lof(.5*n))) )/sqrt(sqrt(M_PI));}
//#include "amos.cin"

DB osb(int n,DB x){ //Later both n,x should be z_type, but not yet.
 DB q=2.*n+1.;
 DB Q=sqrt(q);
 DB t=x/Q;
 DB r=sqrt(1.-t*t); r=1./sqrt(r);
 DB a=(q+.25/q)*qua(t)-M_PI/2.*n;
// printf("%2d %6.3lf q=%6.3lf Q=%6.3lf t=%6.3lf r=%6.3lf a=%6.3lf ",n,x,q,Q,t,r,a); getchar();
 return cos(a)*r;}

#include"ado.cin"

int main(){ // printf("%16d %16d\n",INT_MIN,INT_MAX);
int M,m,n; DB x,xx,y,z,s;
FILE *o; o=fopen("hermigaaplo4.eps", "w");
ado(o,804,224);
fprintf(o,"402 102 translate 100 100 scale 2 setlinecap 1 setlinejoin\n");
#define M(x,y) fprintf(o,"%6.4lf %6.4lf M\n",x+0., y+0.);
#define L(x,y) fprintf(o,"%6.4lf %6.4lf L\n",x+0., y+0.);

for(m=-4; m<5; m++) {M(m,-1)L(m,1)}
for(n=-1; n<2; n++) {M(-4,n)L(4,n)}
fprintf(o,".01 W 0 0 0 RGB S\n");

DO(n,201){x=.05*(n-100); y= hermiten(0,x)*exp(-x*x/2.); if(n==0)M(x,y) else L(x,y) } fprintf(o,"1 0 0 RGB .016 W S\n ");
DO(n,201){x=.05*(n-100); y= hermiten(1,x)*exp(-x*x/2.); if(n==0)M(x,y) else L(x,y) } fprintf(o,"1 0 0 RGB .016 W S\n ");
DO(n,201){x=.05*(n-100); y= hermiten(2,x)*exp(-x*x/2.); if(n==0)M(x,y) else L(x,y) } fprintf(o,"1 0 0 RGB .016 W S\n ");
DO(n,201){x=.05*(n-100); y= hermiten(3,x)*exp(-x*x/2.); if(n==0)M(x,y) else L(x,y) } fprintf(o,"1 0 0 RGB .016 W S\n ");
DO(n,201){x=.05*(n-100); y= hermiten(4,x)*exp(-x*x/2.); if(n==0)M(x,y) else L(x,y) } fprintf(o,"0 .7 0 RGB .016 W S\n ");
DO(n,201){x=.05*(n-100); y= hermiten(5,x)*exp(-x*x/2.); if(n==0)M(x,y) else L(x,y) } fprintf(o,"0 0 1 RGB .016 W S\n ");
DO(n,201){x=.05*(n-100); y= hermiten(6,x)*exp(-x*x/2.); if(n==0)M(x,y) else L(x,y) } fprintf(o,"1 0 1 RGB .016 W S\n ");

DO(m,7){DB a=Amp(m); DB xmax=sqrt(2*m+1.);
DO(n,601){ x=-xmax+.012*(n+.5); if(x>xmax) break; y= a*osb(m,x); if(n==0)M(x,y) else L(x,y) } fprintf(o,"0 0 0 RGB .01 W S\n ");
        }

fprintf(o,"showpage\n%c%cTrailer\n",'%','%');
fclose(o);
system("epstopdf hermigaaplo4.eps");
system("open hermigaaplo4.pdf");
}

Latex generator of curves


\documentclass[12pt]{article}
\usepackage{geometry}
\paperwidth 806pt
\paperheight 230pt
\topmargin -104pt
\oddsidemargin -73pt
\pagestyle{empty}
\usepackage{graphicx}
\parindent 0pt
\textwidth 700px
\textheight 900px
\newcommand \sx {\scalebox}
\begin{document}
\begin{picture}(800,223)
\put(0,0){\includegraphics{hermigaaplo4}}
\put(389,216){\sx{1.8}{$y$}}
\put(388,194){\sx{1.8}{$1$}}
\put(376,-1){\sx{1.8}{$-1$}}
\put( 85,80){\sx{2}{$-3$}}
\put(185,80){\sx{2}{$-2$}}
\put(285,80){\sx{2}{$-1$}}
\put(398,80){\sx{2}{$0$}}
\put(498,80){\sx{2}{$1$}}
\put(598,80){\sx{2}{$2$}}
\put(698,80){\sx{2}{$3$}}
\put(792,80){\sx{2}{$x$}}
%Top Left
\put(40,208){\sx{1.8}{$\tilde F_6(x)$}}
\put(102,208){\sx{1.8}{$\tilde F_4(x)$}}
\put(180,208){\sx{1.8}{$\tilde F_2(x)$}}
\put(1,140){\sx{1.8}{$F_6(x)$}}
%bottom left
\put(10,58){\sx{1.8}{$F_5(x)$}}
\put(22,10){\sx{1.8}{$\tilde F_5(x)$}}
\put(140,10){\sx{1.8}{$\tilde F_3(x)$}}
\put(233,10){\sx{1.8}{$\tilde F_1(x)$}}
%
\put(370,180){\sx{1.8}{$y=F_0(x)$}}
\put(452,208){\sx{1.8}{$\tilde F_0(x)$}}
\put(526,208){\sx{1.8}{$\tilde F_1(x)$}}
\put(604,208){\sx{1.8}{$\tilde F_2$}}
\put(646,208){\sx{1.8}{$\tilde F_3$}}
\put(682,208){\sx{1.8}{$\tilde F_4$}}
\put(734,208){\sx{1.8}{$\tilde F_5$}}
\put(762,208){\sx{1.8}{$\tilde F_6$}}
%
\put(755,144){\sx{1.8}{$F_6(x)$}}
%
\put(611,58){\sx{1.8}{$y\!=\!F_6(x)$}}
\end{picture}
\end{document}

References

File history

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

Date/TimeThumbnailDimensionsUserComment
current06:12, 1 December 2018Thumbnail for version as of 06:12, 1 December 20181,672 × 477 (247 KB)Maintenance script (talk | contribs)Importing image file
  • You cannot overwrite this file.

There are no pages that link to this file.

Metadata