You are here:
Foswiki
>
Main Web
>
TWikiUsers
>
CezaryMigaszewski
>
ProgramEuler
(revision 1) (raw view)
Edit
Attach
Program euler realizuje pewne zagadnienie mechaniki nieba, wykorzystujac bardzo prosta metode Eulera obliczen numerycznych. Jego opis podam w najblizszym czasie. ------------------ #include<stdio.h> #include<math.h> #define KROK 0.000001 /*metoda Eulera*/ main() { FILE *f; char *plik; float t,x,y,u,v,tkon,r,ax,ay,fx,fy,k,j; int i; plik = "euler.dat"; f=fopen(plik,"w"); /*rysowanie tarczy planety*/ for (k=-0.096; k<0.1; k=k+0.004) { j=sqrt(0.01-k*k); fprintf(f,"%10.4f %7.4f\n",k,j); } for (k=0.096; k>-0.1; k=k-0.004) { j=-sqrt(0.01-k*k); fprintf(f,"%10.4f %7.4f\n",k,j); } printf("podaj polozenie poczatkowe\nx(0)="); scanf("%f",&x); printf("\ny(0)="); scanf("%f",&y); printf("\npodaj skladowe predkosci poczatkowej\nu(0)="); scanf("%f",&u); printf("\nv(0)="); scanf("%f",&v); printf("\npodaj czas koncowy "); scanf("%f",&tkon); printf("\npodaj skladowe przyspieszenia od sily zaburzajacej (w jedn. GM/a^2) "); printf("\nfx="); scanf("%f",&fx); printf("\nfy="); scanf("%f",&fy); i=0; fprintf(f,"%10.4f %7.4f\n",x,y); r=sqrt(x*x+y*y); t=0.0; while(t<=tkon && r>=0.1) { ax=-x/(r*r*r)+fx; ay=-y/(r*r*r)+fy; x=x+u*KROK+ax*KROK*KROK/2; y=y+v*KROK+ay*KROK*KROK/2; u=u+ax*KROK; v=v+ay*KROK; ++i; t=t+KROK; r=sqrt(x*x+y*y); if (i % 1000 == 0) fprintf(f,"%10.4f %7.4f\n",x,y); } fclose(f); return 0; } ----------------------- -- Main.CezaryMigaszewski - 17 Apr 2004
Edit
|
Attach
|
P
rint version
|
H
istory
:
r10
|
r4
<
r3
<
r2
<
r1
|
B
acklinks
|
V
iew topic
|
Edit WikiText
|
More topic actions...
Topic revision: r1 - 17 Apr 2004,
CezaryMigaszewski
Main
Log In
or
Register
Toolbox
Create New Topic
Index
Search
Changes
Notifications
RSS Feed
Statistics
Preferences
Users
Groups
Webs
Cosmo
Main
Sandbox
System
English
Français
Polski
Copyright © CC-BY-SA by the contributing authors. All material on this collaboration platform is copyrighted under CC-BY-SA by the contributing authors unless otherwise noted.
Ideas, requests, problems regarding Foswiki?
Send feedback