## 2019年8月25日日曜日

### 数学 - Python - 解析学 - 各種の初等関数 - 三角関数 - π、正弦(sine)・余弦(cosine)、平面幾何学の定理

1. $\begin{array}{l}\mathrm{sin}\left(\pi -\theta \right)\\ =\mathrm{sin}\left(\left(-\theta \right)+\pi \right)\\ =-\mathrm{sin}\left(-\theta \right)\\ =\mathrm{sin}\theta \\ \mathrm{cos}\left(\pi -\theta \right)\\ =\mathrm{cos}\left(\left(-\theta \right)+\pi \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, plot

print('2.')

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

def tearDown(self):
pass

def test(self):
theta = symbols('θ')
self.assertEqual(sin(pi - theta), sin(theta))
self.assertEqual(cos(pi - theta), -cos(theta))

if __name__ == '__main__':
theta = symbols('θ')
p = plot(sin(pi - theta), -cos(pi - theta),
(theta, -5, 5),
ylim=(-5, 5),
show=False,
legend=True)

colors = ['red', 'green', 'blue', 'brown', 'orange',
'purple', 'pink', 'gray', 'skyblue', 'yellow']

for o, color in zip(p, colors):
o.line_color = color

p.show()
p.save('sample2.png')
main()


C:\Users\...>py sample2.py
2.
.
----------------------------------------------------------------------
Ran 1 test in 0.000s

OK

C:\Users\...>