-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbaryeval2.m
More file actions
40 lines (34 loc) · 1.07 KB
/
baryeval2.m
File metadata and controls
40 lines (34 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
% =========================================================================
% baryeval2
%
% AUTHOR ..... [Thomas Devries]
%
% Evaluates the barycentric formula of the second kind.
%
% INPUT
% tau .... Interpolation nodes
% rho .... Values to be interpolated
% x ...... Points at which to evaluate the interpolating polynomial
%
% OUTPUT
% p .... Value of the interpolating polynomial at points x
% =========================================================================
function p = baryeval2(tau, rho, x)
% top (numerator) of P(x) initialized as an empty vector sized of x input
t = zeros(1, length(x));
% bottom (denomenator) of P(x) initialized as an empty vector sized of x
% input
b = zeros(1, length(x));
% intialize function computing the beta term weights
beta = bary_weights(tau);
% defining top factor of P(x)
for k = 1:length(tau)
t = t + ((beta(k)*rho(k)) ./ (x - tau(k)));
end
% defining bottom factor of P(x)
for k = 1: length(tau)
b = b + ((beta(k)) ./ (x - tau(k)));
end
% Calculating values of P(x)
p = t./b;
end