学習環境
- Surface、Surface ペン(端末)
- Windows 10 Pro (OS)
- Nebo(Windows アプリ)
- iPad Pro 10.5 + Apple Pencil
- MyScript Nebo - MyScript(iPad アプリ(iOS))
- 参考書籍
新装版 数学読本2 (松坂 和夫(著)、岩波書店) の第8章(円の中にひそむ関数 - 三角関数)、8.1(一般角と三角関数)、正弦・余弦の問6の解答を求めてみる。
(証明終)
コード
Python 3
#!/usr/bin/env python3 from unittest import TestCase, main from sympy import pprint, symbols, sin, cos, pi, tan, sqrt, plot print('6.') theta = symbols('θ') class MyTestCase(TestCase): def setUp(self): pass def tearDown(self): pass def test_sine(self): self.assertEqual(sin(pi - theta), sin(theta)) def test_cosine(self): self.assertEqual(cos(pi - theta), -cos(theta)) theta = 1 x = symbols('x') thetas = [pi - theta, theta] fs = [tan(t0) * x for t0 in thetas] + [sin(theta)] g = sqrt(1 - x ** 2) p = plot((g, (x, -1, 1)), (-g, (x, -1, 1)), *[(f, (x, -2, 2)) for f in fs], ylim=(-2, 2), legend=True, show=False) colors = ['red', 'green', 'blue', 'brown', 'orange', 'purple', 'pink', 'gray', 'skyblue', 'yellow'] for s, color in zip(p, colors): s.line_color = color p.show() p.save(f'sample6.png') if __name__ == '__main__': main()
入出力結果(Zsh、cmd.exe(コマンドプロンプト)、Terminal、Jupyter(IPython))
% ./sample6.py -v 6. test_cosine (__main__.MyTestCase) ... ok test_sine (__main__.MyTestCase) ... ok ---------------------------------------------------------------------- Ran 2 tests in 0.003s OK %
0 コメント:
コメントを投稿