Python Programming
Basics
Numerical Methods
- Bisection Method
- Secant Method
- Regular Falsi (False Position) Method
- Newton Raphson Method
- Gauss Elimination Method
- Gauss Jordan Method
- Gauss-Seidel Method
- Lagrange Interpolation Method
- Newton Divided Difference Interpolation
- Newton Forward Difference Interpolation
- Newton Backward Difference Interpolation
- Trapezoidal Rule
- Simpson 1/3rd Rule
- Simpson 3/8 Rule
- Euler’s Method
- Euler’s Modified Method
- Runge-Kutta 2nd Order Method
- Runge-Kutta 4th Order Method
- Cubic Spline Method
- Bilinear Interpolation Method
- Milne’s Method
- More topics coming soon…
Advance Numerical Methods
Newton’s Backward Difference Interpolation is a method used to estimate the value of a function at a particular point based on a set of discrete data points.
It is similar to Newton’s Forward Difference Interpolation, but it uses the backward differences of the function values instead of forward differences.
Newton Backward difference interpolation in Python:
import math
# Define the function for Newton's Backward Difference Interpolation
def newton_backward_interpolation(x, y, x_new):
# Get the number of data points
n = len(y)
# Get the common spacing between the x-values
h = x[1] - x[0]
# Compute the backward differences of the y-values using a nested loop
deltas = [y] # initialize a list of lists with y as the first element
for i in range(1, n):
delta_i = []
for j in range(n-i):
delta_j = deltas[i-1][j+1] - deltas[i-1][j]
delta_i.append(delta_j)
deltas.append(delta_i)
# Compute the coefficients of the backward difference interpolating polynomial using the backward differences
b = [deltas[0][0] / math.factorial(i) for i in range(n)]
for i in range(1, n):
b[i] = deltas[i-1][0] / (math.factorial(i) * h**i)
# Evaluate the interpolating polynomial at the desired point x_new using a nested loop
Pn = b[-1] # start with the highest order coefficient
for i in range(n-2, -1, -1):
Pn = Pn*(x_new - x[i]) + b[i]
# Return the estimated value of the function at x_new
return Pn
# Example usage
# Define the data points
x = [0.0, 0.2, 0.4, 0.6, 0.8, 1.0]
y = [1.0000, 1.2214, 1.4918, 1.8221, 2.2255, 2.7183]
# Define the point where we want to estimate the function
x_new = 0.5
# Use the newton_backward_interpolation function to estimate the value of the function at x_new
Pn = newton_backward_interpolation(x, y, x_new)
# Print the estimated value of the function at x_new
print(f"Pn({x_new}) = {Pn}")
#Output - Pn(0.5) = 1.6604399999999998