added bessel_2.c
[physik/computational_physics.git] / bessel_2.c
diff --git a/bessel_2.c b/bessel_2.c
new file mode 100644 (file)
index 0000000..a6245a9
--- /dev/null
@@ -0,0 +1,40 @@
+#include <stdio.h>
+#include <math.h>
+#include "general.h"
+#include "g_plot.h"
+
+#define L_PLUS 50
+#define MAX_R 10
+#define STEP_R .5
+#define MAX_L 50
+
+int main(int argc,char **argv) {
+       int i;
+       double F[MAX_L];
+       double J[MAX_L];
+       double p;
+       double r;
+
+       for(r=0;r<MAX_R;r+=STEP_R) {
+               i=MAX_L-2;
+               J[0]=(r==0)?1:sin(r)/r;
+               F[MAX_L-1]=0;
+               F[MAX_L-2]=1;
+
+               while(i) {
+                       F[i-1]=(2*i+1)/(r*r)*F[i]-F[i+1];
+                       i--;
+               }
+
+               p=J[0]/F[0];
+
+               for(i=1;i<MAX_L;i++) J[i]=p*F[i];
+
+               printf("%f %f %f ...\n",r,J[0],J[1]);
+
+       }
+
+       return 1;
+}
+
+