Skip to content

Commit 86d68f9

Browse files
committed
Numpy Mathematical Functions
1 parent dc03a52 commit 86d68f9

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Author: OMKAR PATHAK
2+
3+
import numpy as np
4+
5+
angles = np.array([0, 30, 45, 60, 90, 180, 360])
6+
7+
# Convert to radians by multiplying with pi/180
8+
# for getting sine of angles
9+
print(np.sin(angles * np.pi/180))
10+
11+
# for getting cosine of angles
12+
print(np.cos(angles * np.pi/180))
13+
14+
# for getting tangent of angles
15+
print(np.tan(angles * np.pi/180))
16+
17+
# for computing inverse of trigonometric functions
18+
sine = np.sin(angles * np.pi/180)
19+
sineinv = np.arcsin(sine)
20+
# computing angle from inverse
21+
print(np.degrees(sineinv))
22+
23+
# for rounding the values
24+
print(np.around(sine, 4)) # [ 0.      0.5     0.7071  0.866   1.      0.     -0.    ]
25+
26+
# for rounding to previous integer
27+
print(np.floor(sine)) # [ 0.  0.  0.  0.  1.  0. -1.]
28+
29+
# for rounding to next integer
30+
print(np.ceil(sine)) # [ 0.  1.  1.  1.  1.  1. -0.]

0 commit comments

Comments
 (0)