for int ai xi bi xi ci xi di xi di di di di --------------copy-- -----

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
for (int i = 0; i < n; i++)
{
ai[i] = 1;// 1 - p(xi[i + 1]) * h / 2;
bi[i] = 4;// q(xi[i]) * h * h - 2;
ci[i] = 1;// 1 + p(xi[i]) * h / 2;
di[i] = f(xi[i]) * h * h;
}
di[1] = di[4] = 5; di[2] = di[3] = 6; n = 5;
//--------------copy-------------------
double[] alpha = new double[n];
double[] beta = new double[n];
alpha[1] = -ci[1] / bi[1];
beta[1] = di[1] / bi[2];
for (int i = 2; i < n; i++)
{
alpha[i] = -(ci[i] / (ai[i - 1] * alpha[i - 1] + bi[i]));
beta[i] = (di[i] - ai[i - 1] * beta[i - 1]) / (ai[i - 1] * alpha[i - 1] + bi[i]);
}
//s[n].c = ((d[n - 1]) - a1 * beta[n - 2]) / (a1 * alpha[n - 2] + b1);
yi[n-1] = beta[n-1];// (di[n] - ai[n - 1] * beta[n - 1]) / (ai[n - 1] * alpha[n - 1] + bi[n]);
for (int i = n - 2; i > 0; i--)
{
yi[i] = alpha[i] * yi[i + 1] + beta[i];
}