- 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…
The cubic spline method is a type of interpolation method that is commonly used in numerical analysis to estimate a function (guess the function) that passes through a set of data points.
The method involves constructing a piecewise cubic polynomial that matches the values and first derivatives of the function at the data points, as well as satisfies some continuity conditions between adjacent polynomials.
In Python, we can use the CubicSpline
function from the scipy.interpolate
module to perform cubic spline interpolation.
The CubicSpline
function takes as input two arrays, x
and y
, that represent the x-coordinates and y-coordinates of the data points, respectively.
It then returns a CubicSpline
object that can be used to estimate the value of the function at any point within the interval defined by the data points.
Cubic Spline Method in Python:
import numpy as np
from scipy.interpolate import CubicSpline
#PROGRAM BY BOTTOM SCIENCE
# Define the data points
x = np.array([0.0, 0.2, 0.4, 0.6, 0.8, 1.0])
y = np.array([1.0000, 1.2214, 1.4918, 1.8221, 2.2255, 2.7183])
# Create a CubicSpline object with the data
cs = CubicSpline(x, y)
# Define the point where we want to estimate the function
x_new = 0.5
# Use the CubicSpline object to estimate the value of the function at x_new
Pn = cs(x_new)
# Print the estimated value of the function at x_new
print(f"Pn({x_new}) = {Pn}")
#Output - Pn(0.5) = 1.6604399999999984