Difference between revisions of "File:Hermigaplot.jpg"

From TORI
Jump to: navigation, search
(Importing image file)
 
 
Line 1: Line 1:
  +
Explicit plot of [[Oscillator function]]s
Importing image file
 
  +
  +
$y=h_n(x)=N_n^{-1/2}\, H_n(x)\, \exp(-x^2/2)$
  +
  +
for $n=0 .. 6$
  +
  +
==[[C++]] generator of curves==
  +
File [[ado.cin]] should be loaded to compile the code below.
  +
<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 HermiteNo[14]={1, 2, 8, 48, 384, 3840, 46080, 645120, 10321920, 185794560,
  +
3715891200, 81749606400, 1961990553600, 51011754393600};
  +
  +
DB HermitH0[7][7]= // COEFFICIENTS OF EVEN HERMITEH
  +
{{1, 0, 0, 0, 0, 0, 0}, {-2, 4, 0, 0, 0, 0, 0},
  +
{12, -48, 16, 0, 0, 0, 0}, {-120, 720, -480, 64, 0, 0, 0},
  +
{1680, -13440, 13440, -3584, 256, 0, 0},
  +
{-30240, 302400, -403200, 161280, -23040, 1024, 0},
  +
{665280, -7983360, 13305600, -7096320, 1520640, -135168, 4096}};
  +
  +
DB HermitH1[7][7]= // COEFFICIENTS OF ODD HERMITЕH
  +
{{2, 0, 0, 0, 0, 0, 0}, {-12, 8, 0, 0, 0, 0, 0},
  +
{120, -160, 32, 0, 0, 0, 0}, {-1680, 3360, -1344, 128, 0, 0, 0},
  +
{30240, -80640, 48384, -9216, 512, 0, 0},
  +
{-665280, 2217600, -1774080, 506880, -56320, 2048, 0},
  +
{17297280, -69189120, 69189120, -26357760,4392960, -319488, 8192}};
  +
  +
DB HermitH(int n,DB x){ int m,M; DB s, xx;
  +
if(n==0) return 1.;
  +
if(n==1) return x+x;
  +
if(n>13) {printf("hermite number %2d is not yet implemented (max. is 13)\n consider to stop..",n); getchar(); return 0;}
  +
xx=x*x; //printf("Hernith 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+=HermitH0[M][m]; s*=xx;}
  +
return (HermitH0[M][0]+s);}
  +
else{ M=(n-1)/2; s=0.; for(m=M;m>0;m--) {s+=HermitH1[M][m]; s*=xx;}
  +
return (HermitH1[M][0]+s)*x; }
  +
}
  +
  +
DB hermiten(int n,DB x){ if(n>13) {printf("hermite number %2d is not yet implemented (max. is 13)\n consider to stop..",n); getchar(); return 0;}
  +
return HermitH(n,x)/sqrt(sqrt(M_PI)*HermiteNo[n]);
  +
}
  +
  +
#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("hermigaplo.eps", "w");
  +
ado(o,804,204);
  +
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,"0 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,"0 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,"0 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,".8 0 .9 RGB .016 W S\n ");
  +
fprintf(o,"showpage\n%c%cTrailer\n",'%','%'); fclose(o);
  +
system("epstopdf hermigaplo.eps");
  +
system("open hermigaplo.pdf");
  +
}
  +
</nowiki></nomathjax></poem>
  +
  +
==[[Latex]] generator of labels==
  +
  +
<poem><nomathjax><nowiki>
  +
\documentclass[12pt]{article}
  +
\usepackage{geometry}
  +
\paperwidth 806pt
  +
\paperheight 210pt
  +
\topmargin -104pt
  +
\oddsidemargin -73pt
  +
\pagestyle{empty}
  +
\usepackage{graphicx}
  +
\parindent 0pt
  +
\textwidth 700px
  +
\textheight 900px
  +
\newcommand \sx {\scalebox}
  +
\begin{document}
  +
\begin{picture}(800,203)
  +
\put(0,0){\includegraphics{hermigaplo}}
  +
\put(386,744){\sx{2}{$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$}}
  +
\put(370,180){\sx{1.8}{$y=F_0(x)$}}
  +
\put(480,172){\sx{1.8}{$F_1(x)$}}
  +
\put(540,170){\sx{1.8}{$F_2(x)$}}
  +
\put(600,166){\sx{1.8}{$F_3$}}
  +
\put(640,164){\sx{1.8}{$F_4$}}
  +
\put(676,162){\sx{1.8}{$F_5$}}
  +
\put(712,160){\sx{1.8}{$F_6$}}
  +
\end{picture}
  +
\end{document}
  +
</nowiki></nomathjax></poem>
  +
  +
==References==
  +
<references/>
  +
  +
[[Category:C++]]
  +
[[Category:Explicit plot]]
  +
[[Category:Hermite polynomial]]
  +
[[Category:Harmonic Oscillator]]
  +
[[Category:Hermite Gauss mode]]
  +
[[Category:Latex]]
  +
[[Category:Optics]]
  +
[[Category:Oscillator function]]
  +
[[Category:Quantum mechanics]]

Latest revision as of 08:37, 1 December 2018

Explicit plot of Oscillator functions

$y=h_n(x)=N_n^{-1/2}\, H_n(x)\, \exp(-x^2/2)$

for $n=0 .. 6$

C++ generator of curves

File ado.cin should be loaded to compile the code below.


#include<math.h>
#include<stdio.h>
#include<stdlib.h>
#define DB double
#define DO(x,y) for(x=0;x<y;x++)

DB HermiteNo[14]={1, 2, 8, 48, 384, 3840, 46080, 645120, 10321920, 185794560,
3715891200, 81749606400, 1961990553600, 51011754393600};

DB HermitH0[7][7]= // COEFFICIENTS OF EVEN HERMITEH
{{1, 0, 0, 0, 0, 0, 0}, {-2, 4, 0, 0, 0, 0, 0},
{12, -48, 16, 0, 0, 0, 0}, {-120, 720, -480, 64, 0, 0, 0},
{1680, -13440, 13440, -3584, 256, 0, 0},
{-30240, 302400, -403200, 161280, -23040, 1024, 0},
{665280, -7983360, 13305600, -7096320, 1520640, -135168, 4096}};

DB HermitH1[7][7]= // COEFFICIENTS OF ODD HERMITЕH
{{2, 0, 0, 0, 0, 0, 0}, {-12, 8, 0, 0, 0, 0, 0},
{120, -160, 32, 0, 0, 0, 0}, {-1680, 3360, -1344, 128, 0, 0, 0},
{30240, -80640, 48384, -9216, 512, 0, 0},
{-665280, 2217600, -1774080, 506880, -56320, 2048, 0},
{17297280, -69189120, 69189120, -26357760,4392960, -319488, 8192}};

DB HermitH(int n,DB x){ int m,M; DB s, xx;
if(n==0) return 1.;
if(n==1) return x+x;
if(n>13) {printf("hermite number %2d is not yet implemented (max. is 13)\n consider to stop..",n); getchar(); return 0;}
xx=x*x; //printf("Hernith 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+=HermitH0[M][m]; s*=xx;}
                                       return (HermitH0[M][0]+s);}
  else{ M=(n-1)/2; s=0.; for(m=M;m>0;m--) {s+=HermitH1[M][m]; s*=xx;}
                                      return (HermitH1[M][0]+s)*x; }
}

DB hermiten(int n,DB x){ if(n>13) {printf("hermite number %2d is not yet implemented (max. is 13)\n consider to stop..",n); getchar(); return 0;}
return HermitH(n,x)/sqrt(sqrt(M_PI)*HermiteNo[n]);
}

#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("hermigaplo.eps", "w");
ado(o,804,204);
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,"0 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,"0 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,"0 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,".8 0 .9 RGB .016 W S\n ");
fprintf(o,"showpage\n%c%cTrailer\n",'%','%'); fclose(o);
system("epstopdf hermigaplo.eps");
system("open hermigaplo.pdf");
}

Latex generator of labels


\documentclass[12pt]{article}
\usepackage{geometry}
\paperwidth 806pt
\paperheight 210pt
\topmargin -104pt
\oddsidemargin -73pt
\pagestyle{empty}
\usepackage{graphicx}
\parindent 0pt
\textwidth 700px
\textheight 900px
\newcommand \sx {\scalebox}
\begin{document}
\begin{picture}(800,203)
\put(0,0){\includegraphics{hermigaplo}}
\put(386,744){\sx{2}{$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$}}
\put(370,180){\sx{1.8}{$y=F_0(x)$}}
\put(480,172){\sx{1.8}{$F_1(x)$}}
\put(540,170){\sx{1.8}{$F_2(x)$}}
\put(600,166){\sx{1.8}{$F_3$}}
\put(640,164){\sx{1.8}{$F_4$}}
\put(676,162){\sx{1.8}{$F_5$}}
\put(712,160){\sx{1.8}{$F_6$}}
\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 × 435 (160 KB)Maintenance script (talk | contribs)Importing image file
  • You cannot overwrite this file.

The following 2 pages link to this file:

Metadata