学習環境
- Surface、Surface ペン(端末)
- Windows 10 Pro (OS)
- Nebo(Windows アプリ)
- iPad Pro 10.5 + Apple Pencil
- MyScript Nebo - MyScript(iPad アプリ(iOS))
- 参考書籍
微分積分学 (ちくま学芸文庫) (吉田 洋一(著)、筑摩書房)のI.(微分法)、演習問題 I.、6〜15の解答を求めてみる。
コード
Python 3
#!/usr/bin/env python3
from sympy import pprint, symbols, sqrt, Rational, Derivative
from unittest import TestCase, main
print('6〜15.')
class MyTest(TestCase):
def setUp(self):
pass
def tearDown(self):
pass
def test(self):
x, a, b, c = symbols('x, a, b, c')
fs = [a ** 2 - x ** 2,
x ** 3 + 4 * x ** 2 + 3,
(1 - x) ** 2,
1 / x ** 2,
(a + b * x + c * x ** 2) / x,
sqrt(1 + x),
4 * sqrt(x) + 5 / x + 3,
x * (1 - x ** 2),
sqrt(1 + x ** 2),
sqrt(1 - x ** 2)]
ans = [-2 * x,
3 * x ** 2 + 8 * x,
- 2 * (1 - x),
-2 / x ** 3,
(-a + c * x ** 2) / x ** 2,
(1 + x) ** Rational(-1, 2) / 2,
2 * x ** Rational(-1, 2) - 5 / x ** 2,
1 - 3 * x ** 2,
x * (1 + x ** 2) ** Rational(-1, 2),
-x * (1 - x ** 2) ** Rational(-1, 2)]
for f, a in zip(fs, ans):
self.assertEqual(Derivative(f, x, 1).doit().factor(), a.factor())
if __name__ == '__main__':
main()
入出力結果(Bash、cmd.exe(コマンドプロンプト)、Terminal、Jupyter(IPython))
C:\Users\...>py sample6.py 6〜15. . ---------------------------------------------------------------------- Ran 1 test in 0.079s OK c:\Users\...>
0 コメント:
コメントを投稿