## 2019年10月23日水曜日

### 数学 - Python - 円の中にひそむ関数 - 三角関数 - 一般角と三角関数 - 正弦・余弦 - 公式、円周率

1. $\begin{array}{l}\mathrm{sin}\left(\pi -\theta \right)\\ =-\mathrm{sin}\left(-\theta \right)\\ =\mathrm{sin}\theta \\ \mathrm{cos}\left(\pi -\theta \right)\\ =-\mathrm{cos}\left(-\theta \right)\\ =-\mathrm{cos}\theta \end{array}$

（証明終）

コード

Python 3

#!/usr/bin/env python3
from unittest import TestCase, main
from sympy import pprint, symbols, sin, cos, pi, tan, sqrt, plot
print('6.')

theta = symbols('θ')

class MyTestCase(TestCase):
def setUp(self):
pass

def tearDown(self):
pass

def test_sine(self):
self.assertEqual(sin(pi - theta), sin(theta))

def test_cosine(self):
self.assertEqual(cos(pi - theta), -cos(theta))

theta = 1
x = symbols('x')
thetas = [pi - theta, theta]
fs = [tan(t0) * x for t0 in thetas] + [sin(theta)]
g = sqrt(1 - x ** 2)

p = plot((g, (x, -1, 1)),
(-g, (x, -1, 1)),
*[(f, (x, -2, 2)) for f in fs],
ylim=(-2, 2),
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'sample6.png')

if __name__ == '__main__':
main()


% ./sample6.py -v
6.
test_cosine (__main__.MyTestCase) ... ok
test_sine (__main__.MyTestCase) ... ok

----------------------------------------------------------------------
Ran 2 tests in 0.003s

OK
%