import numpy as np
import matplotlib.pyplot as plt

"""
Explanation: Trigonometry
End of explanation
"""


fig, ax = plt.subplots(1, 3, figsize=(13,4))

x = np.linspace(0, 2*np.pi, 30*np.pi).astype(np.float32)

ax[0].plot(x, np.sin(x), label='sin')
ax[1].plot(x, np.cos(x), label='cos')
ax[2].plot(x, np.tan(x), label='tan')

ax[0].plot(x, np.arcsin(np.sin(x)), label='arcsin')
ax[1].plot(x, np.arccos(np.cos(x)), label='arccos')
ax[2].plot(x, np.arctan(np.tan(x)), label='arctan')

for axes in ax:
    axes.grid(True)
    axes.legend()

plt.show()

"""
Explanation: Contents

Sine, cosine and tangent
Measurements
Small angle approximation
Trigonometric functions
More trigonometric functions
Identities
Compound angles

<a id='Sine_cosine_and_tangent'></a>
Sine, cosine and tangent
Sine:
- $\sin\theta = \frac{opp}{hyp}$
- with triangle with angles A, B and C, and lines a, b and c opposite their respective angles
- $\frac{a}{\sin A} = \frac{b}{\sin B} = \frac{c}{\sin C}$
Cosine:
- $\cos\theta = \frac{adj}{hyp}$
- with triangle with angles A, B and C, and lines a, b and c opposite their respective angles
- $a^2 = b^2 + c^2 - 2bc \cos A$
- $b^2 = a^2 + c^2 - 2ac \cos B$
- $c^2 = a^2 + b^2 - 2ab \cos C$
- $\cos A = \frac{b^2 + c^2 - a^2}{2bc}$
Tangent:
- $\tan\theta = \frac{opp}{adj}$
Area of triangle:
- $\frac{1}{2}ab\sin C$
<a id='Measurements'></a>
Measurements
Radians:
- 1 radian = angle when the arc opposite the angle = r (the 2 points on the circumference)
- since $c = 2\pi r$, 1 circumference = 2 pi radians
Arc Length:
- length, s, of arc on circumference with angle $\theta$ in radians
- $s = r\theta$
Area of Sector:
- area, a, of sector with angle $\theta$ in radians
- $\frac{1}{2} r^2\theta$
<a id='Small_angle_approximation'></a>
Small angle approximation
when $\theta \approx 0$ (in radians)
or $\theta = \lim_{\theta\to0}$
$\sin \theta \approx \theta$
$\cos \theta \approx 1 - \frac{\theta^2}{2} \approx 1$
$\tan \theta \approx \theta$
<a id='Trigonometric_functions'></a>
Trigonometric functions
arcsin, arcos and arctan are the inverse (from length to angle in circle)
Domains and ranges:
sin:
- $\theta = \mathbb{R}$
- $-1 \le \sin\theta \le 1$
- $-\frac{\pi}{2} \le \arcsin x \le \frac{\pi}{2}$
cos:
- $\theta = \mathbb{R}$
- $-1 \le \cos\theta \le 1$
- $0 \le \arccos x \le \pi$
tan:
- $\theta \not= \frac{\pi}{2}, \frac{3\pi}{2} \dots$
- $\tan$ range is undefined
- $-\pi \le \arctan x \le \pi$
Graphing:
End of explanation
"""


fig, ax = plt.subplots(1, 3, figsize=(13,4))

x = np.linspace(0, 2*np.pi, 20*np.pi)

ax[0].plot(x, 1/np.cos(x), label='$sec$')
ax[1].plot(x, 1/np.sin(x), label='cosec')
ax[2].plot(x, np.cos(x)/np.sin(x), label='cot')

for axes in ax:
    axes.grid(True)
    axes.set_ylim([-20,20])
    
    axes.legend()

plt.show()

"""
Explanation: <a id='More_trigonometric_functions'></a>
More trigonometric functions
Secant:
- $\sec \theta = \frac{1}{\cos \theta}$
Cosecant:
- $\mathrm{cosec} \theta = \frac{1}{\sin \theta}$
Cotangent:
- $\cot \theta = \frac{1}{\tan\theta} = \frac{\cos\theta}{\sin\theta}$
Graphing:
End of explanation
"""


