学習環境
- Surface
- Windows 10 Pro (OS)
- Nebo(Windows アプリ)
- iPad
- MyScript Nebo - MyScript(iPad アプリ(iOS))
- 参考書籍
ラング線形代数学(上) (ちくま学現文庫)(S.ラング (著)、芹沢 正三 (翻訳)、筑摩書房)の4章(線形写像)、3(線形写像の核と像)、練習問題7の解答を求めてみる。
2階微分演算の核は1次 以下の関数。
n 階微分演算の核は n-1次以下の関数。
コード
#!/usr/bin/env python3
from unittest import TestCase, main
from sympy import symbols, Derivative
print('7.')
x = symbols('x')
class TestDerivativeKernel(TestCase):
def test_2(self):
a, b = symbols('a, b')
self.assertNotEqual(Derivative(a * x + b, x, 1).doit(), 0)
self.assertEqual(Derivative(a * x + b, x, 2).doit(), 0)
def test_n(self):
for n in range(10):
f = sum([symbols(f'a{i}') * x ** i for i in range(n)])
self.assertEqual(Derivative(f, x, n).doit(), 0)
if __name__ == "__main__":
main()
入出力結果(Zsh、PowerShell、Terminal、Jupyter(IPython))
% ./sample7.py -v
7.
test_2 (__main__.TestDerivativeKernel) ... ok
test_n (__main__.TestDerivativeKernel) ... ok
----------------------------------------------------------------------
Ran 2 tests in 0.111s
OK
%
0 コメント:
コメントを投稿