2020年8月2日日曜日

学習環境

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


  1. d dx ( 2 3 + 2 m x m ( x + a ) x + a - 2 m a 3 + 2 m I m - 1 )
    = 2 3 + 2 m ( m x m - 1 ( x + a ) x + a + x m x + a + x m x + a 2 - m a ( x m - 1 x + a ) )
    = 2 x m - 1 x + a 3 + 2 m ( m ( x + a ) + x + x 2 - m a )
    = 2 x m - 1 x + a 3 + 2 m ( m x + 3 2 x )
    = 2 x m x + a 3 + 2 m ( m + 3 2 )
    = x m x + a 3 + 2 m ( 2 m + 3 )
    = x m x + a

    よって、

    I m = 2 3 + 2 m x m ( x + a ) x + a - 2 m a 3 + 2 m I m - 1

    (証明終)

コード

#!/usr/bin/env python3
from unittest import TestCase, main
from sympy import sqrt, symbols, Integral, Derivative, plot

print('10.')

m = symbols('m', positive=True)
x, a = symbols('x, a', real=True)
f = x ** m * sqrt(x + a)


class Test(TestCase):
    def test(self):
        self.assertEqual(
            f,
            (
                Derivative(2 * x ** m * (x + a) * sqrt(x + a) / (3 + 2 * m),
                           x,
                           1).doit() -
                2 * m * a * f.subs({m: m-1}) / (3 + 2 * m)
            ).simplify()
        )


p = plot(*[f.subs({m: m0, a: 1}) for m0 in range(1, 5)],
         (x, -1, 4),
         ylim=(-2.5, 2.5),
         show=False,
         legend=True)
colors = ['red', 'green', 'blue', 'brown', 'orange',
          'purple', 'pink', 'gray', 'skyblue', 'yellow']

for o, color in zip(p, colors):
    o.line_color = color

p.show()
p.save(f'sample10.png')
if __name__ == "__main__":
    main()

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

% ./sample10.py -v
10.
test (__main__.Test) ... ok

----------------------------------------------------------------------
Ran 1 test in 0.304s

OK
%

0 コメント:

コメントを投稿