I need to calculate deterministically the following sum in python using numeric methods.
I have the following function:
Is there any analogue of scipy.integrate.tplquad
that can calculate so many integrals?
Using sympy
import sympy as sym
x = sym.symbols('x1:11')
expr = sym.prod(x) * sym.exp(-sum(x))
integral = sym.integrate(expr, *((xi, 0, 1) for xi in x))
print(integral)
will show you the explicit expression, though integral.factor()
will show you a neater form.
(-2 + E)**10*exp(-10) # E is the mathematical constant
You can also evaluate that whatever precision you want.
>>> integral.evalf() # this can take an argument `n` for precision digits
1.65960210179703e-6