/ concept-collection / barycentric-rational
Sign in
concept-collection / barycentric-rational
barycentric-rational / src / methods / equal.m
40 lines · 1.4 KBBlameHistoryRaw
1% ---------------------------------------------------------------------------
2% All weights equal: what the alternating signs are for
3%
4% w_k = 1 for every k.
5%
6% This is a perfectly good barycentric formula and it does interpolate: at each
7% node the k-th term dominates and r(x_k) = f_k. Between two consecutive nodes,
8% though, the denominator
9%
10% sum_k 1 / (t - x_k)
12% runs from +infinity at the left node down to -infinity at the right one, so it
13% crosses zero somewhere in every interval. Each of those crossings is a pole.
14% Open the Poles tab: n real poles, one per interval, and the roots that
15% Theorem 1 keeps off the real axis are sitting right on it.
17% Schneider and Werner proved that the weights of a pole-free barycentric
18% rational interpolant must alternate in sign, and the paper checks that the
19% weights of equation (18) do. This script is the other side of that statement.
20% Put a (-1)^k back in and the poles disappear -- that is Berrut's interpolant.
22% The d slider is ignored by this script.
23% ---------------------------------------------------------------------------
25function w = bary_weights(x, d)
26w = ones(1, numel(x));
27end
29function r = bary_eval(x, y, w, t)
30sz = size(t);
31D = t(:) - x(:).';
32Q = w(:).' ./ D;
33r = (Q * y(:)) ./ sum(Q, 2);
34hit = find(any(D == 0, 2));
35for m = 1:numel(hit)
36 k = find(D(hit(m), :) == 0, 1);
37 r(hit(m)) = y(k);
38end
39r = reshape(r, sz);
40end
moveopenescclose