Python – cmath.sin() function

cmath is Python built-in module that is used for complex number mathematics. cmath module has a method sin() that returns sine of the complex number passed to it.

Syntax: cmath.sin(Z)

Parameter: It requires only one parameter i.e the number for which sine needs to be calculated.

Return: Returns a complex number that is the sine of the number passed.

Example 1: 



Python3

filter_none

edit
close

play_arrow

link
brightness_4
code

# Import the Library
import cmath 
  
# Printing the result
print (cmath.sin(5 + 3j))

chevron_right


Output:

(-9.654125476854839+2.841692295606352j)

Example 2: In this example real number is passed but the returned result is still a complex number.

Python3

filter_none

edit
close

play_arrow

link
brightness_4
code

# Import the Library
import cmath 
  
# Printing the result
print (cmath.sin(1))

chevron_right


Output:

(0.8414709848078965+0j)

Example 3: In this example no argument is passed in this case TypeError will be thrown

Python3

filter_none

edit
close

play_arrow

link
brightness_4
code

# Import the Library
import cmath 
  
# Printing the result
print (cmath.sin())

chevron_right


Output:

TypeError: sin() takes exactly one argument (0 given)



My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.