Numpy Array - trigonometric functions, hyperbolic functions, inverse trigonometric functions in numpy
In this numpy tutorial, we will discuss about:
-
trigonometric functions in numpy,
-
numpy hyperbolic functions,
-
numpy inverse trigonometric functions,
Before we discuss about numpy trigonometric functions, numpy hyperbolic functions, numpy inverse trigonometric functions, lets create one numpy array first.
numpy stands for numeric python which is used to perform mathematical operations on arrays.
It is a module in which we have to import from the python.
Syntax to import:
import numpy
We can also use alias for the module
For example,
import numpy as np
We can directly use np to call the numpy module.
Create Numpy Array
An array is an one dimensional data structure used to store single data type data.
I.E It will only store all integer data or all string type data.or all float type data.
We can create an numpy array by using array() function.
Syntax:
numpy.array(elements)
where, elements are the input data elements.
trigonometric functions in numpy
We can perform numpy sine function operation,cosine and tangent operations on the numpy numeric array.
Syntax:
numpy.sin(array_data)
numpy.cos(array_data)
numpy.tan(array_data)
To perform numpy hyperbolic functions operations the syntax is
numpy.sinh(array_data)
numpy.cosh(array_data)
numpy.tanh(array_data)
To perform numpy inverse trigonometric functions operations the syntax is
numpy.arcsin(array_data)
numpy.arccos(array_data)
numpy.arctan(array_data)
Lets see examples related to numpy trigonometric functions, numpy hyperbolic functions, numpy inverse trigonometric functions.
numpy trigonometric functions
Example 1: In this example we will perform numpy trigonometric functions operations
#importing the numpy module
import numpy
#create an array with 8 elements - integer type
array_data=numpy.array([34,56,43,22,45,6,54,2])
#actual array
print(array_data)
print()
#perform sin operation
print(numpy.sin(array_data))
print()
#perform cos operation
print(numpy.cos(array_data))
print()
#perform tan operation
print(numpy.tan(array_data))
Output: trigonometric functions in numpy result
[34 56 43 22 45 6 54 2]
[ 0.52908269 -0.521551 -0.83177474 -0.00885131 0.85090352 -0.2794155
-0.55878905 0.90929743]
[-0.84857027 0.85322011 0.5551133 -0.99996083 0.52532199 0.96017029
-0.82930983 -0.41614684]
[-0.62349896 -0.61127369 -1.49838734 0.00885166 1.61977519 -0.29100619
0.6738001 -2.18503986]
Lets see an example of numpy hyperbolic functions.
numpy hyperbolic functions
Example 2: In this example we will perform numpy hyperbolic functions operations.
#importing the numpy module
import numpy
#create an array with 8 elements - integer type
array_data=numpy.array([34,56,43,22,45,6,54,2])
#actual array
print(array_data)
print()
#perform sinh operation
print(numpy.sinh(array_data))
print()
#perform cosh operation
print(numpy.cosh(array_data))
print()
#perform tanh operation
print(numpy.tanh(array_data))
Output: numpy hyperbolic functions result
[34 56 43 22 45 6 54 2]
[2.91730871e+14 1.04582975e+24 2.36391973e+18 1.79245642e+09
1.74671355e+19 2.01713157e+02 1.41537665e+23 3.62686041e+00]
[2.91730871e+14 1.04582975e+24 2.36391973e+18 1.79245642e+09
1.74671355e+19 2.01715636e+02 1.41537665e+23 3.76219569e+00]
[1. 1. 1. 1. 1. 0.99998771
1. 0.96402758]
Lets understand numpy inverse trigonometric functions with example.
numpy inverse trigonometric functions
Example 3: In this example we will perform numpy inverse trigonometric functions operation.
#importing the numpy module
import numpy
#create an array with 8 elements - integer type
array_data=numpy.array([34,56,43,22,45,6,54,2])
#actual array
print(array_data)
print()
#perform sin operation
print(numpy.arcsin(array_data))
print()
#perform arccos operation
print(numpy.arccos(array_data))
print()
#perform arctan operation
print(numpy.arctan(array_data))
Output: numpy inverse trigonometric functions result
[34 56 43 22 45 6 54 2]
[nan nan nan nan nan nan nan nan]
[nan nan nan nan nan nan nan nan]
[1.54139304 1.55294108 1.5475447 1.52537305 1.54857776 1.40564765
1.55227992 1.10714872]
This wraps up our session on numpy trigonometric functions, numpy hyperbolic functions, numpy inverse trigonometric functions.
Would you like to see your article here on tutorialsinhand.
Join
Write4Us program by tutorialsinhand.com
About the Author
Gottumukkala Sravan Kumar 171FA07058
B.Tech (Hon's) - IT from Vignan's University.
Published 1200+ Technical Articles on Python, R, Swift, Java, C#, LISP, PHP - MySQL and Machine Learning
Page Views :
Published Date :
Jun 26,2022