2020年1月7日火曜日

学習環境

微分積分学 (ちくま学芸文庫) (吉田 洋一(著)、筑摩書房)のⅣ.(積分法)、3.(不定積分の公式)、問4.の解答を求めてみる。


  1. Im,n=ax+bmxndx=ax+bmxn+1n+1-1n+1max+bm-1axn+1dx=ax+bmxn+1n+1-man+1ax+bm-1xn+1dx=a+bmxn+1n+1-man+1Im-1,n+1

コード

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

print('3.')

x, a, b = symbols('x, a, b')
m, n = symbols('m, n', integer=True, nonnegative=True)

f = (a * x + b) ** m * x ** n
g = Derivative((a * x + b) ** m * x ** (n + 1) / (n + 1), x,
               1).doit() - m * a / (n + 1) * f.subs({m: m-1, n: n + 1})


class MyTestCase(TestCase):
    def test(self):
        self.assertEqual(f.simplify(), g.simplify())


p = plot(f.subs({a: 1, b: 2, m: 1, n: 2}),
         (x, -5, 5),
         ylim=(0, 10),
         legend=True,
         show=False)

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('sample4.png')


if __name__ == '__main__':
    main()

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

% ./sample4.py -v
3.
test (__main__.MyTestCase) ... ok

----------------------------------------------------------------------
Ran 1 test in 0.344s

OK
%

0 コメント:

コメントを投稿