> {i; = 0; (i = 0; i <= n/2; i + +)
{[i] = fabs (y [2 * i]-y_tochnoe [i]); (eps [i]> delta) = eps [i];
} delta;
} Pechat (double y_vivodimoe [], double a, double eps [], int n, int N, double delta)
{i, j = 1, k; h, x = a; = n/N; = (ba)/n; ("n =% d nh =% 1.2f nMax_Delta =% 1.2e n n ", n, h, delta); (" tx ty t tE n "); (i = 0; i <= n; i + = k)
{
printf ("% d) t% 1.2f t% f t% 1.2e n", j + +, x, y_vivodimoe [i], eps [i]); = x + k * h;
}
} ()
{i, N = 25, n; y [N_max], y_tochnoe [N_max], eps [N_max], y_vivodimoe [N_max]; h, delta; = N;
{(n> = N_max)
{("Vihod za predeli masiva"); 0;
= Y [i];} = 2 * n;
} (delta> epsel); (y_vivodimoe, a, eps, n/4, N, delta); ("n =% d nh =% 1.2f nMax_Delta =% 1.2e n n" , n, h, delta);
return 0;}
Додаток 2
Лістинг програми В«Метод ГальоркінаВ»
# include "stdafx.h"
# include "math.h"
# include "process.h" double epsel = 0.00001; double h = 0.02; double a = 1.3; double b = 1.8; double A = 2.2; double B = -1.4; int M = 10, N_max = 26 , E = 8; F (double x)
{return 1.8/(x * x) -4;} Q (double x)
{return 2.3/x;} P (double x)
{return 0.9 * x;} Resheniya (double D [], double C [], int n)
{sum1 = 0; sum2 = 0; (j = 1; j sum1 + = U * L; sum2 + = U * L;
} [i-1] [k-1] = h/3 * (4 * sum1 +2 * sum2);
}
} (i = 1; i <= n; i + +)
{sum1 = 0; sum2 = 0; (j = 1; j
{= a + j * h; = pow (xa, i) * (xb); = P (x) * (BA)/(ba) + Q (x) * ((A * bB * a) /(ba) + (BA)/(ba) * x); (j% 2) sum1 + = U * (F (x)-L); sum2 + = U * (F (x)-L);
} [i-1] = h/3 * (4 * sum1 +2 * sum2);
}
// Metod Gausa (t = 0; t
{(i = t +1; i
}
}
} (i = n-1; i> = 0; i -) {[i] = D [i]; (j = i +1; j
{C [i] = C [i] - matrix [i] [j] * C [j];} [i] = C [i]/matrix [i] [i];}
} Nahozdenie_y (double y [], double C [], int n)
{y [j] + = C [i-1] * pow (x-a, i) * (x-b);}
}
} Proverka (double y [], double y_tekushee [], int n, double eps [])
{i; delta; (i = 0; i
{eps [i] = fabs (y [i]-y_tekushee [i]); (eps [i]> delta) delta = eps [i];} delta;
} Prisvoenie_y_tekushee (double y [], double y_tekushee [], double y_vivodimoe [], int n)
{i; (i = 0; i
{y_vivodimoe [i] = y_tekushee [i];
y_tekushee [i] = y [i];}
} Pechat_rez (double y_vivodimoe [], double eps [], int n, double delta)
{int i; x; ("Bazis =% d n", n); ("Razbienij v metode Simpsona =% d n", E); ("Max_Delta =% 1.2e n n ", delta); (" t X t Y (X) t t ...