# Barycentric interpolation formula with interval arithmetic

**URL:** <https://discourse.julialang.org/t/barycentric-interpolation-formula-with-interval-arithmetic/33380>\
**Category:** Optimization (Mathematical)\
**Created:** [January 15, 2020, 6:07am UTC](https://discourse.julialang.org/t/barycentric-interpolation-formula-with-interval-arithmetic/33380 "2020-01-15T06:07:16Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ArjunNarayanan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/arjunnarayanan/32/6475_2.png) [@ArjunNarayanan](https://discourse.julialang.org/u/ArjunNarayanan)\
**Post date:** [January 15, 2020, 6:07am UTC](https://discourse.julialang.org/t/barycentric-interpolation-formula-with-interval-arithmetic/33380/1 "2020-01-15T06:07:16Z")

</div>

Barycentric interpolation is a numerically stable algorithm to evaluate Lagrange interpolating polynomials. An implementation in Julia is available at [BarycentricInterpolation.jl](https://github.com/dawbarton/BarycentricInterpolation.jl).

The procedure takes as input a set of nodes X\_k = \{ x\_1, x\_2, \ldots x\_k\} and initially computes a set of weights W\_k = \{ w\_1, w\_2, \ldots w\_k \}.

Then, evaluating the k polynomials at the point x involves:

(This is pseudocode adopted from the above mentioned package just for description purposes)

```julia
for i = 1:k
      vals[i] = Wn[i] / (x - Xn[i])
end

```

(The complete algorithm checks for the case `x == Xn[i]` and then sets `vals[i] = 1.0` and all other entries of `vals` to `0.0`. Also, there is a final normalization step.)

I was wondering if there is a “Barycentric algorithm” that deals with the case when `x::Interval` (from [IntervalArithmetic.jl](https://github.com/JuliaIntervals/IntervalArithmetic.jl)).

Specifically, if `x` contains `Xn[i]` then the output bounds become arbitrarily loose `[0,+/-∞]`. Any inputs in dealing with this will be very helpful!

(It’s a little amusingly ironic that the barycentric algorithm is used because it is numerically robust and avoids cancellation errors, yet seems to not work immediately with interval arithmetic.)
