Riemann积分有两个局限:一是积分区间[a, b]必须有限;二是被积函数f(x)在积分区间[a, b]上有界。而反常积分(Improper Integral)就是对Riemann积分这两个局限的扩展,前者扩展后被称为“无穷积分”,后者扩展后被称为“瑕积分”。
本节的内容属于“微积分的扩展”,课程中介绍的本就不太详细,主要讨论反常积分的“敛散性”我就不作扩展了,仅用Python辅助,展示课后练习和单元测试的解答。
#Exercise 7-7-1
from sympy import *
init_printing()
x = Symbol('x')
f = 1 / (1 + E ** x) ** 2
f, integrate(f, (x, 0, +oo))
(1(ex+1)2,−12+log(2))
#Exercise 7-7-2
x = Symbol('x')
f = 1 / (x ** 2 + 4 * x + 9)
f, integrate(f, (x, -oo, +oo))
(1x2+4x+9,5√π5)
#Exercise 7-7-3
x = Symbol('x')
f = log(x) / (1 + x) ** 2
f, integrate(f, (x, 0, +oo))
(log(x)(x+1)2,0)
#Exercise 7-7-4
x = Symbol('x')
f = 1 / sqrt(abs((1 - x)))
f1 = 1 / sqrt(1 - x)
f2 = 1 / sqrt(x - 1)
f, integrate(f1, (x, 0, 1)), integrate(f2, (x, 1, 2))
(1|x−1|−−−−−√,2,2)
#Exercise 7-7-4
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
#x = np.array(filter(lambda t:t != 1, np.linspace(0, 2))).flatten()
x = np.linspace(0, 2)
t = np.asarray([1]).repeat(x.size)
y = 1 / np.sqrt(np.abs((t - x)))
plt.plot(x,y)
plt.show()
Exercise 7-7-5
∫10x1−x−−−−−√dx=?
解:本题直接用sympy计算不出来,观察它的被积函数,其中含有2次根号,很容易相等“三角函数平方和/差公式”,令 x=sin2(t) ,得:
∫10x1−x−−−−−√dx=∫π20tan(t)d[sin2(t)]=2∫π20sin2(t)dt
#Exercise 7-7-3
x = Symbol('x')
f = sin(x) ** 2
2 * integrate(f, (x, 0, pi / 2))
π2
Exercise 7-7-6
∫+∞0dx(x+1)x2+1−−−−−√=?
解:同样地,用三角函数换元法
∫+∞0dx(x+1)x2+1−−−−−√=∫π20cos2(t)d[tan(t)]sin(t)+cos(t)=∫π20dtsin(t)+cos(t)=∫π20dt2√sin(t+π4)
#Exercise 7-7-6
x = Symbol('x')
f = 1 / (sqrt(2) * sin(x + pi / 4))
integrate(f, (x, 0, pi / 2))
2√2log(2√(2√2+1))−2√2log(2√(−2√2+1))
Exercise 7-7-1b
∫+∞2dxxlnp(x)
若上式收敛,求p的范围
解:运用“比阶判别法的极限形式”
limx→+∞xqf(x)=limx→+∞xq−1lnp(x)
要是这个极限存在,则 p≥q−1>1−1=0
Exercise 7-7-2b
∫+∞2dxx+x2+2−−−−−√
解:先看被积函数的性质
f(x)=1x+x2+2−−−−−√=12(x2+2−−−−−√−x)
f′(x)=12(xx2+2−−−−−√−1)=x−x2+2−−−−−√2x2+2−−−−−√<0
limx→+∞f(x)=0
因此,f(x)单调递减,且有下界,必收敛
运用“比阶判别法的极限形式”
limx→+∞xqf(x)=limx→+∞xpx+x2+2−−−−−√
p=1时,这个极限值存在且不等于0,故该无穷积分发散
Exercise 7-7-3b
∫10ln(x)dx
解:运用瑕积分收敛判断 (x−a)p
limx→0+xp∗ln(x)
当 p = -1 < 1 时,这个极限存在,故该瑕积分收敛
Exercise 7-7-4b
∫10ex1−x−−−−√dx
解:运用瑕积分收敛判断 (x−a)p
limx→0+xp∗ex1−x−−−−√=limx→0+xp
当 0 < p < 1 时,这个极限存在,故该瑕积分收敛
#Exercise 7-7-5b
from sympy import *
init_printing()
x = Symbol('x')
for n in range(-1, 3):f = x ** (n) * E ** (-x)F = integrate(f, x)print(limit(F, x, +oo))
0
0
0
0
Unit Test 4-1
解:本题考察被积函数与原函数的关系。可以利用变上限积分将被积函数与原函数联系起来,假设其中一个积分限 a = 0
F(−x)=∫−x0f(t)dt=∫x0f(−u)d(−u)=−∫x0f(−u)du
很明显,f(x)若为奇函数,F(x)将为偶函数。
#Unit Test 4-5
from sympy import *
init_printing()
x = Symbol('x')
f = cos(2 * x) / (1 + 1 / 2 * sin(2 * x))
integrate(f, x)
1.0log(0.5sin(2x)+1.0)
Unit Test 4-6
∫arctan1x1+x2dx=?
解:三角函数换元,令 x=tan(t),t=arctan(x)
∫arctan1x1+x2dx=∫arctan1tan(t)1+tan2(t)d[tan(t)]=∫arctan1tan(t)dt=∫(π2−t)dt
Unit Test 4-7
∫dxex(1+e2x)=?
解:先分解部分分式(partial fraction),再换元。其中分式分解也可以用sympy执行,如下代码
f(x)=1ex(1+e2x)=1ex−ex1+e2x
#Unit Test 4-7
from sympy import *
init_printing()
x = Symbol('x')
expr = 1 / (x * (1 + x ** 2))
apart(expr)
−xx2+1+1x
t = E ** x
f = 1 / t
g = 1 / (1 + x ** 2)
integrate(f, x), integrate(g, x), integrate(f, x) - integrate(g, x).subs(x, E ** x)
(−e−x,atan(x),−atan(ex)−e−x)
#Unit Test 4-8
from sympy import *
init_printing()
x = Symbol('x')
f = 1 / (x ** 2 + 2 * x + 5)
integrate(f, x)
12atan(x2+12)
Unit Test 4-9
∫xdx(1+x2)1−x2−−−−−√=?
解:先凑微分,再三角函数替换。
∫xdx(1+x2)1−x2−−−−−√=∫dsin2(t)2[1+sin2(t)]1−sin2(t)−−−−−−−−−√=∫sin(t)cos(t)dt[1+sin2(t)]cos(t)=−∫dcos(t)2−cos2(t)
注意,本题经过了两次换元,求出原函数后要换回去,如下代码
#Unit Test 4-9
from sympy import *
init_printing()
x = Symbol('x')
f = - 1 / ( 2 - x ** 2)
integrate(f, x).subs(x, cos(x)).subs(x, asin(x))
2√4log(−x2+1−−−−−−−√−2√)−2√4log(−x2+1−−−−−−−√+2√)
Unit Test 4-10
∫x2−9−−−−−√x2dx=?
解:先有理化,再三角换元
∫x2−9−−−−−√x2dx=∫uu2+9du2+9−−−−−√=∫3tan(θ)9tan2θ+9d9tan2θ+9−−−−−−−−−√=∫tan(θ)sec2θdsec(θ)=∫sin2θcos(θ)dθ=∫1cos(θ)dθ−∫cos(θ)dθ
#Unit Test 4-10
from sympy import *
init_printing()
x = Symbol('x')
f = 1 / cos(x) - cos(x)
integrate(f, x).subs(x, atan(1 / 3 * x)).subs(x, sqrt(x ** 2 - 9))
−1.0x2−−√x2−9−−−−−√−12log(1.0x2−−√x2−9−−−−−√−1)+12log(1.0x2−−√x2−9−−−−−√+1)
#Unit Test 4-11
from sympy import *
init_printing()
x = Symbol('x')
f = 1 / (1 + x + x ** 2)
integrate(f, x).subs(x, 2 ** x) / log(2)
23√atan(23√32x+3√3)3log(2)
Unit Test 4-12
In=∫dxxnx2+1−−−−−√
求上式的递推公式
解:很显然,要应用“分部积分法”
In−2=∫dxxn−2x2+1−−−−−√=∫dx2+1−−−−−√xn−1=x2+1−−−−−√xn−1−∫x2+1−−−−−√dx1−n=x2+1−−−−−√xn−1+(n−1)∫x2+1−−−−−√xndx=x2+1−−−−−√xn−1+(n−1)∫x2+1xnx2+1−−−−−√dx=x2+1−−−−−√xn−1+(n−1)(In+In−2)
Unit Test 4-13
∫dxx(x10+1)=?
解:很显然,这是一个“Partial Fraction” (部分分式)的积分,要先进行分式分解
f(x)=1x(x10+1)=1x−x5x2+5−x(4x6−3x4+2x2−1)5x8−5x6+5x4−5x2+5
然后根据第二三项的特点进行“凑微分和换元”,凑成 x2
#Unit Test 4-13
from sympy import *
init_printing()
x = Symbol('x')
f = 1 / (x ** 11 + x)
apart(f), integrate(f, x)
(−x(4x6−3x4+2x2−1)5x8−5x6+5x4−5x2+5−x5x2+5+1x,log(x)−110log(x10+1))
#Unit Test 4-14
from sympy import *
init_printing()
x = Symbol('x')
f = (x ** 2 + 1) * E ** (2 * x)
integrate(f, x)
e2x4(2x2−2x+3)
#Unit Test 4-15
from sympy import *
init_printing()
x = Symbol('x')
f = x ** 2 * acos(x)
integrate(f, x)
x33acos(x)−x29−x2+1−−−−−−−√−29−x2+1−−−−−−−√
Unit Test 4-16
∫dxx√+x√3=?
解:先有理化
∫dxx√+x√3=∫dt6t3+t2=∫6x5dtt3+t2
#Unit Test 4-16
from sympy import *
init_printing()
x = Symbol('x')
f = 6 * x ** 5 / (x ** 2 + x ** 3)
integrate(f, x).subs(x, x ** (1 / 6))
6x0.166666666666667−3x0.333333333333333+2x0.5−6log(x0.166666666666667+1)
Unit Test 4-17
∫x+1x−−−−−√dx=?
解:先有理化
∫x+1x−−−−−√dx=∫tan2(t)+1tan2(t)−−−−−−−−−−√dtan2(t)
#Unit Test 4-17
from sympy import *
init_printing()
x = Symbol('x')
f = diff(tan(x) ** 2, x)
g = 2 / (cos(x) ** 3)
f, integrate(g, x).subs(x, atan(x))
⎛⎝⎜(2tan2(x)+2)tan(x),−2xx2+1−−−−−√(2x2x2+1−2)−12log(xx2+1−−−−−√−1)+12log(xx2+1−−−−−√+1)⎞⎠⎟
Unit Test 4-18
∫dxex+1−−−−−√+ex−1−−−−−√=?
解:先有理化,再分部积分
∫dxex+1−−−−−√+ex−1−−−−−√=∫ex+1−−−−−√−ex−1−−−−−√2dx=12∫ex+1−−−−−√dx−12∫ex−1−−−−−√dx=12∫tdln(t2−1)−12∫udln(u2+1)=12[t∗ln(t2−1)−∫ln(t2−1)dt−u∗ln(u2+1)+∫ln(u2+1)du]
#Unit Test 4-18
from sympy import *
init_printing()
x = Symbol('x')
f = log(x ** 2 -1)
g = log(x ** 2 + 1)
integrate(f, x), integrate(g, x)
(xlog(x2−1)−2x−log(x−1)+log(x+1),xlog(x2+1)−2x+2atan(x))
part1 = x * f - integrate(f, x)
part2 = x * g - integrate(g, x)
part1.subs(x, sqrt(E ** x + 1)) - part2.subs(x, sqrt(E ** x - 1))
−2ex−1−−−−−√+2ex+1−−−−−√+log(ex+1−−−−−√−1)−log(ex+1−−−−−√+1)+2atan(ex−1−−−−−√)
Unit Test 4-19
∫sin(x)1+sin(x)dx=?
解:简化分式
∫sin(x)1+sin(x)dx=∫dx−∫11+sin(x)dx
#Unit Test 4-19
from sympy import *
init_printing()
x = Symbol('x')
f = 1 / (sin(x) + 1)
integrate(f, x)
−2tan(x2)+1
Unit Test 4-20
∫x21+x2atan(x)dx=?
解:简化分式
∫x21+x2atan(x)dx=∫x2atan(x)datan(x)=12∫x2(x2+1)datan2(x)=12[x2(x2+1)∗atan2(x)−∫atan2(x)dx2(x2+1)]=12[x2(x2+1)∗atan2(x)−4∫atan2(x)∗x3dx−2∫atan2(x)∗xdx]
#Unit Test 4-19
from sympy import *
init_printing()
x = Symbol('x')
f = atan(x) ** 2 * x
integrate(f, x)
x22atan2(x)−xatan(x)+12log(x2+1)+12atan2(x)
g = f * x ** 2
integrate(g, x)
x44atan2(x)−x36atan(x)+x212+x2atan(x)−13log(x2+1)−14atan2(x)
simplify(atan(x) ** 2 * (x ** 4 + x ** 2) - 4 * integrate(g, x) - 2 * integrate(f, x))
2x33atan(x)−x23+13log(x2+1)