Open In App

Complex Numbers in Python | Set 3 (Trigonometric and Hyperbolic Functions)

Last Updated : 15 Jul, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

Some of the Important Complex number functions are discussed in the articles below

Complex Numbers in Python | Set 1 (Introduction)
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 argument.

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

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




# Python code to demonstrate the working of 
# sin(), cos(), tan()
   
# importing "cmath" for complex number operations
import cmath
   
# Initializing real numbers
x = 1.0
   
y = 1.0
  
# converting x and y into complex number z
z = complex(x,y);
  
# printing sine of the complex number
print ("The sine value of complex number is : ",end="")
print (cmath.sin(z))
  
# printing cosine of the complex number
print ("The cosine value of complex number is : ",end="")
print (cmath.cos(z))
  
# printing tangent of the complex number
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 arc sine of the complex number passed in argument.

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

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




# Python code to demonstrate the working of 
# asin(), acos(), atan()
   
# importing "cmath" for complex number operations
import cmath
   
# Initializing real numbers
x = 1.0
   
y = 1.0
  
# converting x and y into complex number z
z = complex(x,y);
  
# printing arc sine of the complex number
print ("The arc sine value of complex number is : ",end="")
print (cmath.asin(z))
  
# printing arc cosine of the complex number
print ("The arc cosine value of complex number is : ",end="")
print (cmath.acos(z))
  
# printing arc tangent of the complex 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.0612750619050357j)
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 argument.

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

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




# Python code to demonstrate the working of 
# sinh(), cosh(), tanh()
   
# importing "cmath" for complex number operations
import cmath
   
# Initializing real numbers
x = 1.0
   
y = 1.0
  
# converting x and y into complex number z
z = complex(x,y);
  
# printing hyperbolic sine of the complex number
print ("The hyperbolic sine value of complex number is : ",end="")
print (cmath.sinh(z))
  
# printing hyperbolic cosine of the complex number
print ("The hyperbolic cosine value of complex number is : ",end="")
print (cmath.cosh(z))
  
# printing hyperbolic tangent of the 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.2717525853195117j)

4. asinh() : This function returns the inverse hyperbolic sine of the complex number passed in argument.

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

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




# Python code to demonstrate the working of 
# asinh(), acosh(), atanh()
   
# importing "cmath" for complex number operations
import cmath
   
# Initializing real numbers
x = 1.0
   
y = 1.0
  
# converting x and y into complex number z
z = complex(x,y);
  
# printing inverse hyperbolic sine of the complex number
print ("The inverse hyperbolic sine value of complex number is : ",end="")
print (cmath.asinh(z))
  
# printing inverse hyperbolic cosine of the complex number
print ("The inverse hyperbolic cosine value of complex number is : ",end="")
print (cmath.acosh(z))
  
# printing inverse hyperbolic tangent of the 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 tangent value of complex number is : (0.40235947810852507+1.0172219678978514j)


Similar Reads

Mathematical Functions in Python | Set 3 (Trigonometric and Angular Functions)
Some of the mathematical functions are discussed in below set 1 and set 2 Mathematical Functions in Python | Set 1 (Numeric Functions) Mathematical Functions in Python | Set 2 (Logarithmic and Power Functions) Trigonometric and angular functions are discussed in this article. 1. sin() :- This function returns the sine of value passed as argument. T
3 min read
Complex Numbers in Python | Set 2 (Important Functions and Constants)
Introduction to python complex numbers: Complex Numbers in Python | Set 1 (Introduction) Some more important functions and constants are discussed in this article. Operations on complex numbers : 1. exp() :- This function returns the exponent of the complex number mentioned in its argument. 2. log(x,b) :- This function returns the logarithmic value
4 min read
Compute the inverse hyperbolic tangent in Python
In this article, we will cover how to compute the inverse hyperbolic tangent in Python using NumPy. numpy.emath.arctanh methodThe inverse hyperbolic tangent is also called as arctanh or tanh-1. To compute the inverse hyperbolic tangent Python provides a method called arctanh which is present in numpy.emath package. arctanh method accepts an array o
2 min read
How to Compute the Inverse Cosine and Inverse Hyperbolic Cosine in PyTorch
In this article, we will see how to compute the inverse Cosine and Inverse Hyperbolic Cosine in Pytorch. torch.acos() torch.acos() is used to find the inverse cosine of elements in a given tensor. We can apply this function on real as well as complex tensors. Syntax: torch.acos(input_tensor) Parameter: It will take a tensor which can be real or com
3 min read
How to compute the inverse hyperbolic sine in PyTorch?
In this article, we are going to discuss how to compute the inverse hyperbolic sine in PyTorch. torch.asinh() method: The torch.asinh() method is used to compute the inverse hyperbolic sine of each element present in a given input tensor. This method accepts both real and complex-valued as input. It supports input tensors of any dimension. This met
3 min read
Complex Numbers in Python | Set 1 (Introduction)
Not only real numbers, Python can also handle complex numbers and its associated functions using the file "cmath". Complex numbers have their uses in many applications related to mathematics and python provides useful tools to handle and manipulate them. Converting real numbers to complex number An complex number is represented by " x + yi ". Pytho
3 min read
Python program for addition and subtraction of complex numbers
Given two complex numbers z1 and z2. The task is to add and subtract the given complex numbers.Addition of complex number: In Python, complex numbers can be added using + operator.Examples: Input: 2+3i, 4+5i Output: Addition is : 6+8i Input: 2+3i, 1+2i Output: Addition is : 3+5i Example : C/C++ Code # Python program to add # two complex numbers # f
2 min read
Replace infinity with large finite numbers and fill NaN for complex input values using NumPy in Python
In this article, we will cover how to fill Nan for complex input values and infinity values with large finite numbers in Python using NumPy. Example: Input: [complex(np.nan,np.inf)] Output: [1000.+1.79769313e+308j] Explanation: Replace Nan with complex values and infinity values with large finite. numpy.nan_to_num method The numpy.nan_to_num method
3 min read
Mathematical Functions in Python | Set 2 (Logarithmic and Power Functions)
Numeric functions are discussed in set 1 below Mathematical Functions in Python | Set 1 ( Numeric Functions) Logarithmic and power functions are discussed in this set. 1. exp(a) :- This function returns the value of e raised to the power a (e**a) . 2. log(a, b) :- This function returns the logarithmic value of a with base b. If base is not mentione
3 min read
Mathematical Functions in Python | Set 4 (Special Functions and Constants)
Some of the mathematical functions are discussed in below set 1, set 2 and set 3 Mathematical Functions in Python | Set 1 (Numeric Functions) Mathematical Functions in Python | Set 2 (Logarithmic and Power Functions) Mathematical Functions in Python | Set 3 (Trigonometric and Angular Functions) Special Functions and constants are discussed in this
2 min read
Article Tags :
Practice Tags :