## 2019年12月13日金曜日

### 数学 - Python - 円の中にひそむ関数 - 三角関数 - 三角関数と三角形 - 正弦 - 正弦定理、外接円、半径、三角形の角、辺の長さ、関係

1. $\begin{array}{l}\frac{10}{\mathrm{sin}\frac{3}{4}\pi }=2R\\ \frac{10}{\frac{1}{\sqrt{2}}}=2R\\ R=5\sqrt{2}\end{array}$

2. $\begin{array}{l}\frac{a}{\mathrm{sin}\frac{\pi }{6}}=2·10\\ a=20·\frac{1}{2}=10\end{array}$

3. $\begin{array}{l}A=\pi -\frac{\pi }{6}·2=\frac{2}{3}\pi \\ \frac{10}{\mathrm{sin}\frac{\pi }{3}}=2R\\ \frac{10}{\frac{\sqrt{3}}{2}}=2R\\ R=\frac{10}{\sqrt{3}}\\ \frac{b}{\mathrm{sin}\frac{\pi }{6}}=2·\frac{10}{\sqrt{3}}\\ b=\frac{2·10}{\sqrt{3}}·\frac{1}{2}=\frac{10}{\sqrt{3}}\\ \frac{c}{\mathrm{sin}\frac{\pi }{6}}=2·\frac{10}{\sqrt{3}}\\ c=\frac{10}{\sqrt{3}}\end{array}$

コード

#!/usr/bin/env python3
from unittest import TestCase, main
from sympy import symbols, pi, sin, solve, sqrt

print('38.')

B = pi / 6
C = pi / 6
A, R, b, c = symbols('A, R, b, c', real=True)

class MyTestCase(TestCase):
def test1(self):
s = solve(10 / sin(3 * pi / 4) - 2 * R)
self.assertEqual(s[0], 5 * sqrt(2))

def test2(self):
s = solve(A / sin(pi / 6) - 2 * 10)
self.assertEqual(s[0], 10)

def test3(self):
A = pi - pi / 6 * 2
self.assertEqual(A, 2 * pi / 3)
r0 = solve(10 / sin(pi / 3) - 2 * R)[0]
self.assertEqual(r0, 10 / sqrt(3))
b0 = solve(b / sin(pi / 6) - 2 * r0, b)[0]
self.assertEqual(b0, 10 / sqrt(3))

if __name__ == '__main__':
main()


% ./sample38.py -v
38.
test1 (__main__.MyTestCase) ... ok
test2 (__main__.MyTestCase) ... ok
test3 (__main__.MyTestCase) ... ok

----------------------------------------------------------------------
Ran 3 tests in 0.248s

OK
%