Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /********************************************
- *********************************************
- *********************************************/
- /**********desintegration.c******************/
- /********************************************
- *********************************************
- *********************************************/
- #include <stdio.h>
- #include <stdlib.h>
- #include <math.h>
- float f(float N)
- {
- float lamda = 8.02;
- return -lamda*N;
- }
- void euler()
- {
- float t,N,h;
- t=0.;
- N=10000000000;
- h=0.01;
- FILE *fichier;
- fichier=fopen("desintegration.txt","w+");
- while(t<80)
- {
- t+=h;
- N=N+h*f(N);
- fprintf(fichier,"%f\t%f\n", t,N);
- //printf("%f\t%f\n", t,N);
- }
- fclose(fichier);
- }
- int main()
- {
- euler();
- return 0;
- }
- /********************************************
- *********************************************
- *********************************************/
- /**********pendule.c******************/
- /********************************************
- *********************************************
- *********************************************/
- #include <stdio.h>
- #include <stdlib.h>
- #include <math.h>
- float f(float N)
- {
- float lamda = 8.02;
- return -lamda*N;
- }
- void euler()
- {
- float o,w,t,h;
- t=0.;
- o=1.;
- w=0.5;
- h=0.01;
- FILE *fichier;
- fichier=fopen("pendule.txt","w+");
- while(t<50)
- {
- t+=h;
- o+=h*w;
- w+=-h*(9.8/0.2)*o;
- fprintf(fichier,"%f\t%f\t%f\n", t,o,w);
- printf("%f\t%f\t%f\n", t,o,w);
- }
- fclose(fichier);
- }
- int main()
- {
- euler();
- return 0;
- }
- /*autre*/
- #include <stdio.h>
- #include <stdlib.h>
- #include <math.h>
- float f(float N)
- {
- float lamda = 8.02;
- return -lamda*N;
- }
- void rungekutta()
- {
- float x0,y0,m1,m2,m3,m4,m,y,x,h,xn;
- x=0.5;
- y=0.5;
- t=0.;
- h=0.01;
- FILE *fichier;
- fichier=fopen("pendule.txt","w+");
- while(t<50)
- {
- m1=f(x0,y0);
- m2=f((x0+h/2.0),(y0+m1*h/2.0));
- m3=f((x0+h/2.0),(y0+m2*h/2.0));
- m4=f((x0+h),(y0+m3*h));
- m=((m1+2*m2+2*m3+m4)/6);
- y=y+m*h;
- x=x+h;
- t+=h;
- fprintf(fichier,"%f\t%f\t%f\n", t,x,y);
- printf("%f\t%f\t%f\n", t,x,y);
- }
- fclose(fichier);
- }
- int main()
- {
- rungekutta();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement