2019年11月8日金曜日

学習環境

新装版 数学読本2 (松坂 和夫(著)、岩波書店)の第8章(円の中にひそむ関数 - 三角関数)、8.2(加法定理)、正弦・余弦の加法定理の問15の解答を求めてみる。


  1. sinα+β=sinαcosβ+cosαsinβ=513·-35+1213·-45=-15-4813·5=-6365cosα+β=cosαcosβ-sinαsinβ=1213·-35-513·-45=-36+2065=-1665cosα-β=cosαcosβ+sinαsinβ=1213·-35+513·-45=-36-2065=-5665

コード

#!/usr/bin/env python3
from unittest import TestCase, main
from sympy import pprint, symbols, sin, cos, asin, acos, Rational

print('15.')


class MyTestCase(TestCase):

    def test(self):
        alpha = asin(Rational(5, 13))
        beta = -acos(-Rational(3, 5))
        spam = [sin(alpha + beta),
                cos(alpha + beta),
                cos(alpha - beta)]
        egg = [-Rational(63, 65),
               -Rational(16, 65),
               -Rational(56, 65)]
        for s, t in zip(spam, egg):
            self.assertEqual(float(s), float(t))


if __name__ == '__main__':
    main()

入出力結果(Zsh、cmd.exe(コマンドプロンプト)、Terminal、Jupyter(IPython))

% ./sample15.py -v
15.
test (__main__.MyTestCase) ... ok

----------------------------------------------------------------------
Ran 1 test in 0.026s

OK
%

0 コメント:

コメントを投稿