## 2020年1月13日月曜日

### 数学 - Python - 解析学 - 積分の計算 - 定積分の計算 - 部分積分法、置換積分、三角関数(逆正弦関数、逆正接関数、正弦、余弦)、対数関数、累乗、累乗根

1. $\begin{array}{l}x=\frac{a+b}{2}+t\\ \frac{b-a}{2}=h\end{array}$

とおくと、

$\begin{array}{l}{\int }_{a}^{b}\frac{\mathrm{dx}}{\sqrt{\left(x-a\right)\left(x-b\right)}}\\ \underset{\frac{3a+b}{2}}{\overset{\frac{a+3b}{2}}{\int }}\frac{\mathrm{dt}}{\sqrt{\left(\left(\frac{a+b}{2}+t\right)-a\right)\left(b-\left(\frac{a+b}{2}+t\right)\right)}}\\ =\underset{\frac{3a+b}{2}}{\overset{\frac{a+3b}{2}}{\int }}\frac{\mathrm{dt}}{\sqrt{\left(\frac{b-a}{2}+t\right)\left(\frac{b-a}{2}-t\right)}}\\ =\underset{\frac{3a+b}{2}}{\overset{\frac{a+3b}{2}}{\int }}\frac{\mathrm{dt}}{\sqrt{\left(h+t\right)\left(h-t\right)}}\\ =\underset{\frac{3a+b}{2}}{\overset{\frac{a+3b}{2}}{\int }}\frac{\mathrm{dt}}{\sqrt{{h}^{2}-{t}^{2}}}\mathrm{dt}\\ ={\left[\mathrm{arcsin}\frac{t}{h}\right]}_{\frac{3a+b}{2}}^{\frac{a+3b}{2}}\\ =\mathrm{arcsin}\frac{a+3b}{2h}-\mathrm{arcsin}\frac{3a+b}{2h}\\ =\mathrm{arcsin}\frac{a+3b}{2}·\frac{2}{b-a}-\mathrm{arcsin}\frac{3a+b}{2}·\frac{2}{b-a}\\ =\mathrm{arcsin}\frac{a+b}{b-a}-\mathrm{arcsin}\frac{3a+b}{b-a}\end{array}$

2. $\begin{array}{l}\alpha <1\\ \int \frac{\mathrm{log}x}{{x}^{\alpha }}\mathrm{dx}\\ =\frac{{x}^{1-\alpha }}{1-\alpha }\mathrm{log}x-\int \frac{{x}^{1-\alpha }}{1-\alpha }·\frac{1}{x}\mathrm{dx}\\ =\frac{1}{1-\alpha }\left({x}^{1-\alpha }\mathrm{log}x-\int {x}^{-\alpha }\mathrm{dx}\right)\\ =\frac{1}{1-\alpha }\left({x}^{1-\alpha }\mathrm{log}x-\frac{{x}^{1-\alpha }}{1-\alpha }\right)\\ {\int }_{0}^{1}\frac{\mathrm{log}x}{{x}^{x}}\mathrm{dx}\\ =\frac{1}{1-\alpha }\underset{b\to +0}{\mathrm{lim}}{\left[{x}^{1-\alpha }\mathrm{log}x-\frac{{x}^{1-\alpha }}{1-\alpha }\right]}_{b}^{1}\\ =\frac{1}{1-\alpha }\underset{b\to +0}{\mathrm{lim}}\left(-\frac{1}{1-\alpha }-{b}^{1-\alpha }\mathrm{log}b+\frac{{b}^{1-\alpha }}{1-\alpha }\right)\\ =\frac{1}{1-\alpha }\left(-\frac{1}{1-\alpha }\right)\\ =-\frac{1}{{\left(1-\alpha \right)}^{2}}\end{array}$

3. $\begin{array}{l}\sqrt{\frac{1+x}{1-x}}=t\\ \frac{\mathrm{dt}}{\mathrm{dx}}=\frac{\frac{\sqrt{1-x}}{2\sqrt{1+x}}+\frac{\sqrt{1+x}}{2\sqrt{1-x}}}{1-x}\\ =\frac{1-x+1+x}{2\left(1-x\right)\sqrt{1-{x}^{2}}}\\ =\frac{1}{\left(1-x\right)\sqrt{1-{x}^{2}}}\\ \frac{1+x}{1-x}={t}^{2}\\ 1+x={t}^{2}\left(1-x\right)\\ x=\frac{{t}^{2}-1}{{t}^{2}+1}\\ \int \frac{\mathrm{dx}}{\left(1-2ax+{a}^{2}\right)\sqrt{1-{x}^{2}}}\\ =\int \frac{1-x}{1-2ax+{a}^{2}}\mathrm{dt}\\ =\int \frac{1-\frac{{t}^{2}-1}{{t}^{2}+1}}{1-2a·\frac{{t}^{2}-1}{{t}^{2}+1}+{a}^{2}}\mathrm{dt}\\ =\int \frac{{t}^{2}+1-\left({t}^{2}-1\right)}{{t}^{2}+1-2a\left({t}^{2}-1\right)+{a}^{2}\left({t}^{2}+1\right)}\mathrm{dt}\\ =2\int \frac{\mathrm{dt}}{\left({a}^{2}-2a+1\right){t}^{2}+{a}^{2}+2a+1}\\ =2\int \frac{\mathrm{dt}}{{\left(a-1\right)}^{2}{t}^{2}+{\left(a+1\right)}^{2}}\\ =\frac{2}{{\left(a-1\right)}^{2}}\int \frac{\mathrm{dt}}{{t}^{2}+{\left(\frac{a+1}{a-1}\right)}^{2}}\\ =\frac{2}{{\left(a-1\right)}^{2}}·\frac{a-1}{a+1}\mathrm{arctan}\frac{a-1}{a+1}t\\ =\frac{2}{{a}^{2}-1}\mathrm{arctan}\frac{a-1}{a+1}t\\ {\int }_{-1}^{1}\frac{\mathrm{dx}}{\left(1-2ax+{a}^{2}\right)\sqrt{1-{\lambda }^{2}}}\\ =\frac{2}{{a}^{2}-1}\underset{b\to \infty }{\mathrm{lim}}{\left[\mathrm{arctan}\frac{a-1}{a+1}t\right]}_{0}^{b}\\ =\frac{2}{{a}^{2}-1}\underset{b\to \infty }{\mathrm{lim}}\mathrm{arctan}\frac{a-1}{a+1}b\\ =\left|\frac{2}{{a}^{2}-1}\frac{\pi }{2}\right|\\ =\frac{\pi }{\left|{a}^{2}-1\right|}\\ \left|a\right|\ne 1\end{array}$

4. $\begin{array}{l}\underset{0}{\overset{\frac{\pi }{2}}{\int }}\frac{\mathrm{sin}\theta }{\mathrm{sin}\theta +\mathrm{cos}\theta }d\theta \\ =\underset{0}{\overset{\frac{\pi }{2}}{\int }}\left(1-\frac{\mathrm{cos}\theta }{\mathrm{sin}\theta +\mathrm{cos}\theta }\right)d\theta \\ =\frac{\pi }{2}-\underset{0}{\overset{\frac{\pi }{2}}{\int }}\frac{\mathrm{cos}\theta }{\mathrm{sin}\theta +\mathrm{cos}\theta }d\theta \\ =\frac{\pi }{2}-\underset{0}{\overset{\frac{\pi }{2}}{\int }}\frac{\mathrm{sin}\theta }{\mathrm{sin}\theta +\mathrm{cos}\theta }d\theta \\ \underset{0}{\overset{\frac{\pi }{2}}{\int }}\frac{\mathrm{sin}\theta }{\mathrm{sin}\theta +\mathrm{cos}\theta }d\theta =\frac{1}{2}·\frac{\pi }{2}=\frac{\pi }{4}\end{array}$

コード

#!/usr/bin/env python3
from unittest import TestCase, main
from sympy import symbols, Integral, sqrt, pi, log, sin, cos, plot

print('5.')

x = symbols('x')

class MyTestCase(TestCase):
def test1(self):
a = 1
b = 2
self.assertEqual(Integral(1 / sqrt((x - a) * (b - x)), (x, a, b)).doit(),
pi)

def test2(self):
alpha = -1
self.assertEqual(Integral(log(x) / x ** alpha, (x, 0, 1)).doit(),
-1 / (1 - alpha) ** 2)

def test3(self):
a = 2
self.assertEqual(float(Integral(1 / ((1 - 2 * a * x + a ** 2) * sqrt(1 - x ** 2)),
(x, -1, 1)).doit()),
float(pi / abs(1 - a ** 2)))

def test4(self):
self.assertEqual(Integral(sin(x) / (sin(x) + cos(x)), (x, 0, pi / 2)).doit(),
pi / 4)

p = plot(1 / sqrt((x - 1) * (2 - x)),
log(x) / x ** -2,
1 / ((1 - 2 * 3 * x + 3 ** 2) * sqrt(1 - x ** 2)),
sin(x) / (sin(x) + cos(x)),
cos(x) / (sin(x) + cos(x)),
(x, -5, 5),
ylim=(-5, 5),
legend=True,
show=False)

colors = ['red', 'green', 'blue', 'brown', 'orange',
'purple', 'pink', 'gray', 'skyblue', 'yellow']

for o, color in zip(p, colors):
o.line_color = color

p.show()
p.save('sample5.png')

if __name__ == '__main__':
main()


% ./sample5.py -v
5.
test1 (__main__.MyTestCase) ... ok
test2 (__main__.MyTestCase) ... ok
test3 (__main__.MyTestCase) ... ok
test4 (__main__.MyTestCase) ... ok

----------------------------------------------------------------------
Ran 4 tests in 18.068s

OK
%