**

Write and debug a program for approximating the function f(x) on the interval [a, b] by a given method, m is the number of points at which the function is known (the size of the table). The function type is set to get the values of the table (xi, yi), i=1,2,…, m and check the quality of the approximation.

The solution of the problem is to formalize a separate function, the algorithm of which is described in the form of a flowchart. WHY, when I run the program, it gives me an infinite number of values, how to fix it ? **

```
#include <iostream>
#include <math.h>
using namespace std;
double f(double x) {
return x * x* x - 5 * x * x;
}
double N(double* x, double *y, double xt, int m) {
int i, k;
double D[15], N, p;
for (i = 0; i < m; i++) {
D[i] = y[i];
}
p = 1;
N = y[0];
for (k = 0; k < m - 1; k++) {
for (i = 0; i < m - k; i++) {
D[i] = (D[i] - D[i + 1]) / (x[i] - x[i + k+1]);
}
p = p * (xt - x[k]);
N += p * D[0];
}
return N;
}
double pogr(double x, double N) {
return (f(x) - N);
}
int main() {
double a, b, h, h1, x,*m_x, m_y_t, *m_y, max, p=0;
int i, n, m;
cout << " individ: a=-2, b=5, m=5." << endl;
cout << "a: "; cin >> a;
cout << "b: "; cin >> b;
cout << "m: "; cin >> m;
cout << "n: "; cin >> n;
h = (b - a) / (m - 1);
h1 = (b - a) / (n - 1);
m_y = new double[m + 1];
m_x = new double[m + 1];
for (x = a, i = 0; i < m; i++) {
m_x[i] = x;
m_y[i] = f(x);
x += h;
}
max = p;
for (x = a; i < n; x += h1) {
m_y_t = N(m_x, m_y, x, m);
cout << "xt= " << x << " f*(x)= " << m_y_t;
p = abs(f(x) - m_y_t);
cout « "tPogreshnost: " « p « endl;
if (p > max) max = p;
}
cout << " Max pogr = " << max << endl;
```

}

Source: Windows Questions C++