From: Michael Orlitzky Date: Sun, 4 Nov 2012 21:12:17 +0000 (-0500) Subject: Add the lagrange_psi function. X-Git-Url: https://gitweb.michael.orlitzky.com/?a=commitdiff_plain;h=03f0629ed5ea048ba00751d72e8508868b48fb66;p=sage.d.git Add the lagrange_psi function. --- diff --git a/mjo/interpolation.py b/mjo/interpolation.py index 70c35c1..8c3936e 100644 --- a/mjo/interpolation.py +++ b/mjo/interpolation.py @@ -93,6 +93,7 @@ def divided_difference_coefficients(xs): for xj in xs ] return coeffs + def divided_difference(xs, ys): """ Return the Newton divided difference of the points (xs[k], @@ -269,3 +270,25 @@ def hermite_interpolant(x, xs, ys, y_primes): for k in range(0, len(xs)) ]) return (s1 + s2) + + +def lagrange_psi(x, xs): + """ + The function, + + Psi(x) = (x - xs[0])*(x - xs[1])* ... *(x - xs[-1]) + + used in Lagrange and Hermite interpolation. + + INPUT: + + - ``x`` -- The independent variable of the resulting expression. + + - ``xs`` -- A list of points. + + OUTPUT: + + A symbolic expression in one variable, `x`. + """ + + return product([ (x - xj) for xj in xs ])