]> gitweb.michael.orlitzky.com - sage.d.git/commitdiff
Add the lagrange_psi function.
authorMichael Orlitzky <michael@orlitzky.com>
Sun, 4 Nov 2012 21:12:17 +0000 (16:12 -0500)
committerMichael Orlitzky <michael@orlitzky.com>
Sun, 4 Nov 2012 21:12:17 +0000 (16:12 -0500)
mjo/interpolation.py

index 70c35c1a3ac9e812865185c71b1f4d2cc88be1ed..8c3936edabaf5aff434f5f1728edffa899330f6d 100644 (file)
@@ -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 ])