: Visual C++
: 2011-11-27 11:47:21
Description: Given a function f and a set of m >0 distinct points . You are supposed to write a function to approximate f by an orthogonal polynomial using the exact function values at the given m points with a weight assigned to each point . The total error must be no larger than a given tolerance.
Format of function
int OPA( double (*f)(double t), int m, double x, double w, double c, double*eps )
where the function pointer double (*f)(double t) defines the function f int m is the number of points double x contains points double w contains the values of a weight function at the given points x double c contains the coefficients of the approximation polynomial double*eps is passed into the function as the tolerance for the error, and is supposed to be returned as the value of error. The function OPA is supposed to return the degree of the approximation polynomial.
Note: a constant Max_n is defined so that if the total error is still not small enough when n = Ma