Get the Trigonometric sin of an angle in Python


To find the Trigonometric sine of an angle, use the numpy.sin() method in Python Numpy. The method returns the sine of each element of the 1st parameter x. The 1st parameter, x, is an Angle, in radians (2pi means 360 degrees). The 2nd and 3rd parameters are optional.

The 2nd parameter is an ndarray, A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs. 

The 3rd parameter is the condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default out=None, locations within it where the condition is False will remain uninitialized.

Steps

At first, import the required library −

import numpy as np

Get the Trigonometric sine. Finding sin 90 degrees −

print("\nResult...",np.sin(np.pi/2.))

Finding sin 60 degrees −

print("\nResult...",np.sin(np.pi/3.))

Finding sin 45 degrees −

print("\nResult...",np.sin(np.pi/4.))

Finding sin 0 degrees −

print("\nResult...",np.sin(0))

Example

import numpy as np

# To find the Trigonometric sine of an angle, use the numpy.sin() method in Python Numpy
# The method returns the sine of each element of the 1st parameter x. This is a scalar if is a scalar.

print("Get the Trigonometric sine...")

# finding sin 90 degrees
print("\nResult...",np.sin(np.pi/2.))

# finding sin 60 degrees
print("\nResult...",np.sin(np.pi/3.))

# finding sin 45 degrees
print("\nResult...",np.sin(np.pi/4.))

# finding sin 30 degrees
print("\nResult...",np.sin(np.pi/6.))

# finding sin 0 degrees
print("\nResult...",np.sin(0))

Output

Get the Trigonometric sine...

Result... 1.0

Result... 0.8660254037844386

Result... 0.7071067811865475

Result... 0.49999999999999994

Result... 0.0

Updated on: 25-Feb-2022

2K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements