我试图在python中实现5d积分,但是在为nqad定义参数时是否遇到语法错误:
import numpy as np
import math
from scipy.integrate import nquad
import time
#
# Integrand
#
def f(*args):
x1, x2, x3, x4, x5 = args
return math.exp(0.5*x1**2(2 + math.sin(14))) + math.exp(0.25*x2**2(2 + math.sin(13))) + math.exp(0.1*x3**2(2 + math.sin(12))) + math.exp(0.1*x4**2(2 + math.sin(11)) + math.exp(0.1*x5**2(2 + math.sin(10)))
ans = nquad(f,[[0,1] [0,1,],[0,1],[0,1],[0,1]])
print("5D Integral between 0 and 1 = ", ans)
谁能解释一下我哪里出错了
代码中有各种语法错误
return
的末尾缺少一个括号return
中没有*
符号进行乘法,这将导致TypeError: int object is not callable
。因为python将尝试像函数一样调用李>nquad()
的列表中缺少,
李>固定代码
相关问题 更多 >
编程相关推荐