I have been looking for a Python function that allows me to calculate the integral of a piecewise linear function, but I haven't found one yet. This is what I mean:
I have two lists x = [x_1,x_2,x_3,..,x_n] and y=[y_1,y_2,y_3,...,y_n]; the list x is ordered, i.e., x_1<=x_2<=x_3<=...<=x_n. If I graph this with matplotlib I obtain the following:
import matplotlib.pyplot as plt
import matplotlib.markers
import numpy as np
x = np.array([0,1,1.2,2])
y = np.array([0,5,3,8])
plt.figure(figsize=(6,4),dpi=80)
plt.plot(x,y,marker='o')
plt.xlabel('x - axis')
plt.ylabel('y - axis')
plt.title('Input piecewise linear signal')
plt.grid(b = True)
plt.show()
Is there a way to compute the integral of this function given this two lists?
