X-Git-Url: http://gitweb.michael.orlitzky.com/?p=octave.git;a=blobdiff_plain;f=divided_difference.m;h=261abeded4ccf9eabf468f817d1b9fa9eafe0994;hp=4705f0a3d8d1ff3cf699cca2dd21c04d30a3c2fa;hb=b12c6c2a4bf4cef29b2e08b743c92889505c7ed9;hpb=e1b71b4ca7cfa08ac76744a17a3778d4ccfaa7e2 diff --git a/divided_difference.m b/divided_difference.m index 4705f0a..261abed 100644 --- a/divided_difference.m +++ b/divided_difference.m @@ -1,32 +1,32 @@ function dd = divided_difference(f, xs) - ## Compute divided difference of `f` at points `xs`. The argument `xs` - ## is assumed to be a vector containing at least one element. If it - ## contains n elements, the (n-1)st divided difference will be - ## calculated. - ## - ## INPUTS: - ## - ## * ``f`` - The function whose divided differences we want. - ## - ## * ``xs`` - A vector containing x-coordinates. The length of `xs` - ## determines the order of the divided difference. - ## - ## - ## OUTPUTS: - ## - ## * ``dd`` - The divided difference f[xs(1), xs(2),...] - ## + % Compute divided difference of `f` at points `xs`. The argument `xs` + % is assumed to be a vector containing at least one element. If it + % contains n elements, the (n-1)st divided difference will be + % calculated. + % + % INPUTS: + % + % * ``f`` - The function whose divided differences we want. + % + % * ``xs`` - A vector containing x-coordinates. The length of `xs` + % determines the order of the divided difference. + % + % + % OUTPUTS: + % + % * ``dd`` - The divided difference f[xs(1), xs(2),...] + % order = length(xs) - 1; if (order < 0) - ## Can't do anything here. Return nothing. + % Can't do anything here. Return nothing. dd = NA; elseif (order == 0) - ## Our base case. + % Our base case. dd = f(xs(1)); else - ## Order >= 1. + % Order >= 1. cs = divided_difference_coefficients(xs); dd = dot(cs, f(xs)); end