X-Git-Url: https://hackdaworld.org/gitweb/?p=physik%2Fcomputational_physics.git;a=blobdiff_plain;f=kettenbruchentwicklung.c;fp=kettenbruchentwicklung.c;h=3ab3445bae818b576aa168ee68d9326eaa99f704;hp=0000000000000000000000000000000000000000;hb=936dfe8d44eb6beeecb48b201db22bb0d9de9956;hpb=f18089061fde90286be5810c1762ae3d170d1608 diff --git a/kettenbruchentwicklung.c b/kettenbruchentwicklung.c new file mode 100644 index 0000000..3ab3445 --- /dev/null +++ b/kettenbruchentwicklung.c @@ -0,0 +1,55 @@ +#include +#include +#include "g_plot.h" + +#define INT .5 +#define GENAUIGKEIT .5 +#define GENAUIGKEIT_2 (GENAUIGKEIT*GENAUIGKEIT) +#define PI M_PI + +int main(int argc,char **argv) { + double f_n=0,f_a=0; + double A,A_1,A_2; + double B,B_1,B_2; + double a=0; + int i; + double x; + int fd; + + /* parse command line */ + if(argc!=2) { + printf("usage:\n"); + printf("%s plotfile\n",argv[0]); + return -1; + } + + /* main init */ + x=0; + fd=gp_init(argv[1]); + + /* x loop */ + while(x<4*PI) { + + /* init */ + A_1=0; A_2=x; A=x; + B_1=1; B_2=0; B=1; + i=1; + f_n=0; + f_n=f_a+2.0*GENAUIGKEIT; + /* loop bis y genuaigkeit */ + while(!(((f_n-f_a)*(f_n-f_a))>1)*(i>>1)*x; + A=i*A_1+a*A_2; + B=i*B_1+a*B_2; + f_n=A/B; + } + printf("debug: x=%f, y=%f bei N=%d (a=%f)\n",x,f_n,i,a); + gp_add_data(fd,&f_n,1,1,TYPE_DOUBLE); + x+=INT; + } + gp_close(fd); + return 1; +} +