学習環境
- Surface
- Windows 10 Pro (OS)
- Nebo(Windowsアプリ)
- iPad
- MyScript Nebo - MyScript(iPadアプリ(iOS))
- 参考書籍
新装版 数学読本2 (松坂 和夫(著)、岩波書店)の第8章(円の中にひそむ関数 - 三角関数)、8.2(加法定理)、三角関数の諸公式の問35の解答を求めてみる。
コード
#!/usr/bin/env python3
from unittest import TestCase, main
from sympy import pprint, symbols, sin, cos, Rational, rad, sqrt
print('35.')
class MyTestCase(TestCase):
def test(self):
exprs = [sin(rad(75)) * cos(rad(15)),
cos(rad(22.5)) * cos(rad(67.5)),
sin(rad(52.5)) * sin(rad(7.5)),
cos(rad(40)) * cos(rad(20)) - cos(rad(70)) * cos(rad(50))]
egg = [(2 + sqrt(3)) / 4,
1 / (2 * sqrt(2)),
(sqrt(2) - 1) / 4,
Rational(1, 2)]
for s, t in zip(exprs, egg):
self.assertAlmostEqual(float(s), float(t))
if __name__ == '__main__':
main()
入出力結果(Zsh、cmd.exe(コマンドプロンプト)、Terminal、Jupyter(IPython))
% ./sample35.py -v
35.
test (__main__.MyTestCase) ... ok
----------------------------------------------------------------------
Ran 1 test in 0.047s
OK
%
0 コメント:
コメントを投稿