]> gitweb.michael.orlitzky.com - octave.git/blob - divided_difference_coefficients.m
Use the infinity norm in steepest_descent(), update its comments, and simplify the...
[octave.git] / divided_difference_coefficients.m
1 function coefficients = divided_difference_coefficients(xs)
2 % Compute divided difference coefficients of `f` at points `xs`.
3 %
4 % INPUTS:
5 %
6 % * ``xs`` - A vector containing x-coordinates.
7 %
8 % OUTPUTS:
9 %
10 % * ``coefficients`` - The vector of coefficients such that
11 % dot(coefficients, f(xs)) == f[xs]. Used to solve linear systems.
12 %
13
14 coefficients = [];
15
16 for xj = xs
17 this_coeff = 1;
18 for xi = xs
19 if (xi != xj)
20 this_coeff = this_coeff * (1 / (xj - xi));
21 end
22 end
23 coefficients(end+1) = this_coeff;
24 end
25 end