It's not completely clear from your question what you're trying to do. But here's how I interpreted it: You have a double integral over two variables u
and xx
, which also takes two parameters xi
and yi
. You want to evaluate the integral over xx
and u
at many different values of xi
and yj
, and store these values in T
. Assuming this is what you want to do (and correct me if I'm wrong), here's how I would do it.
import numpy as np
from scipy.integrate import dblquad
b = 50.0
x = np.linspace(-10, 10, 1000)
y = np.linspace(0, 10, 1000)
def f(xx, u, xi, yj):
return ((np.exp(u * (b - yj)) - np.exp(-u * (b - yj))) /
(np.exp(u * b) - np.exp(-u * b)) * np.cos(u * (xx - xi)))
T = np.zeros([len(x), len(y)])
for i, xi in enumerate(x):
for j, yj in enumerate(y):
T[i, j] += dblquad(
f, -10, 10, lambda x: 0.1, lambda x: 10, args=(xi, yj))[0]