擅长:python、mysql、java
<p>sth基于<code>polyval()</code>的方法看起来是最好的答案(因为您已经可以访问该函数),但是如果您想实现自己的等效函数,那么该函数看起来更像:</p>
<pre><code>def poly(coeffs):
def calc(x)
result = 0
for i,c in enumerate(reversed(coeffs)):
result += c*(x**i)
return result
return calc
findroot(poly([1,2,0]))
</code></pre>