sympy
always succeedssympy
then returns an Integral
object instead of a number)
def element_vector(f, phi, Omega_e, symbolic=True):
...
I = sp.integrate(f*phi[r]*detJ, (X, -1, 1)) # try...
if isinstance(I, sp.Integral):
h = Omega_e[1] - Omega_e[0] # Ensure h is numerical
detJ = h/2
integrand = sp.lambdify([X], f*phi[r]*detJ)
I = sp.mpmath.quad(integrand, [-1, 1])
b_e[r] = I
...