2019年11月16日土曜日

学習環境

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



    1. sinθ=cosθsinθ-cosθ=02sinθcos74π+cosθsin74π=02sinθ+74π=0θ+74π=nπθ=nπ-74πθ=π4,54π

    2. sinθ+cosθ=-12sinθcosπ4+cosθsinπ4=-12sinθ+π4=-1sinθ+π4=-12θ+π4=54π+2nπ,74π+2mπθ=π,32π

    3. sinθ-3cosθ=02sinθcos53π+cosθsin53π=02sinθ+53π=0θ+53π=nπθ=-53π+nπθ=13π,43π

    4. cosθ-3sinθ=12sin56πcosθ+cos56πsinθ=12sinθ+56π=1sinθ+56π=12θ+56π=π6+2nπ,56π+2mπθ=0,43π

コード

#!/usr/bin/env python3
from unittest import TestCase, main
from sympy import pprint, symbols, sin, cos, sqrt, pi, solveset, Interval

print('21.')
theta = symbols('θ')


class MyTestCase(TestCase):
    def test(self):
        spam = [sin(theta) - cos(theta),
                sin(theta) + cos(theta) + 1,
                sin(theta) - sqrt(3) * cos(theta),
                cos(theta) - sqrt(3) * sin(theta) - 1]
        egg = [{pi / 4, 5 * pi / 4},
               {pi, 3 * pi / 2},
               {pi / 3, 4 * pi / 3},
               {0, 4 * pi / 3}]
        for s, t in zip(spam, egg):
            self.assertEqual(
                solveset(s, theta, domain=Interval.Ropen(0, 2 * pi)), t)


if __name__ == '__main__':
    main()

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

% ./sample21.py -v
21.
test (__main__.MyTestCase) ... ok

----------------------------------------------------------------------
Ran 1 test in 1.055s

OK
%

0 コメント:

コメントを投稿