Processing math: 100%

2019年10月5日土曜日

学習環境

微分積分学 (ちくま学芸文庫) (吉田 洋一(著)、筑摩書房)のⅡ.(微分法の公式)、6.(導関数の求め方)、演習問題I9の解答を求めてみる。


  1. ddx((a+x)(b+x)(a-x)(b-x))13=(a+x)13(b+x)13(a-x)13(b-x)13(13·1a+x+13·1b+x-13·-1a-x-13·-1b-x)=(a+x)13(b+x)13(a-x)13(b-x)13·13·(1a+x+1b+x+1a-x+1b-x)

コード

Python 3

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

print('19.')

x, a, b = symbols('x, a, b')
f = root(((a + x) * (b + x)) / ((a - x) * (b - x)), 3)
d = Derivative(f, x, 1).doit()


class MyTest(TestCase):
    def setUp(self):
        pass

    def tearDown(self):
        pass

    def test(self):
        d0 = f * Rational(1, 3) * (
            1 / (a + x) + 1 / (b + x) + 1 / (a - x) + 1 / (b - x))
        self.assertEqual(d.factor(), d0.factor())


p = plot(f.subs({a: 1, b: 2}),
         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('sample19.png')

if __name__ == '__main__':
    main()

入出力結果(Bash、cmd.exe(コマンドプロンプト)、Terminal、Jupyter(IPython))

$ ./sample19.py
19.
.
----------------------------------------------------------------------
Ran 1 test in 0.055s

OK
$ 

0 コメント:

コメントを投稿