numerical_methods.interpolation package

Submodules

numerical_methods.interpolation.forward_elimination_non_null module

numerical_methods.interpolation.forward_elimination_non_null.forward_elimination_non_null(A: list[list[float]], b: list[float], n: int) list[float] | int[source]

Perform Gaussian elimination with a non-zero pivot constraint and solve the system using back substitution.

This function assumes that no pivot will be zero (i.e., A[k][k] ≠ 0). Otherwise, it prints an error.

Parameters:
  • A (list[list[float]]) – Coefficient matrix of size n x n.

  • b (list[float]) – Right-hand side vector.

  • n (int) – Number of equations/unknowns.

Returns:

Solution vector X if successful, or 0 if a zero pivot is encountered.

Return type:

list[float] | int

numerical_methods.interpolation.lagrange_interpolation module

numerical_methods.interpolation.lagrange_interpolation.lagrange_interpolation(n: int, x: float, points: list[list[float]]) None[source]

Evaluate the Lagrange interpolating polynomial at a given point.

Parameters:
  • n (int) – Number of data points.

  • x (float) – The value at which to evaluate the polynomial.

  • points (list[list[float]]) – List of [xi, yi] data points.

Example:

>>> points = [[1, 2], [2, 3], [4, 7]]
>>> lagrange_interpolation(3, 2.5, points)

numerical_methods.interpolation.newton_interpolation module

numerical_methods.interpolation.newton_interpolation.newton_interpolation(n: int, x: float, points: list[list[float]]) list[list[float]][source]

Evaluate the Newton interpolating polynomial at a given point using divided differences.

Parameters:
  • n (int) – Number of data points.

  • x (float) – The value at which to evaluate the polynomial.

  • points (list[list[float]]) – List of [xi, yi] data points.

Returns:

The divided difference table.

Return type:

list[list[float]]

Example:

>>> points = [[1, 2], [2, 3], [4, 7]]
>>> newton_interpolation(3, 2.5, points)
numerical_methods.interpolation.newton_interpolation.soigner_dd(d: list[list[float]]) None[source]

Nicely display the divided differences table.

Parameters:

d (list[list[float]]) – Divided difference matrix.

Module contents