3

I have the following series:

f[x_] := Sin[x]
n := 50

Ni3[x_] := Sum[(f[k]*(-1)^k)/((x - k)*Gamma[k + 1]*Gamma[n - k + 1]), {k, 0, n}]/
           Sum[(-1)^k/((x - k)*Gamma[k + 1]*Gamma[n - k + 1]), {k, 0, n}]

Plot[{Ni3[x], f[x]}, {x, -7, 7}, AspectRatio -> Automatic, PlotRange -> 10]

At number of terms n below 40 the plot gives what is expected. But when increasing it above 50 the plot becomes corrupted. The setting $MinPrecision does not affect the result. The series is proven to converge to $f(x)=\sin(x)$.

bad plot

J. M.'s missing motivation
  • 124,525
  • 11
  • 401
  • 574
Anixx
  • 3,585
  • 1
  • 20
  • 32

1 Answers1

4

As Szabolcs suggests, cranking up WorkingPrecision (or for that matter, just forcing Plot[] to use arbitrary precision) helps a lot. In this answer, I've taken the liberty to slightly simplify your barycentric interpolant as well:

f[x_] := Sin[x]

Ni3[n_Integer, x_] := (x - n) Binomial[x, n]
    Sum[(-1)^(n - k) Binomial[n, k] f[k]/(x - k), {k, 0, n}, Method -> "Procedural"]

Plot[{Ni3[50, x], f[x]}, {x, -7, 7}, AspectRatio -> Automatic, 
     PlotRange -> 10, WorkingPrecision -> 20]

sine and barycentric interpolant

J. M.'s missing motivation
  • 124,525
  • 11
  • 401
  • 574