2020年8月4日火曜日

学習環境

微分積分学 (ちくま学芸文庫) (吉田 洋一(著)、筑摩書房)のⅣ.(積分法)、演習問題11.の解答を求めてみる。



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

      a b f ( x ) dx = F ( b ) - F ( a )
      a - c b - c f ( x ) dx = F ( ( b - c ) + c ) - F ( ( a - c ) + c ) = F ( b ) - F ( c )

      よって、

      a b f ( x ) dx = a - c b - c f ( x + c ) dx

    • 0 a f ( x ) dx = F ( a ) - F ( 0 )
      0 a f ( a - x ) dx = - F ( a - a ) + F ( a - 0 ) = F ( a ) - F ( 0 )
      0 a f ( x ) dx = 0 a f ( a - x ) dx

    • a 0 1 f ( a x ) dx = a ( 1 a F ( a ) - 1 a F ( 0 ) ) = F ( a ) - F ( 0 ) = 0 a f ( x ) 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()

入出力結果(Zsh、PowerShell、Terminal、Jupyter(IPython))

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

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

OK
%

0 コメント:

コメントを投稿