# 23 Numpy Math Functions with Programs

Here , we have detail explanation with example input and output about trigonometric functions, round functions, Hyperbolic functions

## #Mathematical functions

### #Trigonometric functions

#sin()- Trigonometric sine, element-wise.

` ` ``` import numpy as np a= np.array([10,20,30]) print ('Sin value:' , np.sin(a)) ``` ` ` ` `

Output:

Sin value: [-0.54402111  0.91294525 -0.98803162]

#cos() – Cosine element-wise.

` ` ``` import numpy as np a= np.array([10,20,30]) print ('Cosine value:' , np.cos(a)) ``` ` ` ` `

Output:

Cosine value: [-0.83907153  0.40808206  0.15425145]

#tan()   Compute tangent element-wise.

` ` ``` import numpy as np a= np.array([10,20,30]) print ('Tan value:' , np.tan(a)) ``` ` ` ` `

Output:

Tan value: [ 0.64836083  2.23716094 -6.4053312 ]

#arcsin()  –  Inverse sine, element-wise.

` ` ``` import numpy as np a= np.array([10,20,30]) print ('arcsin value:' , np.arcsin(1)) ``` ` ` ` `

Output:

arcsin value: 1.5707963267948966

#arccos() – Trigonometric inverse cosine, element-wise.

` ` ``` import numpy as np a= np.array([10,20,30]) print ('arccos value:' , np.arccos(-1)) ``` ` ` ` `

Output:

arccos value: 3.141592653589793

#arctan()       Trigonometric inverse tangent, element-wise.

` ` ``` import numpy as np a= np.array([10,20,30]) print ('arctan value:' , np.arctan(a)) ``` ` ` ` `

Output:

arctan value: [1.47112767 1.52083793 1.53747533]

#degrees(x)       Convert angles from radians to degrees.

` ` ``` import numpy as np a= np.array([10,20,30]) print ('Convert to degrees value:' , np.degrees(a)) ``` ` ` ` `

Output:

Convert to degrees value: [ 572.95779513 1145.91559026 1718.87338539]

` ` ``` import numpy as np a= np.array([10,20,30]) print ('Convert to Radians value:' , np.radians(a)) ``` ` ` ` `

Output:

Convert to Radians value: [0.17453293 0.34906585 0.52359878]

` ` ``` import numpy as np a= np.array([10,20,30]) print ('Convert angles from degrees to radians' , np.deg2rad(a)) ``` ` ` ` `

Output:

Convert angles from degrees to radians [0.17453293 0.34906585 0.52359878]

` ` ``` import numpy as np a= np.array([10,20,30]) print ('Convert angles from degrees to radians' , np.deg2rad(a)) ``` ` ` ` `

Output:

Convert angles from radians to degrees. [ 572.95779513 1145.91559026 1718.87338539]

### #Hyperbolic functions

#sinh(x) – Hyperbolic sine, element-wise.

` ` ``` import numpy as np a= np.array([10,20,30]) print ('Sinh value:' , np.sinh(a)) ``` ` ` ` `

Output:

Sinh value: [1.10132329e+04 2.42582598e+08 5.34323729e+12]

#cosh(x) –  Hyperbolic cosine, element-wise.

` ` ``` import numpy as np a= np.array([10,20,30]) print ('cosh value:' , np.cosh(a)) ``` ` ` ` `

Output:

cosh value: [1.10132329e+04 2.42582598e+08 5.34323729e+12]

#tanh(x)  – Compute hyperbolic tangent element-wise.

` ` ``` import numpy as np a= np.array([10,20,30]) print ('tanh value:' , np.tanh(a)) ``` ` ` ` `

Output:

tanh value: [1. 1. 1.]

#arcsinh(x) – Inverse hyperbolic sine element-wise.

` ` ``` import numpy as np a= np.array([10,20,30]) print ('arcsinh value:' , np.arcsinh(a)) ``` ` ` ` `

Output:

arcsinh value: [2.99822295 3.68950387 4.09462222]

#arccosh(x) – Inverse hyperbolic cosine, element-wise.

` ` ``` import numpy as np a= np.array([10,20,30]) print ('arccosh value:' , np.arccosh(a)) ``` ` ` ` `

Output:

arccosh value: [2.99322285 3.68825387 4.09406667]

#arctanh(x) – Inverse hyperbolic tangent element-wise.

` ` ``` import numpy as np a= np.array([10,20,30]) print ('arctanh value:' , np.arctanh(0.05)) ``` ` ` ` `

#output:arctanh value: 0.05004172927849127

### #Rounding Fucntions

#around(a) –  Evenly round to the given number of decimals.

` ` ``` import numpy as np a= np.array([10,20,30]) print ('around value:' , np.around(60.65)) ``` ` ` ` `

Output:

around value: 61.0

#round_(a)  –  Round an array to the given number of decimals.

` ` ``` import numpy as np a= np.array([10,20,30]) print ('round value:' , np.round_(60.65)) ``` ` ` ` `

Output:

round value: 61.0

#rint(x) – Round elements of the array to the nearest integer.

` ` ``` import numpy as np a= np.array([10,20,30]) print ('rint value:' , np.rint(60.65)) ``` ` ` ` `

Output:

rint value: 61.0

#fix(x)   – Round to nearest integer towards zero.

` ` ``` import numpy as np a= np.array([10,20,30]) print ('fix value:' , np.fix(60.65)) ``` ` ` ` `

Output:

fix value: 60.0

#floor(x)  –  Return the floor of the input, element-wise.

` ` ``` import numpy as np a= np.array([10,20,30]) print ('floor value:' , np.floor(60.65)) ``` ` ` ` `

Output:

floor value: 60.0

#ceil(x) – Return the ceiling of the input, element-wise.

` ` ``` import numpy as np a= np.array([10,20,30]) print ('ceil value:' , np.ceil(60.65)) ``` ` ` ` `

Output:

ceil value: 61.0

#trunc(x) – Return the truncated value of the input, element-wise.

` ` ``` import numpy as np a= np.array([10,20,30]) print ('trunc value:' , np.trunc(60.65)) ``` ` ` ` `

Output:

trunc value: 60.0 