以上边界为自变量进行积分

Integration with upper boundary as independent variable

我正在尝试定义一个以自变量为积分上限的函数:

from scipy import integrate

def integr(x):
    f = lambda y: 1 #example function
    value,_ = integrate.quad(f, 0, x)
    return value

为单个数字计算 integr 有效。但是,如果我想将它应用于一个数组以接收结果数组,则会返回一个值错误:

ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

你知道解决这个问题的方法吗?我需要对输入数组的值进行循环吗?

非常感谢!

我刚刚在另一个 post 中找到了答案。

x = np.linspace(0, 100) #example array
list(map(integr, x)))

很抱歉问了这么简单的问题,但我是 Python 的新手。