I am currently trying to compute the definite integral of a interpolated polynomial multiplied by a cosinus function. Here are the lines with the construction of the polynomial :
x_table = [0. 0.088375 0.17675 0.265125 0.3535 ]
result = [698.15 557.84796934 443.76849088 371.01657964 341.86988949]
x_points = x_table
y_points = result
coefficients = np.polyfit(x_points, y_points, len(x_points) - 1)
p = Polynomial(coefficients[::-1]) # inversion of the coefficient
And what I want to do is to calculate the definite integral from 0 to L of this p polynomial multiplied by a cosinus. I called this product p_cos in my code. I tried the integrate method from sympy but it doesn’t work…
x = symbols('x')
L = 0.3535
b_res = [9.42629366521645, 18.058169746130034, 26.852632148686432, 35.6924546755864]
for m in range(1, 5):
p_cos = p*np.cos(b_res[m-1]*x)
integral_p_cos = sp.integrate(p_cos, (x, 0, L))
Do you have an idea of a method to integrate this p_cos expression from 0 to L ?