## 2019年12月25日水曜日

### 数学 - Python - 解析学 - 積分の計算 - 不定積分の計算 - 置換積分法、平方根

1. 以下積分定数は省略。

$\begin{array}{l}\int \sqrt{{x}^{2}+a}\mathrm{dx}\\ =x\sqrt{{x}^{2}+a}-\int x·\frac{1}{2}·\frac{2x}{\sqrt{{x}^{2}+a}}\mathrm{dx}\\ =x\sqrt{{x}^{2}+a}-\int \frac{{x}^{2}}{\sqrt{{x}^{2}+a}}\mathrm{dx}\\ =x\sqrt{{x}^{2}+a}-\int \frac{{x}^{2}+a-a}{\sqrt{{x}^{2}+a}}\mathrm{dx}\\ =x\sqrt{{x}^{2}+a}-\int \left(\sqrt{{x}^{2}+a}-\frac{a}{\sqrt{{x}^{2}+a}}\right)\mathrm{dx}\\ =x\sqrt{{x}^{2}+a}-\int \sqrt{{x}^{2}+a}\mathrm{dx}+a\int \frac{1}{\sqrt{{x}^{2}+a}}dx\\ \int \sqrt{{x}^{2}+a}\mathrm{dx}\\ =\frac{1}{2}\left(x\sqrt{{x}^{2}+a}-a\int \frac{1}{\sqrt{{x}^{2}+a}}\mathrm{dx}\right)\\ =\frac{1}{2}\left(x\sqrt{{x}^{2}+a}-a\mathrm{log}\left|x+\sqrt{{x}^{2}+a}\right|\right)\end{array}$

2. $\begin{array}{l}\int \sqrt{\frac{1-x}{1+x}}\mathrm{dx}\\ =\int \frac{1-x}{\sqrt{1-{x}^{2}}}\mathrm{dx}\\ =\int \frac{1}{\sqrt{1-{x}^{2}}}\mathrm{dx}-\int \frac{x}{\sqrt{1-{x}^{2}}}\mathrm{dx}\\ =\mathrm{arcsin}x-\mathrm{log}\sqrt{1-{x}^{2}}\end{array}$

3. $\begin{array}{l}x=\frac{1}{t}\\ t=\frac{1}{x}\end{array}$

とおき、 x で微分すると、

$\frac{\mathrm{dt}}{\mathrm{dx}}=-\frac{1}{{x}^{2}}$

よって、

$\begin{array}{l}\int \frac{1}{x\sqrt{{x}^{2}+1}}\mathrm{dx}\\ =\int \frac{1}{x\sqrt{{x}^{2}+1}}\left(-{x}^{2}\right)\mathrm{dt}\\ =\int \frac{-x}{\sqrt{{x}^{2}+1}}\mathrm{dt}\\ =\int \frac{-\frac{1}{t}}{\sqrt{\frac{1}{{t}^{2}}+1}}\mathrm{dt}\\ =\int \frac{-1}{\sqrt{1+{t}^{2}}}\mathrm{dt}\\ =\int \frac{t-\sqrt{1+{t}^{2}}}{\sqrt{1+{t}^{2}}\left(\sqrt{1+{t}^{2}}-t\right)}\mathrm{dt}\\ \int \left(\frac{t}{\sqrt{1+{t}^{2}}}-1\right)\frac{1}{\sqrt{1+{t}^{2}}-1}\mathrm{dt}\\ =\mathrm{log}\left(\sqrt{1+{t}^{2}}-t\right)\\ =\mathrm{log}\left(\sqrt{1+\frac{1}{{x}^{2}}}-\frac{1}{x}\right)\\ =\mathrm{log}\frac{\sqrt{{x}^{2}+1}-1}{x}\end{array}$

4. $\sqrt{\frac{x+1}{x-1}}=t$

とおくと、

$\begin{array}{l}\frac{\mathrm{dt}}{\mathrm{dx}}\\ =\frac{\frac{\sqrt{x-1}}{2\sqrt{x+1}}-\frac{\sqrt{x+1}}{2\sqrt{x-1}}}{x-1}\\ =\frac{x-1-x-1}{2\left(x-1\right)\sqrt{{x}^{2}-1}}\\ =\frac{-1}{\left(x-1\right)\sqrt{{x}^{2}-1}}\end{array}$

よって、

$\begin{array}{l}x>1\\ \int \frac{1}{\left(x-1\right)\sqrt{{x}^{2}-1}}\mathrm{dx}\\ =-\int 1\mathrm{dt}\\ =-t\\ =-\frac{\sqrt{x+1}}{\sqrt{x-1}}\end{array}$

コード

#!/usr/bin/env python3
from sympy import pprint, symbols, Integral, sqrt, plot

print('3.')

x, a = symbols('x, a')
fs = [sqrt(x ** 2 + a),
sqrt((1 - x) / (1 + x)),
1 / (x * sqrt(x ** 2 + 1)),
1 / ((x - 1) * sqrt(x ** 2 - 1))]

for i, f in enumerate(fs, 1):
print(f'({i})')
I = Integral(f, x)
for o in [I, I.doit()]:
pprint(o)
print()

p = plot(*[f.subs({a: 2}) for f in fs],
ylim=(-10, 10),
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('sample3.png')


% ./sample3.py
3.
(1)
⌠
⎮    ________
⎮   ╱      2
⎮ ╲╱  a + x   dx
⌡

________
╱      2
╱      x            ⎛x ⎞
√a⋅x⋅  ╱   1 + ──    a⋅asinh⎜──⎟
╲╱        a            ⎝√a⎠
────────────────── + ───────────
2                 2

(2)
⌠
⎮     _______
⎮    ╱ 1 - x
⎮   ╱  ─────  dx
⎮ ╲╱   x + 1
⌡

⌠
⎮     _______
⎮    ╱ 1 - x
⎮   ╱  ─────  dx
⎮ ╲╱   x + 1
⌡

(3)
⌠
⎮       1
⎮ ───────────── dx
⎮      ________
⎮     ╱  2
⎮ x⋅╲╱  x  + 1
⌡

⎛1⎞
-asinh⎜─⎟
⎝x⎠

(4)
⌠
⎮          1
⎮ ─────────────────── dx
⎮            ________
⎮           ╱  2
⎮ (x - 1)⋅╲╱  x  - 1
⌡

⌠
⎮              1
⎮ ─────────────────────────── dx
⎮   _________________
⎮ ╲╱ (x - 1)⋅(x + 1) ⋅(x - 1)
⌡

%


(4)の積分は求められてないし、SymPyには苦手な積分、不定積分があるみたい。