学習環境
- Surface、Surface ペン(端末)
- Windows 10 Pro (OS)
- Nebo(Windows アプリ)
- iPad Pro 10.5 + Apple Pencil
- MyScript Nebo - MyScript(iPad アプリ(iOS))
- 参考書籍
解析入門(上) (松坂和夫 数学入門シリーズ 4) (松坂 和夫(著)、岩波書店)の第5章(各種の初等関数)、5.3(三角関数)、問題7の解答を求めてみる。
コード
Python 3
#!/usr/bin/env python3
from unittest import TestCase, main
from sympy import pprint, symbols, sin, cos, tan, pi, sqrt, plot
print('7.')
class MyTest(TestCase):
def setUp(self):
pass
def tearDown(self):
pass
def test(self):
spam = [sin, cos, tan]
egg = [sqrt(2 - sqrt(2)) / 2,
sqrt(2 + sqrt(2)) / 2,
sqrt(2) - 1]
for s, t in zip(spam, egg):
self.assertEqual(s(pi / 8).factor(), t.factor())
if __name__ == '__main__':
theta = symbols('θ')
p = plot(sin(theta), cos(theta), tan(theta),
sqrt(2 - sqrt(2)) / 2,
sqrt(2 + sqrt(2)) / 2,
sqrt(2) - 1,
(theta, -5, 5),
ylim=(-5, 5),
show=False,
legend=True)
colors = ['red', 'green', 'blue', 'brown', 'orange',
'purple', 'pink', 'gray', 'skyblue', 'yellow']
for o, color in zip(p, colors):
o.line_color = color
p.show()
p.save('sample7.png')
main()
入出力結果(Bash、cmd.exe(コマンドプロンプト)、Terminal、Jupyter(IPython))
C:\Users\...>py sample7.py 7. . ---------------------------------------------------------------------- Ran 1 test in 0.021s OK C:\Users\...>
0 コメント:
コメントを投稿