学習環境
- Surface
- Windows 10 Pro (OS)
- Nebo(Windows アプリ)
- iPad
- MyScript Nebo - MyScript(iPad アプリ(iOS))
- 参考書籍
解析入門 原書第3版 (S.ラング(著)、松坂 和夫(翻訳)、片山 孝次(翻訳)、岩波書店)の第Ⅵ部(多変数の関数)、第17章(ベクトル)、4(ベクトルのノルム)の練習問題14の解答を求めてみる。
コード
#!/usr/bin/env python3
from unittest import TestCase, main
from sympy import symbols, Integral, plot, sqrt
print('14.')
x = symbols('x')
def dot(f, g):
return Integral(f * g, (x, -1, 1)).doit()
def norm(f):
return sqrt(dot(f, f))
class MyTestCase(TestCase):
def test(self):
self.assertEqual(norm(1), sqrt(2))
if __name__ == '__main__':
main()
入出力結果(Zsh、PowerShell、Terminal、Jupyter(IPython))
% ./sample14.py -v
14.
test (__main__.MyTestCase) ... ok
----------------------------------------------------------------------
Ran 1 test in 0.013s
OK
%
0 コメント:
コメントを投稿