### 示例

quadscipy.integrate中最常用的积分函数，示例如下

import numpy as np

func = lambda x: x**2
# (21.333333333333332, 2.3684757858670003e-13)
# (2.0, 2.220446049250313e-14)


0

4

x

2

d

x

=

1

3

x

3

0

4

=

64

3

21.3

0

π

sin

x

d

x

=

cos

x

0

π

=

2

int_0^4 x^2text dx=frac{1}{3}x^3big|^4_0=frac{64}{3}approx 21.3\ int^pi_0sin xtext dx=-cos xbig|^pi_0=2

04x2dx=31x3

04=36421.30πsinxdx=cosx

0π=2

### 完整参数

quad的完整参数如下

scipy.integrate.quad(func, a, b, args=(), full_output=0, epsabs=1.49e-08, epsrel=1.49e-08, limit=50, points=None, weight=None, wvar=None, wopts=None, maxp1=50, limlst=50, complex_func=False)


• argsfunc函数中，除待求积分参数之外的其他参数
• epsabs, epsrel 分别为绝对和相对误差
• limit 自适应算法中子区间的个数
• points 断点位置
• weight, wvar 定义域区间内的权重类型和权重
• wopts, maxp1 切比雪夫矩及其上限

### weight参数

weight wvar 函数
“cos”

w

w

cos

w

x

cos wx

“sin”

w

w

sin

w

x

sin wx

“alg”

α

,

β

alpha, beta

g

(

x

)

g(x)

“alg-loga”

α

,

β

alpha, beta

g

(

x

)

log

(

x

a

)

g(x)log(x-a)

“alg-logb”

α

,

β

alpha, beta

g

(

x

)

log

(

b

x

)

g(x)log(b-x)

“alg-log”

α

,

β

alpha, beta

g

(

x

)

log

(

x

a

)

log

(

b

x

)

g(x)log(x-a)log(b-x)

“cauchy”

c

c

1

x

c

frac{1}{x-c}

g

(

x

)

=

(

x

a

)

α

(

b

x

)

β

g(x)=(x-a)^alpha*(b-x)^beta

g(x)=(xa)α(bx)β

func

f

(

x

)

=

x

f(x)=x

f(x)=x，若weight参数为cos，而wvar取值为

w

w

w，则实际计算的积分表达式为

a

b

cos

w

f

(

x

)

d

x

int_a^bcos wf(x)text dx

abcoswf(x)dx

func = lambda x : x