## 2020年8月4日火曜日

### 数学 - Python - 微分積分学 - 積分法 - 定積分、等式

• f の原始関数を F とおく。

${\int }_{a}^{b}f\left(x\right)\mathrm{dx}=F\left(b\right)-F\left(a\right)$
${\int }_{a-c}^{b-c}f\left(x\right)\mathrm{dx}=F\left(\left(b-c\right)+c\right)-F\left(\left(a-c\right)+c\right)=F\left(b\right)-F\left(c\right)$

よって、

${\int }_{a}^{b}f\left(x\right)\mathrm{dx}={\int }_{a-c}^{b-c}f\left(x+c\right)\mathrm{dx}$

• ${\int }_{0}^{a}f\left(x\right)\mathrm{dx}=F\left(a\right)-F\left(0\right)$
${\int }_{0}^{a}f\left(a-x\right)\mathrm{dx}=-F\left(a-a\right)+F\left(a-0\right)=F\left(a\right)-F\left(0\right)$
${\int }_{0}^{a}f\left(x\right)\mathrm{dx}={\int }_{0}^{a}f\left(a-x\right)\mathrm{dx}$

• $a{\int }_{0}^{1}f\left(ax\right)\mathrm{dx}=a\left(\frac{1}{a}F\left(a\right)-\frac{1}{a}F\left(0\right)\right)=F\left(a\right)-F\left(0\right)={\int }_{0}^{a}f\left(x\right)\mathrm{dx}$

コード

#!/usr/bin/env python3
from unittest import TestCase, main
from sympy import Function, Integral
from sympy.abc import a, b, c, x

print('11.')

f = 2 * x + 3 * x ** 2

class Test(TestCase):
def test1(self):
self.assertEqual(
Integral(f, (x, a, b)).doit().expand(),
Integral(f.subs({x: x + c}), (x, a - c, b - c)).doit().expand()
)

def test2(self):
self.assertEqual(
Integral(f, (x, 0, a)).doit(),
Integral(f.subs({x: a - x}), (x, 0, a)).doit().expand()
)

def test3(self):
self.assertEqual(
Integral(f, (x, 0, a)).doit().expand(),
(a * Integral(f.subs({x: a * x}), (x, 0, 1)).doit()).expand()
)

if __name__ == "__main__":
main()

% ./sample11.py -v
11.
test1 (__main__.Test) ... ok
test2 (__main__.Test) ... ok
test3 (__main__.Test) ... ok

----------------------------------------------------------------------
Ran 3 tests in 0.084s

OK
%