## 2020年8月7日金曜日

### 数学 - Python - 微分積分学 - 積分法 - 定積分の計算、部分積分法、累乗、累乗根

1. ${\int }_{0}^{a}\left({a}^{2}x-{x}^{3}\right)\mathrm{dx}$
$={\left[\frac{{a}^{2}}{2}{x}^{2}-\frac{1}{4}{x}^{4}\right]}_{0}^{a}$
$=\frac{{a}^{4}}{4}$

2. ${\int }_{0}^{a}{\left(\sqrt{a}-\sqrt{t}\right)}^{2}\mathrm{dt}$
$={\int }_{0}^{a}\left(a-2\sqrt{a}\sqrt{t}+t\right)\mathrm{dt}$
$={a}^{2}-2\sqrt{a}·\frac{2}{3}{\left[{t}^{\frac{3}{2}}\right]}_{0}^{a}+\frac{1}{2}{\left[{t}^{2}\right]}_{0}^{a}$
$={a}^{2}-\frac{4}{3}{a}^{2}+\frac{1}{2}{a}^{2}$
$=\frac{6-8+3}{6}{a}^{2}$
$=\frac{{a}^{2}}{6}$

3. ${\int }_{0}^{1}\frac{x\mathrm{dx}}{\sqrt{{x}^{2}+4}}$
$={\left[\sqrt{{x}^{2}+4}\right]}_{0}^{1}$
$=\sqrt{5}-2$

4. ${\int }_{0}^{1}{z}^{2}\sqrt{1-z}\mathrm{dz}$
$={\left[{z}^{2}\left(-\frac{2}{3}{\left(1-z\right)}^{\frac{3}{2}}\right)\right]}_{0}^{1}+\frac{4}{3}{\int }_{0}^{1}z{\left(1-z\right)}^{\frac{3}{2}}\mathrm{dz}$
$=\frac{4}{3}\left({\left[z\left(-\frac{2}{5}{\left(1-z\right)}^{\frac{5}{2}}\right)\right]}_{0}^{1}+\frac{2}{5}{\int }_{0}^{1}{\left(1-z\right)}^{\frac{5}{2}}\mathrm{dz}\right)$
$=\frac{4}{3}·\frac{2}{5}\left(-\frac{2}{7}\right){\left[{\left(1-z\right)}^{\frac{7}{2}}\right]}_{0}^{1}$
$=\frac{4}{3}·\frac{2}{5}·\frac{2}{7}$
$=\frac{16}{105}$

5. $\int \frac{{x}^{3}}{\sqrt{{x}^{2}+{a}^{2}}}\mathrm{dx}$
$={x}^{2}\sqrt{{x}^{2}+{a}^{2}}-\int 2x\sqrt{{x}^{2}+{a}^{2}}\mathrm{dx}$
$={x}^{2}\sqrt{{x}^{2}+{a}^{2}}-\frac{2}{3}{\left({x}^{2}+{a}^{2}\right)}^{\frac{3}{2}}$
${\int }_{0}^{a}\frac{{x}^{3}}{\sqrt{{x}^{2}+{a}^{2}}}\mathrm{dx}$
$={\left[{x}^{2}\sqrt{{x}^{2}+{a}^{2}}-\frac{2}{3}{\left({x}^{2}+{a}^{2}\right)}^{\frac{3}{2}}\right]}_{0}^{a}$
$=\sqrt{2}{a}^{3}-\frac{2}{3}·{\left(2{a}^{2}\right)}^{\frac{3}{2}}+\frac{2}{3}{\left({a}^{2}\right)}^{\frac{3}{2}}$
$=\sqrt{2}{a}^{3}-\frac{2}{3}·{2}^{\frac{3}{2}}·{a}^{3}+\frac{2}{3}·{a}^{3}$
$=\left(\sqrt{2}-\frac{4\sqrt{2}}{3}+\frac{2}{3}\right){a}^{3}$
$=\frac{2-\sqrt{2}}{3}{a}^{3}$

コード

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

print('13、14、15、16、17.')

class Test(TestCase):
def test(self):
ap = symbols('a', positive=True)
fs = [a ** 2 * x - x ** 3,
(sqrt(ap) - sqrt(x)) ** 2,
x / sqrt(x ** 2 + 4),
x ** 2 * sqrt(1 - x),
x ** 3 / sqrt(x ** 2 + ap ** 2)]
xs = [(0, a),
(0, ap),
(0, 1),
(0, 1),
(0, ap)]
ds = [a ** 4 / 4,
ap ** 2 / 6,
sqrt(5) - 2,
Rational(16, 105),
(2 - sqrt(2)) / 3 * ap ** 3]
for i, (f, (x1, x2), d) in enumerate(zip(fs, xs, ds), 13):
print(f'({i})')
self.assertEqual(Integral(f, (x, x1, x2)).doit().simplify(),
d.simplify())

if __name__ == "__main__":
main()


% ./sample13.py -v
13、14、15、16、17.
test (__main__.Test) ... (13)
(14)
(15)
(16)
(17)
ok

----------------------------------------------------------------------
Ran 1 test in 2.690s

OK
%