## 2019年11月9日土曜日

### 数学 - Python - 円の中にひそむ関数 - 三角関数 - 加法定理 - 正弦・余弦の加法定理 - 弧度法、radian

1. $\begin{array}{l}\mathrm{sin}1{5}^{\circ }\\ =\mathrm{sin}\left(6{0}^{\circ }-4{5}^{\circ }\right)\\ =\mathrm{sin}\left(\frac{1}{3}\pi -\frac{1}{4}\pi \right)\\ =\mathrm{sin}\frac{\pi }{3}\mathrm{cos}\frac{\pi }{4}-\mathrm{cos}\frac{\pi }{3}\mathrm{sin}\frac{\pi }{4}\\ =\frac{\sqrt{3}}{2}·\frac{1}{\sqrt{2}}-\frac{1}{2}·\frac{1}{\sqrt{2}}\\ =\frac{\sqrt{3}-1}{2\sqrt{2}}\\ =\frac{\sqrt{6}-\sqrt{2}}{4}\end{array}$

2. $\begin{array}{l}\mathrm{cos}1{5}^{\circ }\\ =\mathrm{cos}\frac{\pi }{12}\\ =\mathrm{cos}\left(\frac{1}{3}\pi -\frac{1}{4}\pi \right)\\ =\mathrm{cos}\frac{\pi }{3}\mathrm{cos}\frac{\pi }{4}+\mathrm{sin}\frac{\pi }{3}\mathrm{sin}\frac{\pi }{4}\\ =\frac{1}{2}·\frac{1}{\sqrt{2}}+\frac{\sqrt{3}}{2}·\frac{1}{\sqrt{2}}\\ =\frac{\sqrt{3}+1}{2\sqrt{2}}\\ =\frac{\sqrt{6}+\sqrt{2}}{4}\end{array}$

3. $\begin{array}{l}\mathrm{sin}10{5}^{\circ }\\ =\mathrm{sin}\frac{7}{12}\pi \\ =\mathrm{sin}\left(\frac{\pi }{2}+\frac{\pi }{12}\right)\\ =\mathrm{sin}\frac{\pi }{2}\mathrm{cos}\frac{\pi }{12}+\mathrm{cos}\frac{\pi }{2}\mathrm{sin}\frac{\pi }{12}\\ =\frac{\sqrt{6}+\sqrt{2}}{4}\end{array}$

4. $\begin{array}{l}\mathrm{cos}10{5}^{\circ }\\ =\mathrm{cos}\frac{7}{12}\pi \\ =-\mathrm{sin}\left(\frac{7}{12}\pi -\frac{\pi }{2}\right)\\ =-\mathrm{sin}\frac{\pi }{12}\\ =\frac{\sqrt{2}-\sqrt{6}}{4}\end{array}$

5. $\begin{array}{l}\mathrm{sin}12{0}^{\circ }\\ =\mathrm{sin}\frac{2}{3}\pi \\ =\frac{\sqrt{3}}{2}\end{array}$

6. $\begin{array}{l}\mathrm{cos}12{0}^{\circ }\\ =\mathrm{cos}\frac{2}{3}\pi \\ =-\frac{1}{2}\end{array}$

7. $\begin{array}{l}\mathrm{sin}16{5}^{\circ }\\ =\mathrm{sin}\frac{165}{180}\pi \\ =\mathrm{sin}\frac{11}{12}\pi \\ =\mathrm{sin}\left(\frac{10}{12}\pi +\frac{1}{12}\pi \right)\\ =\mathrm{sin}\left(\frac{5}{6}\pi +\frac{\pi }{12}\right)\\ =\mathrm{sin}\frac{5}{6}\pi \mathrm{cos}\frac{\pi }{12}+\mathrm{cos}\frac{5}{6}\pi \mathrm{sin}\frac{\pi }{12}\\ =\frac{1}{2}·\frac{\sqrt{6}+\sqrt{2}}{4}-\frac{\sqrt{3}}{2}·\frac{\sqrt{6}-\sqrt{2}}{4}\\ =\frac{\sqrt{6}+\sqrt{2}-\sqrt{18}+\sqrt{6}}{8}\\ =\frac{2\sqrt{6}+\sqrt{2}-3\sqrt{2}}{8}\\ =\frac{2\sqrt{6}-2\sqrt{2}}{8}\\ =\frac{\sqrt{6}-\sqrt{2}}{4}\end{array}$

8. $\begin{array}{l}\mathrm{cos}16{5}^{\circ }\\ =\mathrm{cos}\frac{11}{12}\pi \\ =-\mathrm{cos}\left(\frac{11}{12}\pi -\pi \right)\\ =-\mathrm{cos}\left(-\frac{\pi }{12}\right)\\ =-\mathrm{cos}\frac{\pi }{12}\\ =-\frac{\sqrt{6}+\sqrt{2}}{4}\end{array}$

コード

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

print('16.')

class MyTestCase(TestCase):

def test(self):
angles = [15, 105, 120, 165]
fs = [sin, cos]
results = [(sqrt(6) - sqrt(2)) / 4,
(sqrt(6) + sqrt(2)) / 4,
(sqrt(6) + sqrt(2)) / 4,
(sqrt(2) - sqrt(6)) / 4,
sqrt(3) / 2,
-Rational(1, 2),
(sqrt(6) - sqrt(2)) / 4,
-(sqrt(6) + sqrt(2)) / 4]
for i, angle in enumerate(angles):
for j, f in enumerate(fs):
self.assertAlmostEqual(f(math.radians(angle)),
float(results[2 * i + j]))

if __name__ == '__main__':
main()


% ./sample16.py -v
16.
test (__main__.MyTestCase) ... ok

----------------------------------------------------------------------
Ran 1 test in 0.011s

OK
%