I want to compute an integral of the form: .
I am struggling to implement this in python. Is there a programic way to accomplish this? I tried doing this with several for loops but I'm stuck on the error SystemError: too many statically nested blocks
.
fs = {}
for i in range(100):
fs[i] = lamda x: x*i
for x1 in np.arange(0,1,.01):
for x2 in np.arange(0,1,.01):
....
for x100 in np.arange(0,1,.01):
for i in range(100):
exec("summ+= fs[i](x%i"%i)
Of course it is slow: The "for i in range(100)" (1) part is reached 100 * 100 * 100 * ... * 100 (100 '*100's) = 100 ^ 100; and people say n^2 is bad... Anyways I would do it like this:
- Put 100 values initialized with 0 into a list.
- for i = 0 to 100 ^ 100:
- go through the list and use the k-th value as the parameter for the k-th function. do the summing thing
- Add 0.1 to the n-th value in the list;
if this value is now == 1; set it to 0 and go to the (n+1)-th value and repeat this procedure until you reach the end of the list or one value is < 1.
Start with the first value in the list.
now you have your sum.