Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Construct the Newton form of the interpolating polynomial of degree 8 for the fu

ID: 3728700 • Letter: C

Question



Construct the Newton form of the interpolating polynomial of degree 8 for the function f(x) using the data points at x =-8,6,4,2,0, 2, 4, 6, 8. 4. EvaluateE(x), ps(x), and Itx)-Ps(x)forthe17 points at x =-8,-7,-6,-5,4,3,2-1, o, 1, 2, 3, 4, 5, 6,7,8. Part II. Use Visual Studio 2015 to do the following task 1. Create a C++ console application project in Visual Studio 2015 and name your project YourLastName3 2. Write a program that implements the Newton Interpolation discussed in class. 3. Write a separate function for each of the following. You may define and call additional functions. Computation of divided differences Evaluation of the interpolating polynomial Must use a nested form as discussed in class . 4. Your program must store divided differences in a single dimensional array 5. All floating point arithmetic will be double precision. 6. Program input: Sequence of x values of data points Sequence of x values to evaluate P(x) 7. Program output Divided differences at each iteration Table containing fox), P)fx) -P(x) for the 17 data points .

Explanation / Answer

#include <iostream>
using namespace std;

class divide
{
public:
    void askP();
    void askX();
    void askF();
    void askXX();
    void diffTable();
    void calcP();
private:
    double XX, x[10] , f[10][10] , p[10],diff[5][5],P1;
    int n;

};

void divide::askP()
{
    cout << "Enter n: ";
    cin >> n;
}

void divide::askX()
{
    cout << endl;
    for(int i = 0; i<n; i++ )
    {
        cout << "ENter X[" << i << "] : ";
        cin >> x[i];
    }
    cout << endl;
}

void divide::askF()
{

    for(int j = 0; j<n; j++ )
    {
        cout << "ENter F[" << j << "] : ";
        cin >> f[0][j];
    }
    cout << endl;
}
void divide::askXX()
{

    cout << "Enter X: ";
    cin >> XX;
}

void divide::diffTable()
{
    for(int i = 1; i < n; i++)
    {
        for(int j = 0; j< n-i;j++)
        {
            f[i][j] = (f[i-1][j+1]-f[i-1][j])/(x[i+j]-x[j]);
        }
    }
    cout << endl;
    cout << "Sn Xi f(Xi) ";
    for(int i = 0; i <n-1;i++)
    {
        cout << i+1 << " diff ";
    }
    cout << endl;
    for(int i = 0; i < n; i++)
    {
         cout <<i+1 <<" " << x[i]<< " ";
        for(int j = 0; j< n-i;j++)
        {
            cout << f[j][i] << " ";
        }
        cout << endl;
    }
}

void divide::calcP()
{
    P1 = 0;
    for(int i = 0;i<n;i++)
    {
        double k = 1;
        for(int j = 0; j<i;j++)
        {
            k*= (XX - x[j]);
        }
        P1 += k * f[i][0];

    }
    cout <<endl << "The value of P" << n-1 << "(" << XX << "): " <<P1 << endl << endl;
}
int main()
{

    divide d1;
    d1.askP();
    d1.askX();
    d1.askF();
    d1.askXX();
    d1.diffTable();
    d1.calcP();

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote