Change language

Complex Numbers in Python | Set 3 (trigonometric and hyperbolic functions)

|

Complex Numbers in Python | Set 2 (Important Functions and Constants)

Trigonometric and hyperbolic functions are discussed in this article.

Trigonometric functions

1. sin () : This function returns the sine of the complex number passed in the argument.

2. cos () : This function returns the cosine of the complex number passed in the argument.

3. tan () : This function returns the tangent of the complex number passed in the argument.

# Python code for demonstration work
# sin (), cos (), tan ()

 
# import & quot; cmath & quot; for operations with complex numbers

import cmath

 
# Initializing real numbers

x = 1.0

 

y = 1.0

 
# convert x and y to complex z

z = complex (x, y); 

 
# printing the sine of a complex number

print ( "The sine value of complex number is:" , end = "")

print (cmath.sin (z))

 
# printing the cosine of a complex number

print ( "The cosine value of complex number is:" , end = "")

print (cmath .cos (z))

 
# complex number print tangent

print ( "The tangent value of complex number is: " , end = " ")

print (cmath.tan (z))

Output:

 The sine value of complex number is: (1.2984575814159773 + 0.6349639147847361j) The cosine value of complex number is: (0.8337300251311491-0.9888977057628651j) The tangent value of complex number is: (0.2717525853195118 + 1.0839233273386946j) 

4. asin () : This function returns the arcsine of the complex number passed in the argument.

5. acos () : This function returns the inverse cosine of the complex number passed in the argument.

6. atan () : This function returns the arctangent of the complex number passed in the argument.

# Python code for demonstration work
# asin (), acos (), atan ()

 
# import & quot; cmath & quot; for operations with complex numbers

import cmath

 
# Initializing real numbers

x = 1.0

 

y = 1.0

 
# convert x and y to complex z

z = complex (x, y); 

 
# printing the sine arc of a complex number

print ( "The arc sine value of complex number is:" , end = "")

print (cmath.asin (z))

 
# printing the arccosine of a complex number

print ( " The arc cosine value of complex number is: " , end = " ")

print (cmath.acos (z))

 
# print arctangent comp lex number

print ( "The arc tangent value of complex number is: " , end = " ")

print (cmath.atan (z))

Output:

 The arc sine value of complex number is: (0.6662394324925153 + 1.0612750619050357 j) The arc cosine value of complex number is: (0.9045568943023814-1.0612750619050357j) The arc tangent value of complex number is: (1.0172219678978514 + 0.40235947810852507j) 

Hyperbolic functions

1. sinh () : This function returns the hyperbolic sine of the complex number passed in the argument.

2. cosh () : This function returns the hyperbolic cosine of the complex number passed in the argument.

3. tanh () : This function returns the hyperbolic tangent of the complex number passed in the argument.

# Python code for demonstrations
# sinh (), cosh (), tanh ()

 
# import & quot; cmath & quot; for operations with complex numbers

import cmath

 
# Initializing real numbers

x = 1.0

 

y = 1.0

 
# convert x and y to complex z

z = complex (x, y); 

 
# printing the hyperbolic sine of a complex number

print ( "The hyperbolic sine value of complex number is:" , end = "")

print (cmath.sinh (z))

 
# printing the hyperbolic cosine of a complex number

print ( "The hyperbolic cosine value of complex number is:" , end = "")

print (cmath.cosh (z))

  
# printing the hyperbolic tangent of a complex number

print ( "The hyperbolic tangent value of complex number is:" , end = "")

print (cmath.tanh (z))

Output:

 The hyperbolic sine value of complex number is: (0.6349639147847361 + 1.2984575814159773j) The hyperbolic cosine value of complex number is: (0.8337300251311491 + 0.9888977057628651j) The hyperbolic tangent value of complex number is: (1.0839233273386946 + 0.2711725853195 p>  4. asinh () : This function returns the  inverse hyperbolic sine  of the complex number passed in the argument. 

5. acosh () : This function returns the inverse hyperbolic cosine of the complex number passed in the argument.

6. atanh () : This function returns the inverse hyperbolic tangent of the complex number passed in the argument.

# Python code to demonstrate how it works
# asinh (), acosh (), atanh ()

  
# import & quot; cmath & quot; for operations with complex numbers

import cmath

 
# Initializing real numbers

x = 1.0

 

y = 1.0

 
# convert x and y to complex z

z = complex (x, y); 

 
# print the inverse hyperbolic sine of a complex number

print ( "The inverse hyperbolic sine value of complex number is:" , end = "")

print (cmath.asinh (z))

 
# print the inverse hyperbolic cosine of a complex number

print ( "The inverse hyperbolic cosine value of complex number is:" , end = "")

print (cmath.acosh (z))

  
# print the inverse hyperbolic tangent of a complex number

print ( "The inverse hyperbolic tangent value of complex number is:" , end = "")

print (cmath.atanh (z))

Output:

 The inverse hyperbolic sine value of complex number is: (1.0612750619050357 + 0.6662394324925153j) The inverse hyperbolic cosine value of complex number is: (1.0612750619050357 + 0.9045568943023813j) The inverse hyperbolic tangolic of complex number is: (0.40235947810852507 + 1.0172219678978514j) 

This article courtesy of Manjit Singh . If you are as Python.Engineering and would like to contribute, you can also write an article using contribute.python.engineering or by posting an article contribute @ python.engineering. See my article appearing on the Python.Engineering homepage and help other geeks.

Please post comments if you find anything wrong or if you would like to share more information on the topic discussed above.

Shop

Learn programming in R: courses

$

Best Python online courses for 2022

$

Best laptop for Fortnite

$

Best laptop for Excel

$

Best laptop for Solidworks

$

Best laptop for Roblox

$

Best computer for crypto mining

$

Best laptop for Sims 4

$

Latest questions

NUMPYNUMPY

Common xlabel/ylabel for matplotlib subplots

12 answers

NUMPYNUMPY

How to specify multiple return types using type-hints

12 answers

NUMPYNUMPY

Why do I get "Pickle - EOFError: Ran out of input" reading an empty file?

12 answers

NUMPYNUMPY

Flake8: Ignore specific warning for entire file

12 answers

NUMPYNUMPY

glob exclude pattern

12 answers

NUMPYNUMPY

How to avoid HTTP error 429 (Too Many Requests) python

12 answers

NUMPYNUMPY

Python CSV error: line contains NULL byte

12 answers

NUMPYNUMPY

csv.Error: iterator should return strings, not bytes

12 answers


Wiki

Python | How to copy data from one Excel sheet to another

Common xlabel/ylabel for matplotlib subplots

Check if one list is a subset of another in Python

sin

How to specify multiple return types using type-hints

exp

Printing words vertically in Python

exp

Python Extract words from a given string

Cyclic redundancy check in Python

Finding mean, median, mode in Python without libraries

cos

Python add suffix / add prefix to strings in a list

Why do I get "Pickle - EOFError: Ran out of input" reading an empty file?

Python - Move item to the end of the list

Python - Print list vertically