File:FourierExampleGauss16pol04Ta.png

From TORI
Revision as of 09:39, 21 June 2013 by Maintenance script (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Original file(2,134 × 470 pixels, file size: 88 KB, MIME type: image/png)

Explicit plot of the self-Fourier function and its discrete approximation.

The following curves are shown:

$y=A(x)=\exp(-x^2/2) x^2(-3+x^2)$ versus $x$, dashed curve;

its discrete presentaton with array of length $N=16$ with step $\mathrm {d}x=\sqrt{2 \pi/N} \approx0.626657$ , the $A$ is practically overlapped with the evaluation of its the Fourier transform, $B$, red curve, which approximates

$ B(x)=\frac{1}{\sqrt{2 \pi}}

\int_{-\infty}^{\infty} \exp(-i p x)~ A(p)~ \mathrm {d} p$

The difference of the discrete approcimations of $A$ and $B$ scaled with factor 100 is shown with saw-like line. This modulus of this difference remains of order of 1/1000, and only at the zero-th point of the grid (which corresponds to $x=–8 \mathrm{d} x \approx -5.013$ ) slightly exceeds this level.

Generators

The colleagues are cordially invited to load the generator below, to confirm that it reproduced the picture presented and to play it; for example, to change the function $F$ to just Gaussian exponential.

C++ generator of lines

The files ado.cin and fafo.cin should be in the working directory in order to compile the code below:

#include<math.h>
#include<stdio.h>
#include <stdlib.h>
#include <complex>
using namespace std;
#define z_type complex<double>
#define Re(x)  x.real()
#define Im(x)  x.imag()
#define RI(x)  x.real(),x.imag()
#define DB double
#define DO(x,y) for(x=0;x<y;x++)
#include "ado.cin"
#include"fafo.cin"
DB F(DB x){DB u=x*x; return u*(-3.+u)*exp(-x*x/2.);}
main(){        z_type * a, *b, c; int j,m,n, N=16; FILE *o;
       double step=sqrt(2*M_PI/N),x,y,u;
       a=(z_type *) malloc((size_t)((N+1)*sizeof(z_type)));
       b=(z_type *) malloc((size_t)((N+1)*sizeof(z_type)));
//for(j=0;j<N;j++) { x=step*(j-N/2); u=x*x; a[j]=b[j]=(3.+u*(-6.+u))*exp(-x*x/2); }
for(j=0;j<N;j++) { x=step*(j-N/2); u=x*x; a[j]=b[j]=F(x); }
fafo(b,N,1);
for(j=0;j<N;j++) printf("%2d %18.15f %18.15f  %18.15f %18.15f\n", j, RI(a[j]), RI(b[j])  );
o=fopen("FourierExampleGauss16pol04a.eps","w"); ado(o,1024,224); 
#define M(x,y) fprintf(o,"%6.4f %6.4f M\n",0.+x,0.+y);
#define L(x,y) fprintf(o,"%6.4f %6.4f L\n",0.+x,0.+y);
fprintf(o,"522 122 translate 100 100 scale\n");
M(-5,0) L(5,0) M(0,0) L(0,1) fprintf(o,".01 W S\n");
M(-5,1) L(5,1) M(-5,-1) L(5,-1)
for(m=-5;m<6;m++) {M(m,-1) L(m,1)} fprintf(o,".004 W S\n");
DO(m,201){x=-5.+.05*m; y=F(x); if(m/2*2==m)M(x,y)else L(x,y);} fprintf(o,".008 W 0 0 0 RGB S\n");
DB *X; X=(DB *) malloc((size_t)((N+1)*sizeof(DB))); DO(j,N){ x=step*(j-N/2); X[j]=x; }
DO(j,N){x=X[j];y=Re(a[j]); if(j==0)M(x,y)else L(x,y);} fprintf(o,".01 W 0 0 1 RGB S\n");
DO(j,N){x=X[j];y=Re(b[j]); if(j==0)M(x,y)else L(x,y);} fprintf(o,"0.01 W 1 0 0 RGB S\n");
DO(j,N){x=X[j];y=100.*(Re(b[j])-F(x)); if(j==0)M(x,y)else L(x,y);} fprintf(o,"0.007 W 0 0 .3 RGB S\n");
printf("X[0]=%9.5f\n",X[0]);
fprintf(o,"showpage\n%cTrailer",'%'); fclose(o);
 system("epstopdf FourierExampleGauss16pol04a.eps");
 system(    "open FourierExampleGauss16pol04a.pdf"); //these 2 commands may be specific for macintosh
 getchar(); system("killall Preview");// if run at another operational system, may need to modify
 free(a);
 free(b);
 free(X);
}

Latex generator of labels

\documentclass[12pt]{article} %<br> \usepackage{geometry} %<br> \paperwidth 1028pt %<br> \paperheight 226pt %<br> \topmargin -104pt %<br> \oddsidemargin -76pt %<br> \parindent 0pt %<br> \pagestyle{empty} %<br> \usepackage{graphicx} %<br> \newcommand \sx \scalebox %<br> \begin{document} %<br> \begin{picture}(1024,220) %<br> \put(4,0){\includegraphics{FourierExampleGauss16pol04a}} %<br> \put(8,214){\sx{2}{$y$}} %<br> \put(8,116){\sx{2}{0}} %<br> \put(0,20){\sx{2}{$-\!1$}} %<br> \put(104,0){\sx{2}{$-4$}} %<br> \put(304,0){\sx{2}{$-2$}} %<br> \put(523,0){\sx{2}{$0$}} %<br> \put(723,0){\sx{2}{$2$}} %<br> \put(923,0){\sx{2}{$4$}} %<br> \put(1019,0){\sx{2}{$x$}} %<br> \end{picture} %<br> \end{document}

File history

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

Date/TimeThumbnailDimensionsUserComment
current17:50, 20 June 2013Thumbnail for version as of 17:50, 20 June 20132,134 × 470 (88 KB)Maintenance script (talk | contribs)Importing image file
  • You cannot overwrite this file.

The following 2 pages link to this file:

Metadata