Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _USE_MATH_DEFINES
- #include <math.h>
- #include <locale.h>
- #include <stdio.h>
- double funx(double phi, double r, double m, double h)
- {
- return r*(m+1)*(cos(m*phi)-h*cos((m+1)*phi));
- }
- double funy(double phi, double r, double m, double h)
- {
- return r*(m+1)*(sin(m*phi)-h*sin((m+1)*phi));
- }
- double Length(double Left,double Right,long N,double (*funx)(double, double, double, double), double (*funy)(double, double, double, double))
- {
- double dphi,res=0.0,r=M_PI,m=1./3,h=0.15,phi;
- dphi = (Right - Left) / N;
- for (phi = Left; phi <= (Right-dphi); phi+=dphi)
- res += sqrt(pow((funx(phi+dphi,r,m,h)-funx(phi,r,m,h)),2)+pow((funy(phi+dphi,r,m,h)-funy(phi,r,m,h)),2));
- res += sqrt(pow((funx(Right,r,m,h)-funx(phi,r,m,h)),2)+pow((funy(Right,r,m,h)-funy(phi,r,m,h)),2));
- return res;
- }
- int main()
- {
- long n;
- double L = 0.0, R = 6.0*M_PI;
- double V, V0=28.74656728; //28.74657809
- setlocale( LC_ALL, "" );
- printf("Число шагов;Относительная ошибка\n");
- for (n = 1; n < 1000; n+=n/50+1) {
- V = Length(L, R, n, funx, funy);
- printf( "%ld;=%.15G\n", n, V-V0);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement