2019年11月13日水曜日

学習環境

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



    • tan θ + π 4 = tan θ + tan π 4 1 - tan θ tan π 4 = 1 + tan θ 1 - tan θ

      (証明終)


    • tan π 4 - θ = tan π 4 - tan θ 1 + tan π 4 tan θ = 1 - tan θ 1 + tan θ

      (証明終)

コード

#!/usr/bin/env python3
from unittest import TestCase, main
from sympy import pprint, symbols, tan, pi, plot

print('19.')

theta = 2


class MyTestCase(TestCase):

    def test1(self):
        self.assertEqual(float(tan(theta + pi / 4)),
                         float((1 + tan(theta)) / (1 - tan(theta))))

    def test2(self):
        self.assertEqual(float(tan(pi / 4 - theta)),
                         float((1 - tan(theta)) / (1 + tan(theta))))


x = symbols('x', real=True)
p = plot(tan(x), (1 + tan(x)) / (1 - tan(x)), tan(x), (1 - tan(x)) / (1 + tan(x)),
         (x, -5, 5),
         ylim=(-5, 5),
         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'sample19.png')
if __name__ == '__main__':
    main()

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

% ./sample19.py -v
19.
test1 (__main__.MyTestCase) ... ok
test2 (__main__.MyTestCase) ... ok

----------------------------------------------------------------------
Ran 2 tests in 0.015s

OK
%

0 コメント:

コメントを投稿