2020年8月7日金曜日

学習環境

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


  1. 0 a ( a 2 x - x 3 ) dx
    = [ a 2 2 x 2 - 1 4 x 4 ] 0 a
    = a 4 4

  2. 0 a ( a - t ) 2 dt
    = 0 a ( a - 2 a t + t ) dt
    = a 2 - 2 a · 2 3 [ t 3 2 ] 0 a + 1 2 [ t 2 ] 0 a
    = a 2 - 4 3 a 2 + 1 2 a 2
    = 6 - 8 + 3 6 a 2
    = a 2 6

  3. 0 1 x dx x 2 + 4
    = [ x 2 + 4 ] 0 1
    = 5 - 2

  4. 0 1 z 2 1 - z dz
    = [ z 2 ( - 2 3 ( 1 - z ) 3 2 ) ] 0 1 + 4 3 0 1 z ( 1 - z ) 3 2 dz
    = 4 3 ( [ z ( - 2 5 ( 1 - z ) 5 2 ) ] 0 1 + 2 5 0 1 ( 1 - z ) 5 2 dz )
    = 4 3 · 2 5 ( - 2 7 ) [ ( 1 - z ) 7 2 ] 0 1
    = 4 3 · 2 5 · 2 7
    = 16 105

  5. x 3 x 2 + a 2 dx
    = x 2 x 2 + a 2 - 2 x x 2 + a 2 dx
    = x 2 x 2 + a 2 - 2 3 ( x 2 + a 2 ) 3 2
    0 a x 3 x 2 + a 2 dx
    = [ x 2 x 2 + a 2 - 2 3 ( x 2 + a 2 ) 3 2 ] 0 a
    = 2 a 3 - 2 3 · ( 2 a 2 ) 3 2 + 2 3 ( a 2 ) 3 2
    = 2 a 3 - 2 3 · 2 3 2 · a 3 + 2 3 · a 3
    = ( 2 - 4 2 3 + 2 3 ) a 3
    = 2 - 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()

入出力結果(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 コメント:

コメントを投稿