由 for 循环链接的多项式给出“最大递归深度超出”消息

问题描述

import numpy as np
import matplotlib.pyplot as plt
import math
from scipy import integrate

c=np.array([1,4,2,4])

f=lambda x: 0 
for n in range (c.shape[0]):
   f=lambda x: f(x) + c[n]*x**n 

I=integrate.quad(f,2)
print(I)

我想通过 for 循环从各个项构建多项式函数,然后对它们进行积分。

如果我查询“f”是什么,那么也会显示ma​​in.(x)>。 而“n”也跑到了3。 但是一旦你想使用这个功能,例如写

f(2)

或者如果你使用命令

integrate.quad(f,2)

然后出现消息“超出最大递归深度”。

你能帮我或给我一个简单的例子吗?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)