This action might not be possible to undo. Are you sure you want to continue?
DIFFERENCES
VIJAYA C RAMASAMI, KUID 698659
1. Problem Statement
Implement the polynomial interpolation using Netwon’s divided diﬀerences. Consider the
famous example:
(1) f(x) =
1
1 + x
2
−5 ≤ x ≤ 5
due to Carl Runge. Use two sets of nodes:
Set I : x
i
= −5 + i ∗ h, i = 0, 1, · · · , n (2)
Set II : x
i
= −5 ∗ cos
iπ
n
, i = 0, 1, · · · , n (3)
h =
10
n
(4)
The ﬁrst set of notes are equidistant while the second set, often referred to as the GuassLobatto
Chebyshev points, are denser at both ends than the middle.
Denote by p(x) the interpolation polynomial which satisﬁes the conditions
(5) p
n
(x
i
) = f(x
i
), i = 0, 1, · · · , n
Let the maximum error be
(6) E(n) = max
i=0,1,··· ,n−1
p
n
−f
x
i
+ x
i+1
2
Use your program to compute the error for various values of n, say n = 5, 10, 20, 40, and80 for
the two sets of nodes. What can you conclude based on the results you have obtained ?
2. Mathematical Formulation
2.1. Computation of Divided Diﬀerences. Divided Diﬀerences is an eﬃcient numerical
method to compute the the Newton form of the interpolation polynomial. The Newton’s in
terpolating polynomial has the following form:
(7) p(x) =
n
¸
i=0
d
i
i=1
¸
j=0
(x −x
j
)
We have to ﬁnd the coeﬃcients d
0
, d
1
, · · · , d
n
based on the n interpolation conditions, p(x
i
) =
f(x
i
), i = 0, 1, · · · , n. The divided diﬀerence technique is usually implemented by constructing a
divided diﬀerence table to compute the coeﬃcients d
0
, · · · , d
n
. Even though the divided diﬀerence
table is very handy for solving by hand, computer implementation of the table requires more
storage space than necessary. The pseudocode for another algorithm that is more eﬀﬁcient in
terms of lesser memory requirements is given below:
Date: 11/7/2002.
1
2 VIJAYA C RAMASAMI, KUID 698659
for i = 0 to n do
d[i] := f(x[i])
end do
for i = 1 to n do
for j = n to j step 1 do
d[i] := (d[i]  d[i1])/x[i]  x[ij])
end do
end do
In the above pseudocode, we ﬁrst initialize d
0
, · · · , d
n
to f(x
i
), · · · f(x
n
) respectively. We
already have d
0
= f[x
0
]. The rest of the divided diﬀerence coeﬃcients are computed one column
at a time and store the computed divided diﬀerences in d
1
, d
2
, · · · , d
n
, making sure that we do
not alter the divided diﬀerence values that are already computed.
We implemented the above algorithm in the C programming language. The C subroutine for
the computating the divided diﬀerences is given below:
void ComputeDividedDifferences(double (*f)(double), double *d, double *x,
int n)
{
int i, j;
/* Initialize d */
for(i = 0; i <= n; i++) d[i] = f(x[i]);
/* Compute Divided Differences */
for(i = 1; i <= n; i++)
for(j = n; j >= i; j)
d[j] = (d[j]  d[j1])/(x[j]  x[ji]);
}
2.2. Evaluation of the Polynomial. Once the divided diﬀerences are computed, we can eval
uate the above polynomial at an arbitraty point t using equation (7). A numerically stable and
computationally eﬃcient method of implementing the Newton form is the Horner’s Algorithm
or Nested Multiplication. The following pseudocode computes u = p
n
(t) for a given value of t:
u := d[n]
for i = n1 to 0 step 1 do
u := (t  x[i])u + d[i]
end do
We implemented the Horner’s algorithm in the C programming language. The C subroutine
for evaluating the polynomial is given below:
void Evaluate(double *d, double *x, int n, double *t, double *p, int nt)
{
int i, j;
for(i = 0; i <= nt; i++)
{
p[i] = d[n];
for(j = n1; j >= 0; j)
p[i] = d[j] + (t[i]  x[j])*p[i];
}
POLYNOMIAL INTERPOLATION USING NEWTON’S DIVIDED DIFFERENCES 3
}
2.3. Spacing between Nodes. The spacing between nodes is an important parameter in poly
nomial interpolation. It can be easily shown that the interpolation error increases without bounds
for increase values of n in the case of equidistant nodes. For example, the interpolation error in
the Runge’s polynomial using equidistant nodes in the range [−5, 5] can be approximated as:
(8) max
x∈[−5,5]
f(x) −p
n
(x) ∼
20(n + 1)
ne
n+1
2π
n + 1
−5 0 5
0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1
x
i
−>
f
(
x
i
)
−
>
−5 0 5
0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1
x
i
−>
f
(
x
i
)
−
>
Equidistant
Nodes
Chebyshev
Nodes
Figure 1. Equidistant and Chebyshev Nodes
It can be seen from the above equation that the interpolation error increases as (20/e)
n+1
as n → ∞. A method to avoid this increase in interpolation error is to use nonequdistant
nodes. We can show for the case of the Runge function that if we use closely spaced points at
the two ends of the speciﬁed interval, we can achieve a very good ﬁt for higher values of n. In
this project, we prove using numerical experiments that the GaussLobattoChebyshev points
are a better choice of nodes than equidistant points for interpolating the Runge’s function using
polynomials.
2.4. Interpolation Error. The Interpolation error is usually measured using the L
∞
norm (or
maximum in a given interval). One method to obtain an estimate of the interpolation error is to
compute the error between the function and its polynomial approximation at midpoints between
adjacent nodes. Thus the interpolation error can be computed using:
(9) E(n) = max
i=0,1,··· ,n−1
p
n
−f
x
i
+ x
i+1
2
The Csubroutine that performs this error estimation is given below:
double ComputeMaxError(double (*f)(double), double *d, double *x, int n)
{
double e = 0, temp, t, p;
4 VIJAYA C RAMASAMI, KUID 698659
int i;
for(i = 0; i < n; i++)
{
t = (x[i] + x[i+1])/2;
Evaluate(d, x, n, &t, &p, 0);
temp = fabs(f(t)  p);
if (temp > e) e = temp;
}
return e;
}
3. Numerical Experiments
3.1. Comparision. We performed experiments with the divided diﬀerence technique and the
two types of nodes speciﬁed in the previous section for small/moderate values of n. The plots
in ﬁgure (2) clearly illustrate that the Chebyshev nodes achieve a better ﬁt than the equidistant
nodes. In fact, interpolation using equidistant nodes shows a signiﬁcant oscillatory behaviour
for large values of n, especially on the corner nodes. The interpolation error caused due to this
oscillatory behaviour increases without bound as n increase, as expected from theory.
−5 0 5
−1.5
−1
−0.5
0
0.5
1
Equidistant Nodes
−5 0 5
0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
Chebyshev Nodes
f(x
i
)
p
n
(x)
f(x
i
)
p
n
(x)
Figure 2. Interpolation using Equidistant and Chebyshev Nodes  Graphical Comparision
3.2. Error Performance. The interpolation error for the netwon form of the interpolation
polynomial for the given choice of nodes for various values of n were computed and plotted in
ﬁgure (3). We used log
10
(E) to cover the wide dynamic ranges of the error. It can be seen that
the Chebyshev Nodes provide increasingly good approximations for increasing values of n, while
the interpolation error of the Netwon polynomial increases without bound for increasing values
of n.
We assume linear convergence for interpolation using Chebyshev Nodes and plotted the con
vergence graph in ﬁgure (3). It can be seen that:
(10)
E
n+1

E
n

≤ 1.4
POLYNOMIAL INTERPOLATION USING NEWTON’S DIVIDED DIFFERENCES 5
0 10 20 30 40
−2
−1
0
1
2
3
4
5
n −−>
l
o
g
1
0
(
E
)
(
E
q
u
i
d
i
s
t
a
n
t
N
o
d
e
s
)
0 10 20 30 40
−3.5
−3
−2.5
−2
−1.5
−1
−0.5
0
l
o
g
1
0
(
E
)
(
C
h
e
b
y
s
h
e
v
N
o
d
e
s
)
Error Performance
0 10 20 30 40
0
5
10
15
n −−>
Convergence Rate using Chebyshev Nodes
Equidistant
Nodes
E
n+1
/E
n
≈ 1.4
Chebyshev
Nodes
Figure 3. Error Performance of Divided Diﬀerences Interpolation and the Con
vergence Graph for Interpolation using Chebyshev Nodes.
−5 0 5
0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1
Double Precision Computations
−5 0 5
−1
−0.5
0
0.5
1
1.5
2
2.5
3
Single Precision Computations
Interpolation
Polynomial
Nodes
Error due to limited
precision computations
Figure 4. Eﬀect of Finite Machine Precision on Interpolation (with Chebyshev Nodes)
3.3. Limitations due to Machine Precision. Even though the interpolation error using
Chebyshev nodes theoritically decreases with increasing values of n, limitations due to ﬁnite
machine precision will result in large errors for large values of n. This fact can be easily proven
by executing the algorithm in diﬀerent levels of machine precision and analyzing the error per
formance. In the C programming language, we used ﬂoat for single precision computations and
double for double precision computations and the result for n = 30 is shown in ﬁgure (4). It can
be clearly seen that large errors occur for values of n close to 5. We performed futher analysis
and found that the errors (oscillations) are mostly caused in the nested multiplication routine.
6 VIJAYA C RAMASAMI, KUID 698659
The error (oscillations) are negligible at the output of the divided diﬀerences computation rou
tine even for large values of n. For double precision computations, this error behavior starts
approximately around n = 45.
n Error (Equidistant Nodes) Error (Chebyshev Nodes)
5 0.1212 0.0592
10 1.5317 0.1310
20 3.4025 0.0140
40 2287.7 3.3987 ×10
−4
80 4.6734 ×10
9
2.1471 ×10
5
Table 1. Table of Errors for Interpolation using Equidistant and Chebyshev
nodes for various values of n
4. Conclusions
The Divided Diﬀerences Algorithm was implemented using the C programming language to
compute the Newton form of the interpolating polynomial for the given function using equidis
tant and chebyshev nodes. The following results were observed as a result of the Numerical
experiments:
• Interpolation using Chebyshev nodes always achieves a better ﬁt than interpolation using
equidistant nodes.
• The interpolation error using equidistant nodes increases without bounds a the number
of nodes are increased, as expected from theory.
• The interpolation error using Chebyshev nodes converges linearly with the convergence
constant ≈ 1.4.
• Under ﬁnite machine precision, even the use of Chebyshev nodes will cause large errors.
5. Source Code Listing
5.1. library.cc.
#include "library.h"
#include "math.h"
#include "stdio.h"
#include "stdlib.h"
/* Divided Differences Computation */
void ComputeDividedDifferences(double (*f)(double), double *d, double *x,
int n)
{
int i, j;
/* Initialize d */
for(i = 0; i <= n; i++) d[i] = f(x[i]);
/* Compute Divided Differences */
for(i = 1; i <= n; i++)
for(j = n; j >= i; j)
d[j] = (d[j]  d[j1])/(x[j]  x[ji]);
}
/* Polynomial Evaluation  Horner’s Algorithm */
void Evaluate(double *d, double *x, int n, double *t, double *p, int nt)
{
POLYNOMIAL INTERPOLATION USING NEWTON’S DIVIDED DIFFERENCES 7
int i, j;
for(i = 0; i <= nt; i++)
{
p[i] = d[n];
for(j = n1; j >= 0; j)
p[i] = d[j] + (t[i]  x[j])*p[i];
}
}
/* The Runge Function */
double f(double x)
{
return 1/(1+pow(x,2));
}
/* Error Computation */
double ComputeMaxError(double (*f)(double), double *d, double *x, int n)
{
double e = 0, temp, t, p;
int i;
for(i = 0; i < n; i++)
{
t = (x[i] + x[i+1])/2;
Evaluate(d, x, n, &t, &p, 0);
temp = fabs(f(t)  p);
if (temp > e) e = temp;
}
return e;
}
5.2. main.cc.
#include <stdio.h>
#include <math.h>
#include "library.h"
#include <stdlib.h>
#define PI 3.141592
void main(void)
{
int n = 30, i, nt = 1000;
double h, *d, *x, *t, *p, ht,e;
FILE *fp1, *fp2;
/* Allocate Memory for Operations */
d = (double *)calloc(n+1, sizeof(double));
x = (double *)calloc(n+1, sizeof(double));
p = (double *)calloc(nt+1, sizeof(double));
t = (double *)calloc(nt+1, sizeof(double));
/* Error Checking */
if ((d == NULL)  (x == NULL)  (p == NULL)  (t == NULL))
{
8 VIJAYA C RAMASAMI, KUID 698659
printf("Memory Allocation Failure... Aborting...");
exit(1);
}
/* File to Save the results and for Plotting */
fp1 = fopen("interp_polydata.dat", "wt");
fp2 = fopen("interp_nodes.dat", "wt");
if ((fp1 == NULL)(fp2 == NULL))
{
printf("Cannot open output file... Aborting...");
exit(1);
}
/* Generate the Nodes */
h = 10.0/n;
for(i = 0; i <= n ; i++)
{
/* x[i] = 5 + i*h; */
x[i] = 5*cos(i*PI/n);
d[i] = 1/(1+pow(x[i],2));
}
/* Compute Divided Differences */
ComputeDividedDifferences(f, d, x, n);
/* Evaluate the Polynomial */
ht = 10.0/nt;
for(i = 0; i <= nt ; i++) t[i] = 5 + i*ht;
Evaluate(d, x, n, t, p, nt);
/* Save the Values */
for(i = 0; i <= nt ; i++) fprintf(fp1, "%.4f\t%.4f\n", t[i], p[i]);
for(i = 0; i <= n ; i++) fprintf(fp2, "%.4f\t%.4f\n", x[i], f(x[i]));
/* Compute Error */
e = ComputeMaxError(f, d, x, n);
printf("e = %lf\n", e);
/* Clean Up */
fclose(fp2);
fclose(fp1);
free(d);
free(t);
free(p);
free(x);
}
} 2. for(i = 0. for(j = n1. we can evaluate the above polynomial at an arbitraty point t using equation (7).2. The rest of the divided diﬀerence coeﬃcients are computed one column at a time and store the computed divided diﬀerences in d1 .2 VIJAYA C RAMASAMI. dn .x[ij]) end do end do In the above pseudocode. double *t. j >= i.x[ji]). int nt) { int i. The following pseudocode computes u = pn (t) for a given value of t: u := d[n] for i = n1 to 0 step 1 do u := (t . we ﬁrst initialize d0 . · · · . Evaluation of the Polynomial. i++) for(j = n. /* Initialize d */ for(i = 0. double *p. dn to f (xi ). Once the divided diﬀerences are computed. · · · f (xn ) respectively. /* Compute Divided Differences */ for(i = 1. The C subroutine for the computating the divided diﬀerences is given below: void ComputeDividedDifferences(double (*f)(double). } . · · · .x[j])*p[i]. We already have d0 = f [x0 ]. j. i <= n. double *x. j >= 0. i <= nt. j. KUID 698659 for i = 0 to n do d[i] := f(x[i]) end do for i = 1 to n do for j = n to j step 1 do d[i] := (d[i] . i++) d[i] = f(x[i]). int n) { int i. i++) { p[i] = d[n]. making sure that we do not alter the divided diﬀerence values that are already computed. d2 . j) p[i] = d[j] + (t[i] . int n.d[j1])/(x[j] . We implemented the above algorithm in the C programming language. A numerically stable and computationally eﬃcient method of implementing the Newton form is the Horner’s Algorithm or Nested Multiplication.x[i])u + d[i] end do We implemented the Horner’s algorithm in the C programming language. j) d[j] = (d[j] . i <= n. The C subroutine for evaluating the polynomial is given below: void Evaluate(double *d. double *d.d[i1])/x[i] . double *x.
we prove using numerical experiments that the GaussLobattoChebyshev points are a better choice of nodes than equidistant points for interpolating the Runge’s function using polynomials.1 0.5 0.9 0.n−1 max pn − f  xi + xi+1 2 The Csubroutine that performs this error estimation is given below: double ComputeMaxError(double (*f)(double).4 0.7 0. we can achieve a very good ﬁt for higher values of n. .5 i 0. Spacing between Nodes. the interpolation error in the Runge’s polynomial using equidistant nodes in the range [−5.··· . Thus the interpolation error can be computed using: (9) E(n) = i=0.POLYNOMIAL INTERPOLATION USING NEWTON’S DIVIDED DIFFERENCES 3 } 2. The spacing between nodes is an important parameter in polynomial interpolation. In this project. A method to avoid this increase in interpolation error is to use nonequdistant nodes. Interpolation Error. 5] can be approximated as: (8) max f (x) − pn (x) ∼ 20(n + 1) ne n+1 x∈[−5.2 0.8 0.9 1 Chebyshev Nodes 0. The Interpolation error is usually measured using the L∞ norm (or maximum in a given interval). temp. double *d. It can be easily shown that the interpolation error increases without bounds for increase values of n in the case of equidistant nodes.3 0. double *x. int n) { double e = 0.6 0. For example. One method to obtain an estimate of the interpolation error is to compute the error between the function and its polynomial approximation at midpoints between adjacent nodes.7 0.5] 2π n+1 1 Equidistant Nodes 0.1 0 −5 0 −5 0 xi −> 5 Figure 1. Equidistant and Chebyshev Nodes It can be seen from the above equation that the interpolation error increases as (20/e)n+1 as n → ∞.3 0. 2. t.2 0.4 0. p.6 f(x ) −> f(xi) −> 0 xi −> 5 0.4.3.8 0.1. We can show for the case of the Runge function that if we use closely spaced points at the two ends of the speciﬁed interval.
5 0. i < n. The interpolation error for the netwon form of the interpolation polynomial for the given choice of nodes for various values of n were computed and plotted in ﬁgure (3). Numerical Experiments 3. It can be seen that the Chebyshev Nodes provide increasingly good approximations for increasing values of n. i++) { t = (x[i] + x[i+1])/2. } 3. as expected from theory. Interpolation using Equidistant and Chebyshev Nodes .7 0. We performed experiments with the divided diﬀerence technique and the two types of nodes speciﬁed in the previous section for small/moderate values of n.5 −5 0 5 0 −5 0 5 Figure 2. if (temp > e) e = temp. Evaluate(d. &t. We assume linear convergence for interpolation using Chebyshev Nodes and plotted the convergence graph in ﬁgure (3). n.2.5 0. temp = fabs(f(t) . for(i = 0. &p.5 0. KUID 698659 int i. It can be seen that: (10) En+1  ≤ 1. while the interpolation error of the Netwon polynomial increases without bound for increasing values of n.4 En  . The plots in ﬁgure (2) clearly illustrate that the Chebyshev nodes achieve a better ﬁt than the equidistant nodes.Graphical Comparision 3. } return e.4 −0.4 VIJAYA C RAMASAMI.p).3 −1 0.8 0. x. Error Performance. Equidistant Nodes 1 f(xi) pn(x) 0. interpolation using equidistant nodes shows a signiﬁcant oscillatory behaviour for large values of n. 0). Comparision. especially on the corner nodes.1 −1. The interpolation error caused due to this oscillatory behaviour increases without bound as n increase.9 f(xi) pn(x) Chebyshev Nodes 0. In fact. We used log10 (E) to cover the wide dynamic ranges of the error.6 0 0.1.2 0.
Double Precision Computations 1 3 Single Precision Computations 0. Error Performance of Divided Diﬀerences Interpolation and the Convergence Graph for Interpolation using Chebyshev Nodes. This fact can be easily proven by executing the algorithm in diﬀerent levels of machine precision and analyzing the error performance. Eﬀect of Finite Machine Precision on Interpolation (with Chebyshev Nodes) 3.9 2. Limitations due to Machine Precision.5 Error due to limited precision computations 0. It can be clearly seen that large errors occur for values of n close to 5.1 0 −5 0 5 −1 −5 0 5 Figure 4. limitations due to ﬁnite machine precision will result in large errors for large values of n. We performed futher analysis and found that the errors (oscillations) are mostly caused in the nested multiplication routine. Even though the interpolation error using Chebyshev nodes theoritically decreases with increasing values of n.3.5 40 0 0 10 20 n −−> 30 40 Figure 3.POLYNOMIAL INTERPOLATION USING NEWTON’S DIVIDED DIFFERENCES Error Performance 5 0 15 Convergence Rate using Chebyshev Nodes 5 4 Equidistant Nodes −0.5 0.6 1.2 −0.4 0.5 1 Chebyshev Nodes −2 En+1/En 5 0 −2.5 ≈ 1. we used ﬂoat for single precision computations and double for double precision computations and the result for n = 30 is shown in ﬁgure (4).3 0 0.7 Interpolation Polynomial Nodes 0. In the C programming language.5 0.4 −1 −3 −2 0 10 20 n −−> 30 −3.5 1 0.8 2 0.5 0.5 3 −1 log10(E) (Chebyshev Nodes) log10(E) (Equidistant Nodes) 10 2 −1. .
/* Compute Divided Differences */ for(i = 1. double *x. int nt) { .1. as expected from theory. i++) for(j = n. The following results were observed as a result of the Numerical experiments: • Interpolation using Chebyshev nodes always achieves a better ﬁt than interpolation using equidistant nodes.0140 40 2287.x[ji]).7 3.1212 0. } /* Polynomial Evaluation . double *x. #include "library.3987 × 10−4 80 4. Source Code Listing 5. i <= n. KUID 698659 The error (oscillations) are negligible at the output of the divided diﬀerences computation routine even for large values of n. this error behavior starts approximately around n = 45. • Under ﬁnite machine precision. j) d[j] = (d[j] . n Error (Equidistant Nodes) Error (Chebyshev Nodes) 5 0.h" #include "stdio. • The interpolation error using Chebyshev nodes converges linearly with the convergence constant ≈ 1.6 VIJAYA C RAMASAMI. int n) { int i. /* Initialize d */ for(i = 0.h" #include "stdlib.4025 0. For double precision computations. even the use of Chebyshev nodes will cause large errors. j >= i.1471 × 105 Table 1.d[j1])/(x[j] . int n.1310 20 3. • The interpolation error using equidistant nodes increases without bounds a the number of nodes are increased. double *t.6734 × 109 2. Conclusions The Divided Diﬀerences Algorithm was implemented using the C programming language to compute the Newton form of the interpolating polynomial for the given function using equidistant and chebyshev nodes. double *d.0592 10 1. 5. library. Table of Errors for Interpolation using Equidistant and Chebyshev nodes for various values of n 4.Horner’s Algorithm */ void Evaluate(double *d.5317 0. j.h" /* Divided Differences Computation */ void ComputeDividedDifferences(double (*f)(double).4. double *p. i <= n.h" #include "math. i++) d[i] = f(x[i]).cc.
&t. sizeof(double)). } /* Error Computation */ double ComputeMaxError(double (*f)(double). &p. for(i = 0. *x. i. if (temp > e) e = temp. t. i++) { p[i] = d[n]. j) p[i] = d[j] + (t[i] .p). *p. double h. n. x.cc. *fp2.x[j])*p[i]. double *x. *d. int n) { double e = 0. j >= 0. #include #include #include #include <stdio. *t. *)calloc(nt+1. i++) { t = (x[i] + x[i+1])/2.2.POLYNOMIAL INTERPOLATION USING NEWTON’S DIVIDED DIFFERENCES 7 int i. temp = fabs(f(t) . } } /* The Runge Function */ double f(double x) { return 1/(1+pow(x.e. j. temp. ht. /* Allocate d = (double x = (double p = (double t = (double Memory for Operations */ *)calloc(n+1. nt = 1000. /* Error Checking */ if ((d == NULL)  (x == NULL)  (p == NULL)  (t == NULL)) { . *)calloc(nt+1. } return e. i <= nt. double *d. for(i = 0.h> #define PI 3. Evaluate(d. FILE *fp1. for(j = n1. sizeof(double)).h> "library. 0). } 5. sizeof(double)). *)calloc(n+1. main. sizeof(double)). p. int i. i < n.h" <stdlib.2)).h> <math.141592 void main(void) { int n = 30.
. "wt").. n). p.. x. "%. "%. fp2 = fopen("interp_nodes.0/n. KUID 698659 printf("Memory Allocation Failure.4f\n". i++) t[i] = 5 + i*ht. d[i] = 1/(1+pow(x[i]. n. } /* Generate the Nodes */ h = 10. for(i = 0.0/nt.4f\t%. } . free(t). } /* File to Save the results and for Plotting */ fp1 = fopen("interp_polydata. i++) fprintf(fp2. n). Aborting.4f\t%. fclose(fp1). /* Compute Error */ e = ComputeMaxError(f. f(x[i])). if ((fp1 == NULL)(fp2 == NULL)) { printf("Cannot open output file. i++) { /* x[i] = 5 + i*h. "wt").. free(p)."). for(i = 0. p[i])... exit(1). /* Clean Up */ fclose(fp2). free(d).dat". x[i]. free(x). t[i]. printf("e = %lf\n".8 VIJAYA C RAMASAMI. i <= n .dat". x.. i <= nt . for(i = 0. d. e). d. /* Evaluate the Polynomial */ ht = 10. i++) fprintf(fp1. nt).. /* Save the Values */ for(i = 0. x. */ x[i] = 5*cos(i*PI/n). t.2)). i <= n .4f\n". i <= nt . Evaluate(d. Aborting. exit(1). } /* Compute Divided Differences */ ComputeDividedDifferences(f.").
This action might not be possible to undo. Are you sure you want to continue?
We've moved you to where you read on your other device.
Get the full title to continue listening from where you left off, or restart the preview.