<p><div><div><div><div data-show-faces="false" data-height="21" data-width="100" data-layout="button_count" data-send="true" data-href="https://www.r-bloggers.com/divided-differences-method-of-polynomial-interpolation/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="http://www.aaronschlegel.com/divided-differences-polynomial-interpolation/"> R – Aaron Schlegel</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<div>Part of 6 in the series <a rel="nofollow" href="http://www.aaronschlegel.com/series/numerical-analysis/" title="Numerical Analysis" target="_blank">Numerical Analysis</a></div>
<p>The divided differences method is a numerical procedure for interpolating a polynomial given a set of points. Unlike <a rel="nofollow" href="http://wp.me/p4aZEo-5S0" target="_blank">Neville’s method</a>, which is used to approximate the value of an interpolating polynomial at a given point, the divided differences method constructs the interpolating polynomial in Newton form.</p>
<p>Consider a table of values of <img alt="x" title="x" src="https://s0.wp.com/latex.php?latex=x&bg=ffffff&fg=000&s=0" class="latex"> and corresponding values of a function <img alt="f(x)" title="f(x)" src="https://s0.wp.com/latex.php?latex=f%28x%29&bg=ffffff&fg=000&s=0" class="latex"> at those points:</p>
<table>
<thead>
<tr>
<th>x</th>
<th>y</th>
</tr>
</thead>
<tbody>
<tr>
<td><img alt="x_0" title="x_0" src="https://s0.wp.com/latex.php?latex=x_0&bg=ffffff&fg=000&s=0" class="latex"></td>
<td><img alt="f(x_0)" title="f(x_0)" src="https://s0.wp.com/latex.php?latex=f%28x_0%29&bg=ffffff&fg=000&s=0" class="latex"></td>
</tr>
<tr>
<td><img alt="x_1" title="x_1" src="https://s0.wp.com/latex.php?latex=x_1&bg=ffffff&fg=000&s=0" class="latex"></td>
<td><img alt="f(x_1)" title="f(x_1)" src="https://s0.wp.com/latex.php?latex=f%28x_1%29&bg=ffffff&fg=000&s=0" class="latex"></td>
</tr>
<tr>
<td><img alt="\vdots" title="\vdots" src="https://s0.wp.com/latex.php?latex=%5Cvdots&bg=ffffff&fg=000&s=0" class="latex"></td>
<td><img alt="\vdots" title="\vdots" src="https://s0.wp.com/latex.php?latex=%5Cvdots&bg=ffffff&fg=000&s=0" class="latex"></td>
</tr>
<tr>
<td><img alt="x_n" title="x_n" src="https://s0.wp.com/latex.php?latex=x_n&bg=ffffff&fg=000&s=0" class="latex"></td>
<td><img alt="f(x_n)" title="f(x_n)" src="https://s0.wp.com/latex.php?latex=f%28x_n%29&bg=ffffff&fg=000&s=0" class="latex"></td>
</tr>
</tbody>
</table>
<p>Also assume that <img alt="P_n(x)" title="P_n(x)" src="https://s0.wp.com/latex.php?latex=P_n%28x%29&bg=ffffff&fg=000&s=0" class="latex"> is the <img alt="n" title="n" src="https://s0.wp.com/latex.php?latex=n&bg=ffffff&fg=000&s=0" class="latex">th Lagrangian polynomial that corresponds with the function <img alt="f" title="f" src="https://s0.wp.com/latex.php?latex=f&bg=ffffff&fg=000&s=0" class="latex"> at these points. The polynomial <img alt="P_n(x)" title="P_n(x)" src="https://s0.wp.com/latex.php?latex=P_n%28x%29&bg=ffffff&fg=000&s=0" class="latex"> can be expressed using the divided differences of the function <img alt="f" title="f" src="https://s0.wp.com/latex.php?latex=f&bg=ffffff&fg=000&s=0" class="latex"> with respect to the <img alt="x" title="x" src="https://s0.wp.com/latex.php?latex=x&bg=ffffff&fg=000&s=0" class="latex">-values.</p>
<img alt=" P_n(x) = a_0 + a_1(x - x_0) + a_2(x - x_0)(x - x_1) + \cdots + a_n(x - x_0) \cdots (x - x_{n-1}) " title=" P_n(x) = a_0 + a_1(x - x_0) + a_2(x - x_0)(x - x_1) + \cdots + a_n(x - x_0) \cdots (x - x_{n-1}) " src="https://s0.wp.com/latex.php?latex=+P_n%28x%29+%3D+a_0+%2B+a_1%28x+-+x_0%29+%2B+a_2%28x+-+x_0%29%28x+-+x_1%29+%2B+%5Ccdots+%2B+a_n%28x+-+x_0%29+%5Ccdots+%28x+-+x_%7Bn-1%7D%29+&bg=ffffff&fg=000&s=0" class="latex">
<p>Therefore the constants <img alt="a_0, a_1, \cdots, a_n" title="a_0, a_1, \cdots, a_n" src="https://s0.wp.com/latex.php?latex=a_0%2C+a_1%2C+%5Ccdots%2C+a_n&bg=ffffff&fg=000&s=0" class="latex"> must be found to construct the polynomial. To find these constants, the divided differences are recursively generated until <img alt="n" title="n" src="https://s0.wp.com/latex.php?latex=n&bg=ffffff&fg=000&s=0" class="latex"> iterations have been completed. We start with the zeroth divided difference of the function <img alt="f" title="f" src="https://s0.wp.com/latex.php?latex=f&bg=ffffff&fg=000&s=0" class="latex"> with respect to <img alt="x_i" title="x_i" src="https://s0.wp.com/latex.php?latex=x_i&bg=ffffff&fg=000&s=0" class="latex">, which is the value of <img alt="f" title="f" src="https://s0.wp.com/latex.php?latex=f&bg=ffffff&fg=000&s=0" class="latex"> at that point. Bracket notation is introduced to distinguish the divided differences.</p>
<img alt=" \large{f[x_i] = f(x_i)} " title=" \large{f[x_i] = f(x_i)} " src="https://s0.wp.com/latex.php?latex=+%5Clarge%7Bf%5Bx_i%5D+%3D+f%28x_i%29%7D+&bg=ffffff&fg=000&s=0" class="latex">
<p>Now begins the recursive generation of the divided differences. The first divided difference is then the function <img alt="f" title="f" src="https://s0.wp.com/latex.php?latex=f&bg=ffffff&fg=000&s=0" class="latex"> with respect to the values <img alt="x_i" title="x_i" src="https://s0.wp.com/latex.php?latex=x_i&bg=ffffff&fg=000&s=0" class="latex"> and <img alt="x_{i+1}" title="x_{i+1}" src="https://s0.wp.com/latex.php?latex=x_%7Bi%2B1%7D&bg=ffffff&fg=000&s=0" class="latex">.</p>
<img alt=" \large{f[x_i, x_{i+1}] = \frac{f[x_{i+1}] - f[x_i]}{x_{i+1 - x_i}}} " title=" \large{f[x_i, x_{i+1}] = \frac{f[x_{i+1}] - f[x_i]}{x_{i+1 - x_i}}} " src="https://s0.wp.com/latex.php?latex=+%5Clarge%7Bf%5Bx_i%2C+x_%7Bi%2B1%7D%5D+%3D+%5Cfrac%7Bf%5Bx_%7Bi%2B1%7D%5D+-+f%5Bx_i%5D%7D%7Bx_%7Bi%2B1+-+x_i%7D%7D%7D+&bg=ffffff&fg=000&s=0" class="latex">
<p>The second divided difference follows:</p>
<img alt=" \large{f[x_i, x_{i+1}, x_{i+2}] = \frac{f[x_{i+1},x_{i+2}] - f[x_i, x_{i+1}]}{x_{i+2} - x_i}} " title=" \large{f[x_i, x_{i+1}, x_{i+2}] = \frac{f[x_{i+1},x_{i+2}] - f[x_i, x_{i+1}]}{x_{i+2} - x_i}} " src="https://s0.wp.com/latex.php?latex=+%5Clarge%7Bf%5Bx_i%2C+x_%7Bi%2B1%7D%2C+x_%7Bi%2B2%7D%5D+%3D+%5Cfrac%7Bf%5Bx_%7Bi%2B1%7D%2Cx_%7Bi%2B2%7D%5D+-+f%5Bx_i%2C+x_%7Bi%2B1%7D%5D%7D%7Bx_%7Bi%2B2%7D+-+x_i%7D%7D+&bg=ffffff&fg=000&s=0" class="latex">
<p>This iteration continues until the <img alt="n" title="n" src="https://s0.wp.com/latex.php?latex=n&bg=ffffff&fg=000&s=0" class="latex">th divided difference:</p>
<img alt=" \large{f[x_0, x_1, \cdots, x_n] = \frac{f[x_1, x_2, \cdots, x_n] - f[x_0, x_1, \cdots, x_n]}{x_n - x_0}} " title=" \large{f[x_0, x_1, \cdots, x_n] = \frac{f[x_1, x_2, \cdots, x_n] - f[x_0, x_1, \cdots, x_n]}{x_n - x_0}} " src="https://s0.wp.com/latex.php?latex=+%5Clarge%7Bf%5Bx_0%2C+x_1%2C+%5Ccdots%2C+x_n%5D+%3D+%5Cfrac%7Bf%5Bx_1%2C+x_2%2C+%5Ccdots%2C+x_n%5D+-+f%5Bx_0%2C+x_1%2C+%5Ccdots%2C+x_n%5D%7D%7Bx_n+-+x_0%7D%7D+&bg=ffffff&fg=000&s=0" class="latex">
<p>Thus the interpolating polynomial resulting from the divided differences method takes the form:</p>
<img alt=" P_n(x) = f[x_0] + f[x_0, x_1](x - x_0) + f[x_0, x_1, x_2](x - x_0)(x - x_1) + \cdots + f[x_0, x_1, x_2, \cdots, x_n](x - x_0)(x - x_1) \cdots (x - x_{n-1}) " title=" P_n(x) = f[x_0] + f[x_0, x_1](x - x_0) + f[x_0, x_1, x_2](x - x_0)(x - x_1) + \cdots + f[x_0, x_1, x_2, \cdots, x_n](x - x_0)(x - x_1) \cdots (x - x_{n-1}) " src="https://s0.wp.com/latex.php?latex=+P_n%28x%29+%3D+f%5Bx_0%5D+%2B+f%5Bx_0%2C+x_1%5D%28x+-+x_0%29+%2B+f%5Bx_0%2C+x_1%2C+x_2%5D%28x+-+x_0%29%28x+-+x_1%29+%2B+%5Ccdots+%2B+f%5Bx_0%2C+x_1%2C+x_2%2C+%5Ccdots%2C+x_n%5D%28x+-+x_0%29%28x+-+x_1%29+%5Ccdots+%28x+-+x_%7Bn-1%7D%29+&bg=ffffff&fg=000&s=0" class="latex">
<h6>Divided Differences Example</h6>
<p>Consider the following set of <img alt="x" title="x" src="https://s0.wp.com/latex.php?latex=x&bg=ffffff&fg=000&s=0" class="latex"> points and the corresponding values of a function <img alt="f" title="f" src="https://s0.wp.com/latex.php?latex=f&bg=ffffff&fg=000&s=0" class="latex"> at those points. This data set is the same from the previous post on Neville’s method. We will perform the divided differences method to find the interpolating polynomial of these points and approximate the polynomial at <img alt="f(8.4)" title="f(8.4)" src="https://s0.wp.com/latex.php?latex=f%288.4%29&bg=ffffff&fg=000&s=0" class="latex">.</p>
<table>
<thead>
<tr>
<th>x</th>
<th>f(x)</th>
</tr>
</thead>
<tbody>
<tr>
<td>8.1</td>
<td>16.9446</td>
</tr>
<tr>
<td>8.3</td>
<td>17.56492</td>
</tr>
<tr>
<td>8.6</td>
<td>18.50515</td>
</tr>
<tr>
<td>8.7</td>
<td>18.82091</td>
</tr>
</tbody>
</table>
<p>First, <img alt="f[x_0, x_1]" title="f[x_0, x_1]" src="https://s0.wp.com/latex.php?latex=f%5Bx_0%2C+x_1%5D&bg=ffffff&fg=000&s=0" class="latex"> is found.</p>
<img alt=" f[x_0, x_1] = \frac{f(x_1) - f(x_0)}{x_1 - x_0} = \frac{17.56492 - 16.9446}{8.3 - 8.1} = 3.1016 " title=" f[x_0, x_1] = \frac{f(x_1) - f(x_0)}{x_1 - x_0} = \frac{17.56492 - 16.9446}{8.3 - 8.1} = 3.1016 " src="https://s0.wp.com/latex.php?latex=+f%5Bx_0%2C+x_1%5D+%3D+%5Cfrac%7Bf%28x_1%29+-+f%28x_0%29%7D%7Bx_1+-+x_0%7D+%3D+%5Cfrac%7B17.56492+-+16.9446%7D%7B8.3+-+8.1%7D+%3D+3.1016+&bg=ffffff&fg=000&s=0" class="latex">
<p>Then, <img alt="f[x_1, x_2]" title="f[x_1, x_2]" src="https://s0.wp.com/latex.php?latex=f%5Bx_1%2C+x_2%5D&bg=ffffff&fg=000&s=0" class="latex"> is computed.</p>
<img alt=" f[x_1, x_2] = \frac{f(x_2) - f(x_1)}{x_2 - x_1} = \frac{18.50515 - 17.56492}{8.6 - 8.3} = 3.1341 " title=" f[x_1, x_2] = \frac{f(x_2) - f(x_1)}{x_2 - x_1} = \frac{18.50515 - 17.56492}{8.6 - 8.3} = 3.1341 " src="https://s0.wp.com/latex.php?latex=+f%5Bx_1%2C+x_2%5D+%3D+%5Cfrac%7Bf%28x_2%29+-+f%28x_1%29%7D%7Bx_2+-+x_1%7D+%3D+%5Cfrac%7B18.50515+-+17.56492%7D%7B8.6+-+8.3%7D+%3D+3.1341+&bg=ffffff&fg=000&s=0" class="latex">
<p>With <img alt="f[x_0, x_1]" title="f[x_0, x_1]" src="https://s0.wp.com/latex.php?latex=f%5Bx_0%2C+x_1%5D&bg=ffffff&fg=000&s=0" class="latex"> and <img alt="f[x_1, x_2]" title="f[x_1, x_2]" src="https://s0.wp.com/latex.php?latex=f%5Bx_1%2C+x_2%5D&bg=ffffff&fg=000&s=0" class="latex">, we find <img alt="f[x_0, x_1, x_2]" title="f[x_0, x_1, x_2]" src="https://s0.wp.com/latex.php?latex=f%5Bx_0%2C+x_1%2C+x_2%5D&bg=ffffff&fg=000&s=0" class="latex">.</p>
<img alt=" f[x_0, x_1, x_2] = \frac{f[x_1, x_2] - f[x_0, x_1]}{x_2 - x_0} = \frac{3.1341 - 3.1016}{8.6-8.1} = 0.065 " title=" f[x_0, x_1, x_2] = \frac{f[x_1, x_2] - f[x_0, x_1]}{x_2 - x_0} = \frac{3.1341 - 3.1016}{8.6-8.1} = 0.065 " src="https://s0.wp.com/latex.php?latex=+f%5Bx_0%2C+x_1%2C+x_2%5D+%3D+%5Cfrac%7Bf%5Bx_1%2C+x_2%5D+-+f%5Bx_0%2C+x_1%5D%7D%7Bx_2+-+x_0%7D+%3D+%5Cfrac%7B3.1341+-+3.1016%7D%7B8.6-8.1%7D+%3D+0.065+&bg=ffffff&fg=000&s=0" class="latex">
<p><img alt="f[x_2, x_3]" title="f[x_2, x_3]" src="https://s0.wp.com/latex.php?latex=f%5Bx_2%2C+x_3%5D&bg=ffffff&fg=000&s=0" class="latex"> is then found.</p>
<img alt=" f[x_2, x_3] = \frac{f(x_3) - f(x_2)}{x_3 - x_2} = \frac{18.82091 - 18.50515}{8.7 - 8.6} = 3.1576 " title=" f[x_2, x_3] = \frac{f(x_3) - f(x_2)}{x_3 - x_2} = \frac{18.82091 - 18.50515}{8.7 - 8.6} = 3.1576 " src="https://s0.wp.com/latex.php?latex=+f%5Bx_2%2C+x_3%5D+%3D+%5Cfrac%7Bf%28x_3%29+-+f%28x_2%29%7D%7Bx_3+-+x_2%7D+%3D+%5Cfrac%7B18.82091+-+18.50515%7D%7B8.7+-+8.6%7D+%3D+3.1576+&bg=ffffff&fg=000&s=0" class="latex">
<p>We can then compute <img alt="f[x_1, x_2, x_3]" title="f[x_1, x_2, x_3]" src="https://s0.wp.com/latex.php?latex=f%5Bx_1%2C+x_2%2C+x_3%5D&bg=ffffff&fg=000&s=0" class="latex">:</p>
<img alt=" f[x_1, x_2, x_3] = \frac{f[x_2, x_3] - f[x_1, x_2]}{x_3 - x_1} = \frac{3.1576 - 3.1341}{8.7 - 8.3} = 0.05875 " title=" f[x_1, x_2, x_3] = \frac{f[x_2, x_3] - f[x_1, x_2]}{x_3 - x_1} = \frac{3.1576 - 3.1341}{8.7 - 8.3} = 0.05875 " src="https://s0.wp.com/latex.php?latex=+f%5Bx_1%2C+x_2%2C+x_3%5D+%3D+%5Cfrac%7Bf%5Bx_2%2C+x_3%5D+-+f%5Bx_1%2C+x_2%5D%7D%7Bx_3+-+x_1%7D+%3D+%5Cfrac%7B3.1576+-+3.1341%7D%7B8.7+-+8.3%7D+%3D+0.05875+&bg=ffffff&fg=000&s=0" class="latex">
<p>Lastly, we calculate <img alt="f[x_1, x_2, x_3, x_4]" title="f[x_1, x_2, x_3, x_4]" src="https://s0.wp.com/latex.php?latex=f%5Bx_1%2C+x_2%2C+x_3%2C+x_4%5D&bg=ffffff&fg=000&s=0" class="latex">:</p>
<img alt=" f[x_1, x_2, x_3, x_4] = \frac{f[x_1, x_2, x_3] - f[x_0, x_1, x_2]}{x_3 - x_0} = \frac{0.05875 - 0.065}{8.7-8.1} = -0.010147 " title=" f[x_1, x_2, x_3, x_4] = \frac{f[x_1, x_2, x_3] - f[x_0, x_1, x_2]}{x_3 - x_0} = \frac{0.05875 - 0.065}{8.7-8.1} = -0.010147 " src="https://s0.wp.com/latex.php?latex=+f%5Bx_1%2C+x_2%2C+x_3%2C+x_4%5D+%3D+%5Cfrac%7Bf%5Bx_1%2C+x_2%2C+x_3%5D+-+f%5Bx_0%2C+x_1%2C+x_2%5D%7D%7Bx_3+-+x_0%7D+%3D+%5Cfrac%7B0.05875+-+0.065%7D%7B8.7-8.1%7D+%3D+-0.010147+&bg=ffffff&fg=000&s=0" class="latex">
<p>The interpolating polynomial, <img alt="P_3(x)" title="P_3(x)" src="https://s0.wp.com/latex.php?latex=P_3%28x%29&bg=ffffff&fg=000&s=0" class="latex">, is then constructed.</p>
<img alt=" P_3(x) = 16.9446 + 3.1016(x - 8.1) + 0.065(x - 8.1)(x - 8.3) - 0.010417(x - 8.1)(x - 8.3)(x - 8.6) " title=" P_3(x) = 16.9446 + 3.1016(x - 8.1) + 0.065(x - 8.1)(x - 8.3) - 0.010417(x - 8.1)(x - 8.3)(x - 8.6) " src="https://s0.wp.com/latex.php?latex=+P_3%28x%29+%3D+16.9446+%2B+3.1016%28x+-+8.1%29+%2B+0.065%28x+-+8.1%29%28x+-+8.3%29+-+0.010417%28x+-+8.1%29%28x+-+8.3%29%28x+-+8.6%29+&bg=ffffff&fg=000&s=0" class="latex">
<p>We can see the interpolated polynomial passes through the points with the following:</p>
<pre>
p3x &lt;- function(x) {
  f &lt;- 16.9446 + 3.1016 * (x - 8.1) + 0.065 * (x - 8.1) * (x - 8.3) - 0.010417 * (x - 8.1) * (x - 8.3) * (x - 8.6)
  return(f)
}

x &lt;- c(8.1, 8.3, 8.6, 8.7)
fx &lt;- c(16.9446, 17.56492, 18.50515, 18.82091)

dat &lt;- data.frame(cbind(x, fx))

ggplot(dat, aes(x=x, y=fx)) + 
  geom_point(size=5, col='blue') + 
  stat_function(fun = p3x, size=1.25, alpha=0.4)
</pre>
<p><a rel="nofollow" href="http://www.aaronschlegel.com/?attachment_id=22576" target="_blank"><img sizes="(max-width: 1060px) 100vw, 1060px" src="https://i0.wp.com/www.aaronschlegel.com/wp-content/uploads/chart.png?resize=1060%2C757" alt="Divided differences interpolated function" class="wp-image-22576" data-recalc-dims="1"></a></p>
<p>Using the function above, we can also see the interpolated polynomial resulting from the divided differences method returns the same approximated value of the function <img alt="f" title="f" src="https://s0.wp.com/latex.php?latex=f&bg=ffffff&fg=000&s=0" class="latex">, <img alt="f(x)" title="f(x)" src="https://s0.wp.com/latex.php?latex=f%28x%29&bg=ffffff&fg=000&s=0" class="latex"> as Neville’s method.</p>
<pre>
p3x(8.4)
## [1] 17.87709
</pre>
<h6>Divided Differences in R</h6>
<p>The following is an implementation of the divided differences method of polynomial interpolation in R. The function utilizes the <a rel="nofollow" href="https://cran.r-project.org/web/packages/rSymPy/index.html" target="_blank">rSymPy</a> library to build the interpolating polynomial and approximate the value of the function <img alt="f" title="f" src="https://s0.wp.com/latex.php?latex=f&bg=ffffff&fg=000&s=0" class="latex"> for a given value of <img alt="x" title="x" src="https://s0.wp.com/latex.php?latex=x&bg=ffffff&fg=000&s=0" class="latex">.</p>
<pre>
divided.differences &lt;- function(x, y, x0) {
  require(rSymPy)
  n &lt;- length(x)
  q &lt;- matrix(data = 0, n, n)
  q[,1] &lt;- y
  f &lt;- as.character(round(q[1,1], 5))
  fi &lt;- ''
  
  for (i in 2:n) {
    for (j in i:n) {
      q[j,i] &lt;- (q[j,i-1] - q[j-1,i-1]) / (x[j] - x[j-i+1])
    }
    fi &lt;- paste(fi, '*(x - ', x[i-1], ')', sep = '', collapse = '')
    
    f &lt;- paste(f, ' + ', round(q[i,i], 5), fi, sep = '', collapse = '')
  }
  
  x &lt;- Var('x')
  sympy(paste('e = ', f, collapse = '', sep = ''))
  approx &lt;- sympy(paste('e.subs(x, ', as.character(x0), ')', sep = '', collapse = ''))
  
  return(list('Approximation from Interpolation'=as.numeric(approx), 
              'Interpolated Function'=f, 
              'Divided Differences Table'=q))
}
</pre>
<p>Let’s use the function to interpolate a function given the values of <img alt="x" title="x" src="https://s0.wp.com/latex.php?latex=x&bg=ffffff&fg=000&s=0" class="latex"> and the corresponding values of a function <img alt="f" title="f" src="https://s0.wp.com/latex.php?latex=f&bg=ffffff&fg=000&s=0" class="latex">, <img alt="f(x)" title="f(x)" src="https://s0.wp.com/latex.php?latex=f%28x%29&bg=ffffff&fg=000&s=0" class="latex"> and approximate the function when <img alt="x = 8.4" title="x = 8.4" src="https://s0.wp.com/latex.php?latex=x+%3D+8.4&bg=ffffff&fg=000&s=0" class="latex">.</p>
<pre>
divided.differences(x, fx, 8.4)
## Loading required package: rSymPy
## Loading required package: rJython
## Loading required package: rJava
## Loading required package: rjson
## $`Approximation from Interpolation`
## [1] 17.87709
## 
## $`Interpolated Function`
## [1] &quot;16.9446 + 3.1016*(x - 8.1) + 0.065*(x - 8.1)*(x - 8.3) + -0.01042*(x - 8.1)*(x - 8.3)*(x - 8.6)&quot;
## 
## $`Divided Differences Table`
##          [,1]   [,2]    [,3]        [,4]
## [1,] 16.94460 0.0000 0.00000  0.00000000
## [2,] 17.56492 3.1016 0.00000  0.00000000
## [3,] 18.50515 3.1341 0.06500  0.00000000
## [4,] 18.82091 3.1576 0.05875 -0.01041667
</pre>
<p>The function returns the approximated value, the interpolated polynomial use to approximate the function and the divided differences table which contains the intermediate calculations as we saw earlier. I wasn’t able to find a function in R or a package that performs the divided differences method, so, unfortunately, I have nothing for which to compare our function. However, the results agree with our manual calculations so that should be satisfactory for this introductory purpose.</p>
<h6>References</h6>
<p>Burden, R. L., &amp; Faires, J. D. (2011). Numerical analysis (9th ed.). Boston, MA: Brooks/Cole, Cengage Learning.</p>
<p>The post <a rel="nofollow" href="http://www.aaronschlegel.com/divided-differences-polynomial-interpolation/" target="_blank">Divided Differences Method of Polynomial Interpolation</a> appeared first on <a rel="nofollow" href="http://www.aaronschlegel.com/" target="_blank">Aaron Schlegel</a>.</p>
	<p>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="http://www.aaronschlegel.com/divided-differences-polynomial-interpolation/"> R – Aaron Schlegel</a></strong>.</div>
<hr>
<a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers.com</a> offers <strong><a rel="nofollow" href="https://feedburner.google.com/fb/a/mailverify?uri=RBloggers">daily e-mail updates</a></strong> about <a rel="nofollow" href="https://www.r-project.org/" title="The R Project for Statistical Computing">R</a> news and <a rel="nofollow" href="https://www.r-bloggers.com/search/tutorial" title="R tutorials">tutorials</a> on topics such as: <a rel="nofollow" href="https://www.r-bloggers.com/search/data%20science" title="Data science">Data science</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Big%20Data" title="Big Data">Big Data, <a rel="nofollow" href="https://www.r-users.com/" title="R jobs">R jobs</a>, visualization (<a rel="nofollow" href="https://www.r-bloggers.com/search/ggplot2" title="ggplot and ggplot2 tutorials">ggplot2</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/boxplot" title="Boxplots using lattice and ggplot2 tutorials">Boxplots</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/map" title="Maps and gis">maps</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/animation" title="Animation in R">animation</a>), programming (<a rel="nofollow" href="https://www.r-bloggers.com/search/RStudio" title="RStudio IDE for R">RStudio</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/sweave" title="Sweave and literate programming">Sweave</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/LaTeX" title="LaTeX in R">LaTeX</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/SQL" title="SQL and databases">SQL</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/eclipse" title="Eclipse IDE for R">Eclipse</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/git" title="git and github, Version Control System">git</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/hadoop" title="Large data in R using Hadoop">hadoop</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Web+Scraping" title="Web Scraping of google, facebook, yahoo, twitter and more using R">Web Scraping</a>) statistics (<a rel="nofollow" href="https://www.r-bloggers.com/search/regression" title="Regressions and ANOVA analysis tutorials">regression</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/PCA" title="principal component analysis tutorial">PCA</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/time+series" title="Time series">time series</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/trading" title="finance trading">trading</a>) and more...
<img width="1" alt="" src="http://feeds.feedburner.com/~r/RBloggers/~4/KJ0dkIoWgZ4" height="1"></a></div>