学習環境
- Surface
 - Windows 10 Pro (OS)
 - Nebo(Windows アプリ)
 - iPad
 - MyScript Nebo - MyScript(iPad アプリ(iOS))
 - 参考書籍
 
微分積分学 (ちくま学芸文庫) (吉田 洋一(著)、筑摩書房)のⅣ.(積分法)、演習問題13、14、15、16、17.の解答を求めてみる。
コード
#!/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()
入出力結果(Zsh、PowerShell、Terminal、Jupyter(IPython))
% ./sample13.py -v
13、14、15、16、17.
test (__main__.Test) ... (13)
(14)
(15)
(16)
(17)
ok
----------------------------------------------------------------------
Ran 1 test in 2.690s
OK
%
0 コメント:
コメントを投稿