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