-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathSin_Cos_Tan_Cosec_Sec_Cot_Angles_Degrees.py
32 lines (26 loc) · 1.2 KB
/
Sin_Cos_Tan_Cosec_Sec_Cot_Angles_Degrees.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from matplotlib.animation import FuncAnimation
# Step 1: Data Generation and Preparation
angles_degrees = [0, 30, 45, 60, 90]
data = {'Angle (degrees)': angles_degrees}
# Calculate trigonometric ratios
data['sin'] = [np.sin(np.deg2rad(angle)) for angle in angles_degrees]
data['cos'] = [np.cos(np.deg2rad(angle)) for angle in angles_degrees]
data['tan'] = [np.tan(np.deg2rad(angle)) if angle != 90 else np.nan for angle in angles_degrees]
data['cosec'] = [1 / np.sin(np.deg2rad(angle)) if angle != 0 else np.nan for angle in angles_degrees]
data['sec'] = [1 / np.cos(np.deg2rad(angle)) if angle != 90 else np.nan for angle in angles_degrees]
data['cot'] = [1 / np.tan(np.deg2rad(angle)) if angle != 0 else np.nan for angle in angles_degrees]
df = pd.DataFrame(data)
# Step 2: Visualization
plt.figure(figsize=(12, 6))
# Create a bar chart for sin, cos, tan, cosec, sec, and cot
for i, ratio in enumerate(['sin', 'cos', 'tan', 'cosec', 'sec', 'cot']):
plt.subplot(2, 3, i + 1)
plt.bar(df['Angle (degrees)'], df[ratio])
plt.title(f'{ratio}(θ)')
plt.xlabel('Angle (degrees)')
plt.ylabel(f'{ratio}(θ)')
plt.tight_layout()
plt.show()