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

In Newton\'s form of the interpolation polynomial e need to compute the coeficie

ID: 3184155 • Letter: I

Question

In Newton's form of the interpolation polynomial e need to compute the coeficients, co = f[20], ci = fFo, x!], . . . , cn-fFo, x1, . . . , Fm]. In the table of divided differences we proceed column by column and the needed coefficients are in the uppermost di agonal. A simple 1D array, c of size n 1, can be used to store and compute these values. We just have to compute them from bottom to top to avoid losing values we have already computed. The following pseudocode does precisely this: for J = 0, 1 ci = fi: ,n

Explanation / Answer

answer:

(a):

C language Program code to compute the coefficients and to evaluate the corresponding interpolation

===>

#include<stdio.h>

#include<math.h>

main()

{

float y, x[20], f[20], sum, pf;

int i, j, n;

printf(“Pease Enter the value for n”);

scanf(“%d”, &n);

printf(“Please Enter the value to be found”);

scanf(“%f”, &y);

printf(“Please Enter the values of xi’s & fi’s”);

for(i = 0; i < n; i++)

{

pf = 1;

for(j = 0; j < n; j++)

{

   if(j != i)

   Pf *= (y - x[j])/(x[i] – x[j]);

}

sum += f[i] * pf;

}

printf(“ Value of x is = %f ”, y);

printf(“ Value of sum is =%f ”, sum);

}

output:

Please Enter the value of n 4

Please Enter the value to be found 2.5

Please Enter the values for xi’s & fi’s

1 1

2 8

3 27

4 64

Value of X is = 2.500000

Value of sum is = 15.625000

(b)

answer:

Use your code(s) in (a) to evaluate P10(x) at the points x j = 1 + j(2/100), j = 0, 1, . . . , 100 and plot the error f(x) P10(x).

=============>

/* initializing A[0] */

for(i=0; i<=10; i++){

    A[i]=exp(-x[i]*x[i]/5);

}

//initializing A[0]

P=A[0];

prod=1.0;

/* computing divided differences

for(j=0;j<10-i;j++)

{

    A[j] = (A[j+1] - A[j])/(x[j+i+1]-x[j]);

}

==============================================================================================================================================================================

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