.
xi | 0.2 | 0.4 | 0.6 | 0.8 | 1.2 | 1.4 | 1.6 | ||
f (xi) | 0.4 | 0.8 | 1.2 | 1.6 | 2.4 | 2.8 | 3.2 |
, ( ). .
:
:
, i - x 1 xi.
, , .
xi | 0.2 | 0.4 | 0.6 | 0.8 | 1.2 | 1.4 | 1.6 | ||
f (xi) | 0.4 | 0.8 | 1.2 | 1.6 | 2.4 | 2.8 | 3.2 | ||
0.08 | 0.16 | 0.24 | 0.32 | 0.4 | 0.48 | 0.56 | |||
0.08 | 0.24 | 0.48 | 0.8 | 1.2 | 1.68 | 2.24 |
. 22 . .
. 22
, . , , ? .
1. . [a,b].
.
, 6 26 .
36 |
/* */
#include <fstream.h>
#include <math.h>
void main(void)
{
//
double nArray[11][2];
// ,
// nArray ( 26)
double dSumLeft = 0, dSumRight = 0;
//
// .
for (int i = 1; i < 11; i++)
{
dSumLeft = dSumLeft+nArray[i-1][1] * (nArray[i][0] - nArray[i-1][0]);
dSumRight = dSumRight+nArray[i][1] * (nArray[i][0] - nArray[i-1][0]);
}
//
cout << "\n\nSumLeft = " << dSumLeft << "\n";
cout << "SumRight = " << dSumRight << "\n";
}
2. . . . .
.
, 6 . , . , nArray.
|
|
30 |
/* */
#include <fstream.h>
#include <math.h>
void main(void)
{
//
double nArray[11][2];
// ,
// nArray ( 26)
//
cout << "\nIntegral\nx\ty_left\ty_right\n";
//
double dResultLeft, dResultRight;
ofstream File("integral.txt");
dResultLeft = 0; dResultRight = 0;
for (i = 1; i <= 10; i++)
{
dResultLeft=dResultLeft+nArray[i-1][1]*(nArray[i][0] - nArray[i-1][0]);
dResultRight=dResultRight+nArray[i][1]*(nArray[i][0] - nArray[i-1][0]);
//
cout << nArray[i][0]<<"\t"<<dResultLeft<<\t<<dResultRight<<"\n";
//
File << nArray[i][0]<<"\t"<<dResultLeft<<\t<<dResultRight<<"\n";
}
File.close();
}
integral.txt:
0.2 0 0.08
0.4 0.08 0.24
0.6 0.24 0.48
0.8 0.48 0.8
1 0.8 1.2
1.2 1.2 1.68
1.4 1.68 2.24
1.6 2.24 2.88
1.8 2.88 3.6
2 3.6 4.4
. 23
. 23
9
1. , 6, . .
2. , 6, . . .
.
! , , .
1. ?
10
: .
:
.