added random stuff
[physik/computational_physics.git] / bessel_2.c
1 #include <stdio.h>
2 #include <math.h>
3 #include "general.h"
4 #include "g_plot.h"
5
6 #define L_PLUS 50
7 #define MAX_R 10
8 #define STEP_R .5
9 #define MAX_L 50
10
11 int main(int argc,char **argv) {
12         int i;
13         double F[MAX_L];
14         double J[MAX_L];
15         double p;
16         double r;
17
18         for(r=0;r<MAX_R;r+=STEP_R) {
19                 i=MAX_L-2;
20                 J[0]=(r==0)?1:sin(r)/r;
21                 F[MAX_L-1]=0;
22                 F[MAX_L-2]=1;
23
24                 while(i) {
25                         F[i-1]=(2*i+1)/(r*r)*F[i]-F[i+1];
26                         i--;
27                 }
28
29                 p=J[0]/F[0];
30
31                 for(i=1;i<MAX_L;i++) J[i]=p*F[i];
32
33                 printf("%f %f %f ...\n",r,J[0],J[1]);
34
35         }
36
37         return 1;
38 }
39
40