[Python] Computes the integral with Gauss-Legendre quadratu →→→→→进入此内容的聊天室

来自 , 2020-08-22, 写在 Python, 查看 135 次.
URL http://www.code666.cn/view/85f33757
  1. ## module gaussQuad
  2. ''' I = gaussQuad(f,a,b,m).
  3.    Computes the integral of f(x) from x = a to b
  4.    with Gauss-Legendre quadrature using m nodes.
  5. '''
  6. from gaussNodes import *
  7.  
  8. def gaussQuad(f,a,b,m):
  9.     c1 = (b + a)/2.0
  10.     c2 = (b - a)/2.0
  11.     x,A = gaussNodes(m)
  12.     sum = 0.0
  13.     for i in range(len(x)):
  14.         sum = sum + A[i]*f(c1 + c2*x[i])
  15.     return c2*sum
  16. #//python/7426

回复 "Computes the integral with Gauss-Legendre quadratu"

这儿你可以回复上面这条便签

captcha