## 2019年11月30日土曜日

### 数学 - Python - 解析学 - 積分法 - 不定積分、広義積分 - 逆三角関数(逆正弦関数、逆正接関数)

1. $\begin{array}{l}{\int }_{0}^{a}\frac{\mathrm{dx}}{\sqrt{{a}^{2}-{x}^{2}}}\\ =\underset{b\to a-}{\mathrm{lim}}\underset{0}{\overset{b}{\int }}\frac{\mathrm{dx}}{\sqrt{{a}^{2}-{x}^{2}}}\\ =\underset{b\to a-}{\mathrm{lim}}{\left[\mathrm{arcsin}\left(\frac{x}{a}\right)\right]}_{0}^{b}\\ =\underset{b\to a-}{\mathrm{lim}}\left(\mathrm{arcsin}\frac{b}{a}-\mathrm{arcsin}0\right)\\ =\mathrm{arcsin}1\\ =\frac{\pi }{2}\end{array}$

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

コード

#!/usr/bin/env python3
from unittest import TestCase, main
from sympy import pprint, symbols, Integral, Derivative, pi, oo, sqrt, plot

print('1.')

x = symbols('x', real=True)
a = symbols('x', positive=True)

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

def test_arctan(self):
self.assertEqual(Integral(1 / (a ** 2 + x ** 2),
(x, -oo, oo)).doit(), pi / a)

p = plot((1 / sqrt(1 - x ** 2), (x, -0.9, 0.9)),
(1 / 1 + x ** 2, (x, -2, 2)),
ylim=(0, 4),
show=False,
legend=True)

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('sample1.png')

if __name__ == '__main__':
main()


% ./sample1.py -v
1.
test_arcsin (__main__.MyTestCase) ... ok
test_arctan (__main__.MyTestCase) ... ok

----------------------------------------------------------------------
Ran 2 tests in 0.335s

OK
%