added bessel_1.c + modified Makefile
[physik/computational_physics.git] / bessel_1.c
diff --git a/bessel_1.c b/bessel_1.c
new file mode 100644 (file)
index 0000000..afc0a97
--- /dev/null
@@ -0,0 +1,56 @@
+#include <stdio.h>
+#include <math.h>
+#include "g_plot.h"
+#include "general.h"
+
+#define EPSILON .0001
+#define MAX_L 100
+#define R_STEP 0.1
+#define MAX_R 30
+
+int main(int argc, char **argv) {
+       int l;
+       // int fd;
+       int i;
+       double r;
+       double t;
+       double delta=2*EPSILON;
+       double Jl,Jl_1;
+
+       /*
+       if(argc!=2) {
+               printf("usage: %s file\n"argv[0]);
+               return 1;
+       }
+       */
+
+       // for(l=0:l<MAX_L;l++)
+       l=1;
+
+       for(r=0;r<MAX_R;r+=R_STEP) {
+
+       /* fd */
+       // fd=gp_init(argv[1]);
+
+       i=1;
+       t=1/(fak2(2*l-1));
+       Jl_1=t;
+       t=t/(2*l+1);
+       Jl=t;
+       delta=2*EPSILON;
+       while(delta>EPSILON) {
+               t*=-(r*r)/(2*i);
+               Jl_1+=t;
+               t*=(1./(2*l+1+i));
+               Jl+=t;
+               delta=absolute_value(t/Jl);
+               i++;
+       }
+       printf("%f %f %f (i=%d)\n",r,Jl,Jl_1,i);
+
+       }
+       // gp_close(fd);
+       return 1;
+}
+
+