What is the numpy.sin() Function

The numpy.sin() is a library function that “generates the sine value for the angle passed inside the function”.


numpy.sin(x, /,out=None,*,where=True, casting='same_kind', 
          order='K', dtype=None, subok=True[, signature, extobj]) = <ufunc 'sin'>


The np.sin() function takes one required argument as a parameter:

  1. x: This is the angle to be passed to the function. This is given in radians. This is the required parameter for calculating the sine value.
  2. out: We can specify the location where we want to store the output value. By default, None is kept as the value for this argument.
  3. where: If this condition is True, then the ufunc result is stored; if the condition is False, then the original value is retained.

Return value

It returns a single value. It returns the sine value for the angle passed inside the function. 

Example 1

# importing numpy as np
import numpy as np

# creating an numpy element
ele = np.pi / 4

# storing the sine value to the variable.
sine = np.sin(ele)



In this program, we imported the numpy library and created an element for storing the value of pi by 2 and using the numpy function called np.pi for using pi. Hence, the pi / 2 is stored in the variable named ele.

This angle is passed inside the function called sin(). This sin function finds the appropriate sine value from the angle. Finally, we have printed the sine value.

Example 2

# Importing numpy as np
import numpy as np

# Storing the sine value to the variable.
sine = np.sin(np.pi / 3)



In this program, we found the sine value for the angle of pi / 3. Then, we passed the angle inside the sin function to get the sine value.

That’s it.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.