Author name: Vikram Chiluka

Python cmath.atanh() Method with Examples

cmath.atanh() Method in Python:

The cmath.atanh() method returns the complex number’s inverse hyperbolic tangent.

There are two types of branch cuts:

  1. Extends along the real axis from 1 to ∞, and is continuous from below.
  2. Extends along the real axis from -1 to -∞, and is continuous from above.

Syntax:

cmath.atanh(x)

Parameters

x: This is Required. It is a number used to calculate the inverse hyperbolic arctangent of

Return Value:

Returns a complex value that represents the complex number’s inverse hyperbolic tangent.

Examples:

Example1:

Input:

Given Complex Number = 3-4j

Output:

The given complex number's (3-4j) inverse hyperbolic tangent value = 
(0.1175009073114339-1.4099210495965755j)

Example2:

Input:

Given realpart = 5
Given imaginary part = 3

Output:

The given complex number's (5+3j) inverse hyperbolic tangent value = 
(0.14694666622552977+1.4808695768986575j)

Note: The above input format is for dynamic input.

cmath.atanh() Method with Examples in Python

Method #1: Using Built-in Functions (Static Input)

Approach:

  • Import cmath module(for complex number operations) using the import keyword.
  • Give the complex number as static input and store it in a variable.
  • Pass the given complex number as an argument to the cmath.atanh() method that returns the given complex number’s inverse hyperbolic tangent value.
  • Store it in another variable.
  • Print the inverse hyperbolic tangent value of the given complex number.
  • The Exit of the Program.

Below is the implementation:

# Import cmath module(for complex number operations) using the import keyword.
import cmath
# Give the complex number as static input and store it in a variable.
complexnumb = 3-4j
# Pass the given complex number as an argument to the cmath.atanh() method that
# returns the given complex number's inverse hyperbolic tangent value.
# Store it in another variable.
rslt = cmath.atanh(complexnumb)
# Print the inverse hyperbolic tangent value of the given complex number.
print("The given complex number's", complexnumb,
      "inverse hyperbolic tangent value = ")
print(rslt)

Output:

The given complex number's (3-4j) inverse hyperbolic tangent value = 
(0.1175009073114339-1.4099210495965755j)

Method #2: Using Built-in Functions (User Input)

Approach:

  • Import cmath module(for complex number operations) using the import keyword.
  • Give the real part and imaginary part of the complex number as user input using map(), int(), split().
  • Store it in two variables.
  • Using a complex() function convert those two variables into a complex number and store it in a variable.
  • Pass the given complex number as an argument to the cmath.atanh() method that returns the given complex number’s inverse hyperbolic tangent value.
  • Store it in another variable.
  • Print the inverse hyperbolic tangent value of the given complex number.
  • The Exit of the Program.

Below is the implementation:

# Import cmath module(for complex number operations) using the import keyword.
import cmath
# Give the real part and imaginary part of the complex number as user input
# using map(), int(), split().
# Store it in two variables.
realnumb, imaginarynumb = map(int, input(
    'Enter real part and complex part of the complex number = ').split())
# Using a complex() function convert those two variables into a complex number.
complexnumb = complex(realnumb, imaginarynumb)

# Pass the given complex number as an argument to the cmath.atanh() method that
# returns the given complex number's inverse hyperbolic tangent value.
# Store it in another variable.
rslt = cmath.atanh(complexnumb)
# Print the inverse hyperbolic tangent value of the given complex number.
print("The given complex number's", complexnumb,
      "inverse hyperbolic tangent value = ")
print(rslt)

Output:

Enter real part and complex part of the complex number = 5 3
The given complex number's (5+3j) inverse hyperbolic tangent value = 
(0.14694666622552977+1.4808695768986575j)

Python cmath.atanh() Method with Examples Read More »

Python cmath.rect() Method with Examples

cmath.rect() Method in Python:

The cmath.rect() method converts polar coordinates to the complex number’s rectangular form. It generates a complex number that includes phase and modulus.

This method equals r * (math.cos(phi) + math.sin(phi)*1j).

The radius r is the vector’s length, and phi (phase angle) is the angle formed with the real axis.

Syntax:

cmath.rect(r, phi)

Parameters

r: This is Required. The modulus of a complex number is represented by this symbol.

phi: This is Required. It represents a complex number’s phase.

Return Value:

Returns a complex value that represents a complex number in its rectangular form.

Examples:

Example1:

Input:

Given modulus = 2.135667
Given phase = 6.1111116

Output:

The rectangular form of the complex number =  (2.104127071172476-0.3656812864341552j)

Example2:

Input:

Given modulus = 5
Given phase = 2

Output:

The rectangular form of the complex number =  (-2.080734182735712+4.546487134128409j)

cmath.rect() Method with Examples in Python

Method #1: Using Built-in Functions (Static Input)

Approach:

  • Import cmath module(for complex number operations) using the import keyword.
  • Give the modulus of a complex number (r) as static input and store it in a variable.
  • Give the phase of a complex number (phi) as static input and store it in another variable.
  • Pass the given modulus, phase of a complex number as the arguments to the cmath.rect() method which returns a complex value that represents the complex number in its rectangular form.
  • Store it in another variable.
  • Print a complex value that represents the complex number in its rectangular form.
  • The Exit of the Program.

Below is the implementation:

# Import cmath module(for complex number operations) using the import keyword.
import cmath
# Give the modulus of a complex number (r) as static input and store it in a variable.
gvn_moduls_val = 2.135667
# Give the phase of a complex number (phi) as static input and store it
# in another variable.
gvn_phasee_val = 6.1111116
# Pass the given modulus, phase of a complex number as the arguments to the
# cmath.rect() method which returns a complex value that represents the
# complex number in its rectangular form.
# Store it in another variable.
rslt = cmath.rect(gvn_moduls_val, gvn_phasee_val)
# Print a complex value that represents the complex number in its rectangular form.
print("The rectangular form of the complex number = ", rslt)

Output:

The rectangular form of the complex number =  (2.104127071172476-0.3656812864341552j)

Similarly, try for the other examples

import cmath
gvn_moduls_val = 5
gvn_phasee_val = 2
rslt = cmath.rect(gvn_moduls_val, gvn_phasee_val)
print("The rectangular form of the complex number = ", rslt)

Output:

The rectangular form of the complex number =  (-2.080734182735712+4.546487134128409j)

Method #2: Using Built-in Functions (User Input)

Approach:

  • Import cmath module(for complex number operations) using the import keyword.
  • Give the modulus of a complex number (r) as user input using the float(input()) function and store it in a variable.
  • Give the phase of a complex number (phi) as user input using the float(input()) function and store it in another variable.
  • Pass the given modulus, phase of a complex number as the arguments to the cmath.rect() method which returns a complex value that represents the complex number in its rectangular form.
  • Store it in another variable.
  • Print a complex value that represents the complex number in its rectangular form.
  • The Exit of the Program.

Below is the implementation:

# Import cmath module(for complex number operations) using the import keyword.
import cmath
# Give the modulus of a complex number (r) as user input using the float(input()) function
# and store it in a variable.
gvn_moduls_val = float(input("Enter some random number = "))
# Give the phase of a complex number (phi) as user input using the float(input()) function
# and store it in another variable.
gvn_phasee_val = float(input("Enter some random number = "))
# Pass the given modulus, phase of a complex number as the arguments to the
# cmath.rect() method which returns a complex value that represents the
# complex number in its rectangular form.
# Store it in another variable.
rslt = cmath.rect(gvn_moduls_val, gvn_phasee_val)
# Print a complex value that represents the complex number in its rectangular form.
print("The rectangular form of the complex number = ", rslt)

Output:

Enter some random number = 1.56
Enter some random number = 2.34546
The rectangular form of the complex number = (-1.0911821806705588+1.1148638699801174j)

Python cmath.rect() Method with Examples Read More »

Python cmath.isfinite() Method with Examples

cmath.isfinite() Method in Python:

The cmath.isfinite() method determines whether or not a given complex value is finite.

This method gives the following Boolean value: If the value is finite, True; otherwise, False.

Syntax:

cmath.isfinite(x)

Parameters

x: This is Required. It is the value that is used to determine whether it is finite or not.

Return Value:

Returns a boolean value that is True if the value is finite and False otherwise.

Examples:

Example1:

Input:

Given Complex Number = float('inf')+ 7j

Output:

Check if the given complex number (inf+7j) is finite or not =  False

Example2:

Input:

Given realpart = 5
Given imaginary part = 2

Output:

Check if the given complex number (5+2j) is finite or not = True

Note: The above input format is for dynamic input.

cmath.isfinite() Method with Examples in Python

Method #1: Using Built-in Functions (Static Input)

Approach:

  • Import cmath module(for complex number operations) using the import keyword.
  • Give the complex number as static input and store it in a variable.
  • Pass the given complex number as an argument to the cmath.isfinite() method that returns a boolean value that is True if the given complex number is finite and False otherwise.
  • Store it in another variable.
  • Print the above result after checking if the given complex number is finite or not.
  • The Exit of the Program.

Below is the implementation:

# Import cmath module(for complex number operations) using the import keyword.
import cmath
# Give the complex number as static input and store it in a variable.
complexnumb = 3+4j
# Pass the given complex number as an argument to the cmath.isfinite() method
# that returns a boolean value that is True if the given complex number is
# finite and False otherwise.
# Store it in another variable.
rslt = cmath.isfinite(complexnumb)
# Print the above result after checking if the given complex number is finite or not.
print("Check if the given complex number",
      complexnumb, "is finite or not = ", rslt)

Output:

Check if the given complex number (3+4j) is finite or not =  True

Similarly, try for the other examples

import cmath
complexnumb = complex(3, float('inf'))
rslt = cmath.isfinite(complexnumb)
print("Check if the given complex number",
      complexnumb, "is finite or not = ", rslt)

Output:

Check if the given complex number (3+infj) is finite or not =  False
import cmath
complexnumb = float('inf')+ 7j
rslt = cmath.isfinite(complexnumb)
print("Check if the given complex number",
      complexnumb, "is finite or not = ", rslt)

Output:

Check if the given complex number (inf+7j) is finite or not =  False

Method #2: Using Built-in Functions (User Input)

Approach:

  • Import cmath module(for complex number operations) using the import keyword.
  • Give the real part and imaginary part of the complex number as user input using map(), int(), split().
  • Store it in two variables.
  • Using a complex() function convert those two variables into a complex number and store them in a variable.
  • Pass the given complex number as an argument to the cmath.isfinite() method that returns a boolean value that is True if the given complex number is finite and False otherwise.
  • Store it in another variable.
  • Print the above result after checking if the given complex number is finite or not.
  • The Exit of the Program.

Below is the implementation:

# Import cmath module(for complex number operations) using the import keyword.
import cmath
# Give the real part and imaginary part of the complex number as user input
# using map(), int(), split().
# Store it in two variables.
realnumb, imaginarynumb = map(int, input(
    'Enter real part and complex part of the complex number = ').split())
# Using a complex() function convert those two variables into a complex number.
complexnumb = complex(realnumb, imaginarynumb)

# Pass the given complex number as an argument to the cmath.isfinite() method
# that returns a boolean value that is True if the given complex number is
# finite and False otherwise.
# Store it in another variable.
rslt = cmath.isfinite(complexnumb)
# Print the above result after checking if the given complex number is finite or not.
print("Check if the given complex number",
      complexnumb, "is finite or not = ", rslt)

Output:

Enter real part and complex part of the complex number = 5 2
Check if the given complex number (5+2j) is finite or not = True

Python cmath.isfinite() Method with Examples Read More »

Python cmath.isclose() Method with Examples

cmath.isclose() Method in Python:

The cmath.isclose() method determines whether or not two complex values are close. This method gives the following Boolean value: If the values are close, True; otherwise, False.

To determine whether the values are close, this method employs either a relative tolerance or an absolute tolerance.

It compares the values using the following formula:

abs(a-b) <= max(rel_tol * max(abs(a), abs(b)), abs_tol)

Syntax:

cmath.isclose(a, b, rel_tol= value, abs_tol= value)

Parameters

a: This is Required. The first value used to determine closeness

b: This is Required. The second value used to determine closeness

rel_tol: This is Optional. It is relative tolerance. It is the greatest (maximum) possible difference between values a and b. 1e-09 is the default value.

abs_tol: This is Optional. The absolute minimum tolerance. It is used to compare values close to zero. The value must be greater than zero.

Return Value:

Returns a true or false value. If the values are close, True; otherwise, False.

Examples:

Example1:

Input:

Given first Complex Number = 3+4j
Given second Complex Number = 3+4j

Output:

Checking if the given two complex values are close or not = True

Example2:

Input:

Given first Complex Number = 5+2j
Given second Complex Number = 5+26j

Output:

Checking if the given two complex values are close or not = False

cmath.isclose() Method with Examples in Python

Method #1: Using Built-in Functions (Static Input)

Approach:

  • Import cmath module(for complex number operations) using the import keyword.
  • Give the first complex number as static input and store it in a variable.
  • Give the second complex number as static input and store it in another variable.
  • Pass the given two complex numbers as the arguments to the cmath.isclose() method that determines whether or not given two complex values is close.
  • Store it in another variable.
  • Print the above result.
  • The Exit of the Program.

Below is the implementation:

# Import cmath module(for complex number operations) using the import keyword.
import cmath
# Give the complex number as static input and store it in a variable.
complexnumb1 = 3+4j
# Give the second complex number as static input and store it in another variable.
complexnumb2 = 3+4j
# Pass the given two complex numbers as the arguments to the cmath.isclose()
# method that determines whether or not given two complex values are close.
# Store it in another variable.
rslt = cmath.isclose(complexnumb1, complexnumb2)
# Print the above result
print("Checking if the given two complex values are close or not =", rslt)

Output:

Checking if the given two complex values are close or not = True

With giving absolute tolerance

Approach:

  • Import cmath module(for complex number operations) using the import keyword.
  • Give the first complex number as static input and store it in a variable.
  • Give the second complex number as static input and store it in another variable.
  • Pass the given two complex numbers and absolute tolerance as some random number as the arguments to the cmath.isclose() method that determines whether or not given two complex values is close.
  • Store it in another variable.
  • Print the above result.
  • The Exit of the Program.

Below is the implementation:

# Import cmath module(for complex number operations) using the import keyword.
import cmath
# Give the complex number as static input and store it in a variable.
complexnumb1 = 5+2j
# Give the second complex number as static input and store it in another variable.
complexnumb2 = 5+2j
# Pass the given two complex numbers and absolute tolerance as some random number
# as the arguments to the cmath.isclose() method that determines whether or
# not given two complex values are close.
# Store it in another variable.
rslt = cmath.isclose(complexnumb1, complexnumb2, abs_tol=0.005)
# Print the above result
print("Checking if the given two complex values are close or not =", rslt)

Output:

Checking if the given two complex values are close or not = True

Method #2: Using Built-in Functions (User Input)

Approach:

  • Import cmath module(for complex number operations) using the import keyword.
  • Give the real part and imaginary part of the first complex number as user input using map(), int(), split().
  • Store it in two variables.
  • Using a complex() function convert those two variables into a complex number and store them in a variable.
  • Give the real part and imaginary part of the second complex number as user input using map(), int(), split().
  • Store it in two variables.
  • Using a complex() function convert those two variables into a complex number and store them in a variable.
  • Pass the given two complex numbers as the arguments to the cmath.isclose() method that determines whether or not given two complex values is close.
  • Store it in another variable.
  • Print the above result.
  • The Exit of the Program.

Below is the implementation:

# Import cmath module(for complex number operations) using the import keyword.
import cmath
# Give the real part and imaginary part of the first complex number as user input
# using map(), int(), split().
# Store it in two variables.
realnumb1, imaginarynumb1 = map(int, input(
    'Enter real part and complex part of the complex number = ').split())
# Using a complex() function convert those two variables into a complex number.
complexnumb1 = complex(realnumb1, imaginarynumb1)
# Give the real part and imaginary part of the second complex number as user input
# using map(), int(), split().
# Store it in two variables.
realnumb2, imaginarynumb2 = map(int, input(
    'Enter real part and complex part of the complex number = ').split())
# Using a complex() function convert those two variables into a complex number.
complexnumb2 = complex(realnumb2, imaginarynumb2)

# Pass the given two complex numbers as the arguments to the cmath.isclose()
# method that determines whether or not given two complex values are close.
# Store it in another variable.
rslt = cmath.isclose(complexnumb1, complexnumb2)
# Print the above result
print("Checking if the given two complex values are close or not =", rslt)

Output:

Enter real part and complex part of the complex number = 5 2
Enter real part and complex part of the complex number = 3 2
Checking if the given two complex values are close or not = False

Python cmath.isclose() Method with Examples Read More »

Python cmath.atan() Method with Examples

cmath.atan() Method in Python:

The cmath.atan() method returns the complex number’s arc tangent.

There are primarily two types of branch cuts:

  1. Extend from 1j along the imaginary axis to ∞ j to the right.
  2. Extending from -1j to -∞ j to the left along the imaginary axis

Syntax:

cmath.atan(x)

Parameters

x: This is Required. A number used to calculate the arc tangent of

Return Value:

Returns a complex value that represents the complex number’s arc tangent.

Examples:

Example1:

Input:

Given Complex Number = 3+4j

Output:

The given complex number's (3+4j) arc tangent value = 
(1.4483069952314644+0.15899719167999918j)

Example2:

Input:

Given realpart = 5
Given imaginary part = 2

Output:

The given complex number's (5+2j) arc tangent value = 
(1.399284356584545+0.06706599664866984j)

Note: The above input format is for dynamic input.

cmath.atan() Method with Examples in Python

Method #1: Using Built-in Functions (Static Input)

Approach:

  • Import cmath module(for complex number operations) using the import keyword.
  • Give the complex number as static input and store it in a variable.
  • Pass the given complex number as an argument to the cmath.atan() method that returns the given complex number’s arc tangent value.
  • Store it in another variable.
  • Print the arc tangent value of the given complex number.
  • The Exit of the Program.

Below is the implementation:

# Import cmath module(for complex number operations) using the import keyword.
import cmath
# Give the complex number as static input and store it in a variable.
complexnumb = 3+4j
# Pass the given complex number as an argument to the cmath.atan() method that
# returns the the given complex number's arc tangent value.
# Store it in another variable.
rslt = cmath.atan(complexnumb)
# Print the arc tangent value of the given complex number.
print("The given complex number's", complexnumb,
      "arc tangent value = ")
print(rslt)

Output:

The given complex number's (3+4j) arc tangent value = 
(1.4483069952314644+0.15899719167999918j)

Method #2: Using Built-in Functions (User Input)

Approach:

  • Import cmath module(for complex number operations) using the import keyword.
  • Give the real part and imaginary part of the complex number as user input using map(), int(), split().
  • Store it in two variables.
  • Using a complex() function convert those two variables into a complex number and store it in a variable.
  • Pass the given complex number as an argument to the cmath.atan() method that returns the given complex number’s arc tangent value.
  • Store it in another variable.
  • Print the arc tangent value of the given complex number.
  • The Exit of the Program.

Below is the implementation:

# Import cmath module(for complex number operations) using the import keyword.
import cmath
# Give the real part and imaginary part of the complex number as user input
# using map(), int(), split().
# Store it in two variables.
realnumb, imaginarynumb = map(int, input(
    'Enter real part and complex part of the complex number = ').split())
# Using a complex() function convert those two variables into a complex number.
complexnumb = complex(realnumb, imaginarynumb)

# Pass the given complex number as an argument to the cmath.atan() method that
# returns the the given complex number's arc tangent value.
# Store it in another variable.
rslt = cmath.atan(complexnumb)
# Print the arc tangent value of the given complex number.
print("The given complex number's", complexnumb,
      "arc tangent value = ")
print(rslt)

Output:

Enter real part and complex part of the complex number = 5 2
The given complex number's (5+2j) arc tangent value = 
(1.399284356584545+0.06706599664866984j)

Python cmath.atan() Method with Examples Read More »

Python cmath.asinh() Method with Examples

cmath.asinh() Method in Python:

The cmath.asinh() method returns a number’s inverse hyperbolic sine.

There are primarily two types of branch cuts:

  1. Extend from 1j along the imaginary axis to ∞ j to the right.
  2. Extending from -1j to -∞ j to the left along the imaginary axis

Syntax:

cmath.asinh(x)

Parameters

x: This is Required. The number used to calculate the inverse hyperbolic sine of

Return Value:

Returns a complex value that represents the complex number’s inverse hyperbolic sine.

Examples:

Example1:

Input:

Given Complex Number = 3+4j

Output:

The given complex number's (3+4j) inverse hyperbolic sine value = 
(2.2999140408792695+0.9176168533514787j)

Example2:

Input:

Given realpart = 5
Given imaginary part = 2

Output:

The given complex number's (5+2j) inverse hyperbolic sine value = 
(2.3830308809003258+0.374670804825527j)

Note: The above input format is for dynamic input.

cmath.asinh() Method with Examples in Python

Method #1: Using Built-in Functions (Static Input)

Approach:

  • Import cmath module(for complex number operations) using the import keyword.
  • Give the complex number as static input and store it in a variable.
  • Pass the given complex number as an argument to the cmath.asinh() method that returns the given complex number’s inverse hyperbolic sine value.
  • Store it in another variable.
  • Print the inverse hyperbolic sine value of the given complex number.
  • The Exit of the Program.

Below is the implementation:

# Import cmath module(for complex number operations) using the import keyword.
import cmath
# Give the complex number as static input and store it in a variable.
complexnumb = 3+4j
# Pass the given complex number as an argument to the cmath.asinh() method that
# returns the given complex number's inverse hyperbolic sine value.
# Store it in another variable.
rslt = cmath.asinh(complexnumb)
# Print the inverse hyperbolic sine value of the given complex number.
print("The given complex number's", complexnumb,
      "inverse hyperbolic sine value = ")
print(rslt)

Output:

The given complex number's (3+4j) inverse hyperbolic sine value = 
(2.2999140408792695+0.9176168533514787j)

Method #2: Using Built-in Functions (User Input)

Approach:

  • Import cmath module(for complex number operations) using the import keyword.
  • Give the real part and imaginary part of the complex number as user input using map(), int(), split().
  • Store it in two variables.
  • Using a complex() function convert those two variables into a complex number and store it in a variable.
  • Pass the given complex number as an argument to the cmath.asinh() method that returns the given complex number’s inverse hyperbolic sine value.
  • Store it in another variable.
  • Print the inverse hyperbolic sine value of the given complex number.
  • The Exit of the Program.

Below is the implementation:

# Import cmath module(for complex number operations) using the import keyword.
import cmath
# Give the real part and imaginary part of the complex number as user input
# using map(), int(), split().
# Store it in two variables.
realnumb, imaginarynumb = map(int, input(
    'Enter real part and complex part of the complex number = ').split())
# Using a complex() function convert those two variables into a complex number.
complexnumb = complex(realnumb, imaginarynumb)

# Pass the given complex number as an argument to the cmath.asinh() method that
# returns the given complex number's inverse hyperbolic sine value.
# Store it in another variable.
rslt = cmath.asinh(complexnumb)
# Print the inverse hyperbolic sine value of the given complex number.
print("The given complex number's", complexnumb,
      "inverse hyperbolic sine value = ")
print(rslt)

Output:

Enter real part and complex part of the complex number = 5 2
The given complex number's (5+2j) inverse hyperbolic sine value = 
(2.3830308809003258+0.374670804825527j)

Python cmath.asinh() Method with Examples Read More »

Python cmath.asin() Method with Examples

cmath.asin() Method in Python:

The cmath.asin() method returns the complex number’s arc sine.

There are two types of branch cuts:

  1. Extends right from 1 to ∞ along the real axis.
  2. Extends left along the real axis from -1 to -∞

Syntax:

cmath.asin(x)

Parameters

x: This is Required. A number that can be used to calculate the arc sine of

Return Value:

Returns a complex value that represents the complex number’s arc sine.

Examples:

Example1:

Input:

Given Complex Number = 4+2j

Output:

The given complex number's (4+2j) arc sine value  = 
(1.096921548830143+2.183585216564564j)

Example2:

Input:

Given realpart = 5
Given imaginary part = 2

Output:

The given complex number's (5+2j) arc sine value = 
(1.184231684275022+2.37054853731792j)

Note: The above input format is for dynamic input.

cmath.asin() Method with Examples in Python

Method #1: Using Built-in Functions (Static Input)

Approach:

  • Import cmath module(for complex number operations) using the import keyword.
  • Give the complex number as static input and store it in a variable.
  • Pass the given complex number as an argument to the cmath.asin() method that returns the given complex number’s arc sine value.
  • Store it in another variable.
  • Print the arc sine value of the given complex number.
  • The Exit of the Program.

Below is the implementation:

# Import cmath module(for complex number operations) using the import keyword.
import cmath
# Give the complex number as static input and store it in a variable.
complexnumb = 4+2j
# Pass the given complex number as an argument to the cmath.asin() method that
# returns the given complex number's arc sine value.
# Store it in another variable.
rslt = cmath.asin(complexnumb)
# Print the arc sine value of the given complex number.
print("The given complex number's", complexnumb,
      "arc sine value  = ")
print(rslt)

Output:

The given complex number's (4+2j) arc sine value  = 
(1.096921548830143+2.183585216564564j)

Method #2: Using Built-in Functions (User Input)

Approach:

  • Import cmath module(for complex number operations) using the import keyword.
  • Give the real part and imaginary part of the complex number as user input using map(), int(), split().
  • Store it in two variables.
  • Using a complex() function convert those two variables into a complex number and store it in a variable.
  • Pass the given complex number as an argument to the cmath.asin() method that returns the given complex number’s arc sine value.
  • Store it in another variable.
  • Print the arc sine value of the given complex number.
  • The Exit of the Program.

Below is the implementation:

# Import cmath module(for complex number operations) using the import keyword.
import cmath
# Give the real part and imaginary part of the complex number as user input
# using map(), int(), split().
# Store it in two variables.
realnumb, imaginarynumb = map(int, input(
    'Enter real part and complex part of the complex number = ').split())
# Using a complex() function convert those two variables into a complex number.
complexnumb = complex(realnumb, imaginarynumb)
# Pass the given complex number as an argument to the cmath.asin() method that
# returns the given complex number's arc sine value.
# Store it in another variable.
rslt = cmath.asin(complexnumb)
# Print the arc sine value of the given complex number.
print("The given complex number's", complexnumb,
      "arc sine value  = ")
print(rslt)

Output:

Enter real part and complex part of the complex number = 5 2
The given complex number's (5+2j) arc sine value = 
(1.184231684275022+2.37054853731792j)

Python cmath.asin() Method with Examples Read More »

Python cmath.acosh() Method with Examples

cmath.acosh() Method in Python:

The cmath.acosh() method returns the complex number’s inverse hyperbolic cosine.

There is one branch cut:

Extending left along the real axis from 1 to -∞ , continuous from above

Syntax:

cmath.acosh(x)

Parameters

x: This is Required. The number used to calculate the inverse hyperbolic cosine of

Return Value:

Returns a complex value that represents a number’s inverse hyperbolic arc cosine.

Examples:

Example1:

Input:

Given Complex Number = 3+4j

Output:

The given complex number's (3+4j) inverse hyperbolic cosine value  = 
(2.305509031243477+0.9368124611557198j)

Example2:

Input:

Given realpart = 5
Given imaginary part = 2

Output:

The given complex number's (5+2j) inverse hyperbolic cosine value = 
(2.37054853731792+0.38656464251987466j)

Note: The above input format is for dynamic input.

cmath.acosh() Method with Examples in Python

Method #1: Using Built-in Functions (Static Input)

Approach:

  • Import cmath module(for complex number operations) using the import keyword.
  • Give the complex number as static input and store it in a variable.
  • Pass the given complex number as an argument to the cmath.acosh() method that returns the given complex number’s inverse hyperbolic cosine value.
  • Store it in another variable.
  • Print the inverse hyperbolic cosine value of the given complex number.
  • The Exit of the Program.

Below is the implementation:

# Import cmath module(for complex number operations) using the import keyword.
import cmath
# Give the complex number as static input and store it in a variable.
gvn_numb = 3+4j
# Pass the given complex number as an argument to the cmath.acosh() method that
# returns the given complex number's inverse hyperbolic cosine value.
# Store it in another variable.
rslt = cmath.acosh(gvn_numb)
# Print the inverse hyperbolic cosine value of the given complex number.
print("The given complex number's", gvn_numb,
      "inverse hyperbolic cosine value  = ")
print(rslt)

Output:

The given complex number's (3+4j) inverse hyperbolic cosine value  = 
(2.305509031243477+0.9368124611557198j)

Method #2: Using Built-in Functions (User Input)

Approach:

  • Import cmath module(for complex number operations) using the import keyword.
  • Give the real part and imaginary part of the complex number as user input using map(), int(), split().
  • Store it in two variables.
  • Using a complex() function convert those two variables into a complex number and store it in a variable.
  • Pass the given complex number as an argument to the cmath.acosh() method that returns the given complex number’s inverse hyperbolic cosine value.
  • Store it in another variable.
  • Print the inverse hyperbolic cosine value of the given complex number.
  • The Exit of the Program.

Below is the implementation:

# Import cmath module(for complex number operations) using the import keyword.
import cmath
# Give the real part and imaginary part of the complex number as user input
# using map(), int(), split().
# Store it in two variables.
realnumb, imaginarynumb = map(int, input(
    'Enter real part and complex part of the complex number = ').split())
# Using a complex() function convert those two variables into a complex number.
complexnumb = complex(realnumb, imaginarynumb)
# Pass the given complex number as an argument to the cmath.acosh() method that
# returns the given complex number's inverse hyperbolic cosine value.
# Store it in another variable.
rslt = cmath.acosh(complexnumb)
# Print the inverse hyperbolic cosine value of the given complex number.
print("The given complex number's", complexnumb,
      "inverse hyperbolic cosine value  = ")
print(rslt)

Output:

Enter real part and complex part of the complex number = 5 2
The given complex number's (5+2j) inverse hyperbolic cosine value = 
(2.37054853731792+0.38656464251987466j)

Python cmath.acosh() Method with Examples Read More »

Python cmath.acos() Method with Examples

cmath.acos() Method in Python:

The cmath.acos() method returns the complex number’s arc cosine.

There are two types of branch cuts:

  1. Extends to the right from 1 to ∞ along the real axis.
  2. Extends to the left from -1 to -∞ along the real axis.

Syntax:

cmath.acos(x)

Parameters

x: This is Required. It is a number that can be used to calculate the arc cosine of

Return Value:

Returns a complex value that represents a number’s arc cosine.

If the return value is expressed as a real number, it has an imaginary part of 0.

Examples:

Example1:

Input:

Given Complex Number = 3+4j

Output:

The given complex number's (3+4j)  arc cosine value = 
(0.9368124611557198-2.305509031243477j)

Example2:

Input:

Given realpart = 5
Given imaginary part = 2

Output:

The given complex number's (5+2j)  arc cosine value = 
(0.38656464251987466-2.37054853731792j)

Note: The above input format is for dynamic input.

cmath.acos() Method with Examples in Python

Method #1: Using Built-in Functions (Static Input)

Approach:

  • Import cmath module(for complex number operations) using the import keyword.
  • Give the complex number as static input and store it in a variable.
  • Pass the given complex number as an argument to the cmath.acos() method that returns the given complex number’s arc cosine value.
  • Store it in another variable.
  • Print the arc cosine value of the given complex number.
  • The Exit of the Program.

Below is the implementation:

# Import cmath module(for complex number operations) using the import keyword.
import cmath
# Give the complex number as static input and store it in a variable.
gvn_numb = 3+4j
# Pass the given complex number as an argument to the cmath.acos() method that
# returns the given complex number's arc cosine value.
# Store it in another variable.
rslt = cmath.acos(gvn_numb)
# Print the arc cosine value of the given complex number.
print("The given complex number's", gvn_numb, " arc cosine value = ")
print(rslt)

Output:

The given complex number's (3+4j)  arc cosine value = 
(0.9368124611557198-2.305509031243477j)

Method #2: Using Built-in Functions (User Input)

Approach:

  • Import cmath module(for complex number operations) using the import keyword.
  • Give the real part and imaginary part of the complex number as user input using map(), int(), split().
  • Store it in two variables.
  • Using a complex() function convert those two variables into a complex number and store it in a variable.
  • Pass the given complex number as an argument to the cmath.acos() method that returns the given complex number’s arc cosine value.
  • Store it in another variable.
  • Print the arc cosine value of the given complex number.
  • The Exit of the Program.

Below is the implementation:

# Import cmath module(for complex number operations) using the import keyword.
import cmath
# Give the real part and imaginary part of the complex number as user input
# using map(), int(), split().
# Store it in two variables.
realnumb, imaginarynumb = map(int, input(
    'Enter real part and complex part of the complex number = ').split())
# Using a complex() function convert those two variables into a complex number.
complexnumb = complex(realnumb, imaginarynumb)
# Pass the given complex number as an argument to the cmath.acos() method that
# returns the given complex number's arc cosine value.
# Store it in another variable.
rslt = cmath.acos(complexnumb)
# Print the arc cosine value of the given complex number.
print("The given complex number's", complexnumb, " arc cosine value = ")
print(rslt)

Output:

Enter real part and complex part of the complex number = 5 2
The given complex number's (5+2j) arc cosine value = 
(0.38656464251987466-2.37054853731792j)

Python cmath.acos() Method with Examples Read More »

Python math.degrees() Method with Examples

math.degrees() Method in Python:

The math. degrees() method converts a radian angle to a degree angle.

PI (3.14… ) radians are equal to 180 degrees, so 1 radian equals 57.2957795 degrees.

Syntax:

math.degrees(x)

Parameters

x: This is Required. It is a number. A radian value that can be converted into a degree value.

If the parameter is not a number, a TypeError is returned.

Return Value:

Returns a float value indicating the value in degrees.

Examples:

Example1:

Input:

Given Angle = 7.5

Output:

The given angle{ 7.5 } in degrees =  429.7183463481174

Example2:

Input:

Given Angle = 14

Output:

The given angle{ 14 } in degrees =  802.1409131831525

math.degrees() Method with Examples in Python

Method #1: Using Built-in Functions (Static Input)

Approach:

  • Import math module using the import keyword.
  • Give the number (angle) as static input and store it in a variable.
  • Pass the given angle as an argument to the math.degrees() function that converts the given radian angle to a degree angle.
  • Store it in another variable.
  • Print the given angle in degrees.
  • The Exit of the Program.

Below is the implementation:

# Import math module using the import keyword
import math
# Give the number(angle) as static input and store it in a variable.
gvn_angl = 7.5
# Pass the given angle as an argument to the math.degrees() function that
# converts the given radian angle to a degree angle.
# Store it in another variable.
degre_angl = math.degrees(gvn_angl)
# Print the given angle in degrees.
print("The given angle{", gvn_angl, "} in degrees = ", degre_angl)

Output:

The given angle{ 7.5 } in degrees =  429.7183463481174

Similarly, try for other numbers.

import math
gvn_angl = 4
degre_angl = math.degrees(gvn_angl)
print("The given angle{", gvn_angl, "} in degrees = ", degre_angl)

Output:

The given angle{ 4 } in degrees =  229.1831180523293

Method #2: Using Built-in Functions (User Input)

Approach:

  • Import math module using the import keyword.
  • Give the number (angle) as user input using the float(input()) function and store it in a variable.
  • Pass the given angle as an argument to the math.degrees() function that converts the given radian angle to a degree angle.
  • Store it in another variable.
  • Print the given angle in degrees.
  • The Exit of the Program.

Below is the implementation:

# Import math module using the import keyword
import math
# Give the number(angle) as user input using the float(input()) function 
# and store it in a variable.
gvn_angl =  float(input("Enter some random number = "))
# Pass the given angle as an argument to the math.degrees() function that
# converts the given radian angle to a degree angle.
# Store it in another variable.
degre_angl = math.degrees(gvn_angl)
# Print the given angle in degrees.
print("The given angle{", gvn_angl, "} in degrees = ", degre_angl)

Output:

Enter some random number = -10.5
The given angle{ -10.5 } in degrees = -601.6056848873644

Python math.degrees() Method with Examples Read More »