2 * newton'sche bewegungsgleichung
5 * usage: ./newton <steps> <alpha> <x_p> <v_p>
15 int main(int argc,char **argv) {
17 double alpha,force,tau;
19 int fd; /* data file */
24 printf("usage: %s <steps> <alpha> <x_0> <v_0>\n",argv[0]);
28 /* init + starting conditions */
34 sprintf(filename,"newton_%d_%f_%f_%f.plot",steps,alpha,x_p,v_p);
37 /* allocate memory for data buffer */
38 if((buf=(double *)malloc(3*steps*sizeof(double)))==NULL) {
39 puts("malloc failed!");
42 buf[0]=0; buf[1]=x_p; buf[2]=v_p;
45 for(i=0;i<steps-1;i++) {
48 v=v_p+force*tau; /* masse = 1 */
51 buf[3+j]=i*tau; buf[4+j]=x; buf[5+j]=v;
57 gp_add_data(fd,buf,3,steps,TYPE_DOUBLE);