from scipy.interpolate import interp1d import numpy as np x = np.array([0., 1., 3., 4.]) y = np.array([0., 4., 3., 2.]) f = interp1d(x, y) f(0.5) f(3.3) f(np.array([0.5, 1.5, 2.5, 3.5])) f(-1.) f = interp1d(x, y, bounds_error=False, fill_value=-10.) f(-1.0) f(np.array([-1., 1., 3., 6.])) f = interp1d(x, y, kind='cubic') f(0.5) def simple_function(x): return 3. * x**2 + 2. * x + 1. from scipy.integrate import quad print(quad(simple_function, 1., 2.)) x = np.linspace(1., 2., 1000) y = 3. * x**2 + 2. * x + 1. from scipy.integrate import simps print(simps(y, x=x)) from scipy.integrate import trapz print(trapz(y, x=x)) # your solution here # your solution here # your solution here