Function Repository Resource:

PolynomialDividedDifference

Source Notebook

Evaluate the divided difference of a polynomial

Contributed by: Jan Mangaldan

ResourceFunction["PolynomialDividedDifference"][poly,{x,a,b}]

evaluates the divided difference of the polynomial poly with respect to the variable x at a and b.

Details and Options

The divided difference of a polynomial p(x) at a and b is defined as (p(b)-p(a))/(b-a), if ba, and p(a) if b=a.

Examples

Basic Examples (2) 

Symbolically evaluate the divided difference of a polynomial:

In[1]:=
ResourceFunction["PolynomialDividedDifference"][
 x^3 - x + 5, {x, a, b}]
Out[1]=

Numerically evaluate the divided difference of a polynomial:

In[2]:=
ResourceFunction["PolynomialDividedDifference"][
 x^3 - x + 5, {x, 1/2, 1}]
Out[2]=

Scope (2) 

Divided difference of a polynomial with symbolic coefficients:

In[3]:=
ResourceFunction["PolynomialDividedDifference"][\!\(
\*UnderoverscriptBox[\(\[Sum]\), \(j = 0\), \(3\)]\(\*
TemplateBox[{"j"},
"C"] 
\*SuperscriptBox[\(x\), \(j\)]\)\), {x, a, b}]
Out[3]=

Divided difference of a polynomial with numerical coefficients:

In[4]:=
ResourceFunction["PolynomialDividedDifference"][
 3. - 0.7 x^2 + 1.3 x^5, {x, 0.1, 0.9}]
Out[4]=

Applications (3) 

A high-degree polynomial:

In[5]:=
p[x_] := \!\(
\*UnderoverscriptBox[\(\[Product]\), \(k = 0\), \(9\)]\((x - k)\)\)

Directly evaluating the divided difference through its definition gives a result that is not very accurate:

In[6]:=
With[{\[CurlyEpsilon] = N[3*^-10, 20]}, (p[5 + \[CurlyEpsilon]] - p[5 - \[CurlyEpsilon]])/((5 + \[CurlyEpsilon]) - (5 - \
\[CurlyEpsilon]))]
Out[6]=

PolynomialDividedDifference gives a more accurate result:

In[7]:=
With[{\[CurlyEpsilon] = N[3*^-10, 20]}, ResourceFunction["PolynomialDividedDifference"][
  p[t], {t, 5 - \[CurlyEpsilon], 5 + \[CurlyEpsilon]}]]
Out[7]=

Use PolynomialDividedDifference to evaluate a definite integral:

In[8]:=
p[x_] := x^3 + 2 x^2 - x + 1
In[9]:=
With[{a = -1, b = 3}, (b - a) ResourceFunction["PolynomialDividedDifference"][
   FromDigits[
    Reverse[Prepend[
      CoefficientList[p[t], t]/Range[Exponent[p[t], t] + 1], 0]], t], {t, a, b}]]
Out[9]=

Compare with the result using Integrate:

In[10]:=
\!\(
\*SubsuperscriptBox[\(\[Integral]\), \(-1\), \(3\)]\(p[
   t] \[DifferentialD]t\)\)
Out[10]=

Evaluate the q-derivative of a polynomial using PolynomialDividedDifference:

In[11]:=
p[x_] := x^3 + 2 x^2 - x + 1
In[12]:=
ResourceFunction["PolynomialDividedDifference"][p[t], {t, x, q x}]
Out[12]=

In the limit q1, the q-derivative reduces to the derivative:

In[13]:=
Limit[%, q -> 1]
Out[13]=
In[14]:=
p'[x]
Out[14]=

Properties and Relations (1) 

When b=a, the divided difference of a polynomial p(x) at a and b is equal to the derivative of p(x), evaluated at x=a:

In[15]:=
p[x_] := x^3 + 2 x^2 - x + 1
In[16]:=
ResourceFunction["PolynomialDividedDifference"][p[t], {t, x, x}] == p'[x] // Simplify
Out[16]=

Version History

  • 1.0.0 – 31 December 2020

Source Metadata

Related Resources

License Information