I am trying to implement the Galerkin discontinous method in Python to solve Partial Differential Equations. This method involves solving a large number of systems of ordinary differential equations with the form
where the matrix $M^i$ is definied by the $L^2$ product, i.e. each entry of the matrix is an integral of the product of two functions $N_k$, and $N_l$, that is
where $I_i=[-1,1]$.
To do these integrals, I have defined the function DotProduct(G, H) as follows
from scipy.integrate import quad
def DotProduct(G, H):
F = lambda x:G(x)*H(x)
w = quad(F, -1.0, 1.0)[0]
return w
The use of this function is as follows
f01 = lambda x: 0.5*(1-x)
f11 = lambda x: 0.5*(1+x)
Integral = DotProduct(f01, f11)
print(Integral)
My problem is that 90% of the execution time of the code is dedicated to calculating these integrals.
I've read about speeding up the computation time for integrals using numba, but have had no success implementing it in the function DotProduct(G, H).
Does anyone have any advice?