#include <math.h> #include <stdio.h> #define PI 3.1415926535897932384626433832795 #define N 30 int main() { // Delvare two arrays to hold the coordinates of initial data points double x[N], y[N],(x2); int i; // Generate the points double xx = PI/2; double step = 2 * PI / (N - 1); for ( i = 0; i < N; ++i, xx += step) { double x2=xx+sin(xx); // vary x spacing x[i] = x2; y[i] = sin(x2)/x2; } // Initialize the regression approximation routine with known data points A.getValue(N, x, y, 3); // Interrogate the regression function to find approximated values int N_out =50; xx = PI/2 ; step = 2 * PI / (N_out - 1); printf("\nx, exact, discrete_3, discrete_5, discrete_10"); for ( i = 0; i < N_out; ++i, xx += step) { double x2=xx+sin(xx); printf("\n%.4lf, %.6lf, %.6lf, %.6lf, %.6lf", x2, sin(x2)/x2, A.getValue(x2)); } return 0;

This post has been edited by **Skydiver**: 07 October 2013 - 10:04 PM

Reason for edit:: Put code in code tags. Learn to follow instructions.