## 2020年7月28日火曜日

### 数学 - Python - 微分積分学 - 積分法 - 不定積分の計算 - 平方根、立方根、累乗

1. $\int \frac{\mathrm{dx}}{\sqrt{a-bx}}=-\frac{2\sqrt{a-bx}}{b}$

2. $\int x{\left({a}^{2}+{x}^{2}\right)}^{2}\mathrm{dx}=\frac{{\left({a}^{2}+{x}^{2}\right)}^{2}}{2}$

3. $\int \frac{{x}^{2}\mathrm{dx}}{\sqrt{{x}^{3}+3}}=\frac{2\sqrt{{x}^{3}+3}}{3}$

4. $\int \frac{{\left(\sqrt{a}-\sqrt{x}\right)}^{2}}{\sqrt{x}}\mathrm{dx}=-\frac{2{\left(\sqrt{a}-\sqrt{x}\right)}^{3}}{3}$

5. $\int \frac{2x+1}{\sqrt{{x}^{2}+x+1}}\mathrm{dx}=2\sqrt{{x}^{2}+x+1}$

6. $\int \frac{{x}^{2}+2}{{\left({x}^{3}+6x+5\right)}^{\frac{1}{3}}}\mathrm{dx}=\frac{{\left({x}^{3}+6x+5\right)}^{\frac{2}{3}}}{2}$

コード

#!/usr/bin/env python3
from unittest import TestCase, main
from sympy import sqrt, root, Rational, Derivative
from sympy.abc import x, a, b

print('3, 4, 5, 6, 7, 8.')

class Test(TestCase):
def test1(self):
fs = [1 / sqrt(a - b * x),
x * (a ** 2 + x ** 2) ** 2,
x ** 2 / sqrt(x ** 3 + 3),
(sqrt(a) - sqrt(x)) ** 2 / sqrt(x),
(2 * x + 1) / sqrt(x ** 2 + x + 1),
(x ** 2 + 2) / root(x ** 3 + 6 * x + 5, 3)]
gs = [- 2 * sqrt(a - b * x) / b,
(a ** 2 + x ** 2) ** 3 / 6,
2 * sqrt(x ** 3 + 3) / 3,
-2 * (sqrt(a) - sqrt(x)) ** 3 / 3,
2 * sqrt(x ** 2 + x + 1),
(x ** 3 + 6 * x + 5) ** Rational(2, 3) / 2]
for i, (f, g) in enumerate(zip(fs, gs), 3):
print(f'({i})')
self.assertEqual(f.expand(), Derivative(g, x, 1).doit().expand())

if __name__ == "__main__":
main()


% ./sample3.py -v
3, 4, 5, 6, 7, 8.
test1 (__main__.Test) ... (3)
(4)
(5)
(6)
(7)
(8)
ok

----------------------------------------------------------------------
Ran 1 test in 0.091s

OK
%