下面的代码段是关于Computes the integral with Gauss-Legendre quadrature using m nodes in Python的代码。
## module gaussQuad
''' I = gaussQuad(f,a,b,m).
Computes the integral of f(x) from x = a to b
with Gauss-Legendre quadrature using m nodes.
'''
def gaussQuad(f,a,b,m):
c1 = (b + a)/2.0
c2 = (b - a)/2.0
x,A = gaussNodes(m)
sum = 0.0
for i in range(len(x)):
网友评论