I'm trying to solve an integral inside a for loop where the value of the integral changes with every loop.
Ni_1D = np.array([(x/2)*(x-1), x-x**2, (x/2)*(x+1)])
Tn= [10.0, 10.0, 10.0]
Tt=[0, 0, 0]
y_coor = [0.0, 1.25, 2.5]
x_coor = [4.0, 4.0, 4.0]
dN1D = np.array([x-.5, x-2*x, x+.5])
for i in range(3):
def f(x):
return Ni_1D[i]*(Tn[i]*y_coor[i]+Tt[i]*x_coor[i])* dN1D[i]
fx[i] = integrate.quad(f,-1,1)
But I keep getting the error "cannot convert expression to float." Obviously something is wrong with my first input to quad.
I can't figure out how to get the correct input for f for quad(). When I paste in the function manually everything works fine. For example for i=1 f=-x*(-12.5x**2 + 12.5x). When I define the function direction as -x*(-12.5x**2 + 12.5x) everything works fine.