]> hackdaworld.org Git - physik/computational_physics.git/commitdiff
added bessel_2.c
authorhackbard <hackbard>
Tue, 24 Feb 2004 13:16:39 +0000 (13:16 +0000)
committerhackbard <hackbard>
Tue, 24 Feb 2004 13:16:39 +0000 (13:16 +0000)
Makefile
bessel_2.c [new file with mode: 0644]

index ad5c1cfe404a88326ddddd0ef7515ccf1d8beaf0..3993f5af2053175825a95bac20928a7e4012dfcf 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -5,7 +5,7 @@ CFLAGS = -O3 -Wall
 LIBS = -L/usr/lib -lm
 
 API = g_plot.o general.o
-OBJS = newton zentral homogen integral-1_2 integral-2_2 polynom_interpolation kettenbruchentwicklung bessel_1
+OBJS = newton zentral homogen integral-1_2 integral-2_2 polynom_interpolation kettenbruchentwicklung bessel_1 bessel_2
 
 all: $(OBJS)
 
@@ -33,6 +33,9 @@ kettenbruchentwicklung: $(API)
 bessel_1: $(API)
        $(CC) $(CFLAGS) -o $@ $(API) $(LIBS) bessel_1.c
 
+bessel_2: $(API)
+       $(CC) $(CFLAGS) -o $@ $(API) $(LIBS) bessel_2.c
+
 clean:
        rm $(API) $(OBJS)
 
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;
+}
+
+