Python Program for acosh() Function

In the previous article, we have discussed Python Program for tan() Function
acosh() Function in Python:

The inverse hyperbolic cosine of a number is returned by the math.acosh() method.

It should be noted that the parameter passed to acosh() must be greater than or equal to 1.

Syntax:

math.acosh(x)

Parameter:

x: This is required. A positive number greater than or equal to one. If x is not a number, a TypeError is returned.

Return Value:

The inverse hyperbolic cosine of x is represented as a float in the return value.

  • The acosh function returns the hyperbolic Arc Cosine value if the number argument is positive.
  • If the value is negative, the acosh function returns ValueError.
  • If it’s not a number, the acosh function throws a TypeError.

Examples:

Example1:

Input:

Given first number = 8
Given second number = 36

Output:

The result after applying acosh() function on above given first number 8  =  2.7686593833135738
The result after applying acosh() function on above given second number 36  =  4.276473161941219

Example2:

Input:

Given first number = 14.5
Given second number = 25

Output:

The result after applying acosh() function on above given first number 14.5  =  3.366104642925109
The result after applying acosh() function on above given second number 25  =  3.9116227652145885

Program for acosh() Function in Python

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

Approach:

  • Import math module using the import keyword.
  • Give the list as static input and store it in a variable.
  • Give the first number as static input and store it in another variable.
  • Apply math.acosh() function to the given first number to get inverse hyperbolic cosine of a given number
  • Store it in another variable.
  • Print the above result.
  • Similarly, do the same for the other number.
  • Apply math.acosh() function to the given list element and print it.
  • The Exit of Program.

Below is the implementation:

# Import math module using the import keyword.
import math
# Give the list as static input and store it in a variable.
gvn_lst = [1, 5, 6, 3]
# Give the first number as static input and store it in another variable.
gvn_numb1 = 8
# Apply math.acosh() function to the given first number to get inverse
# hyperbolic cosine of a given number
# Store it in another variable.
fnl_rslt = math.acosh(gvn_numb1)
print("The result after applying acosh() function on above given first number",
      gvn_numb1, " = ", fnl_rslt)
# similarly do the same for the other number.
gvn_numb2 = 36
print("The result after applying acosh() function on above given second number",
      gvn_numb2, " = ", math.acosh(gvn_numb2))
# Apply math.acosh() function to the given list element and print it.
print(
    "The result after applying acosh() function on given list element gvnlst[1] = ", math.acosh(gvn_lst[1]))

Output:

The result after applying acosh() function on above given first number 8  =  2.7686593833135738
The result after applying acosh() function on above given second number 36  =  4.276473161941219
The result after applying acosh() function on given list element gvnlst[1] =  2.2924316695611777

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

Approach:

  • Import math module using the import keyword.
  • Give the list as user input using list(),map(),input(),and split() functions.
  • Store it in a variable.
  • Give the first number as user input using the float(input()) function and store it in a variable.
  • Apply math.acosh() function to the given first number to get inverse hyperbolic cosine of a given number
  • Store it in another variable.
  • Print the above result.
  • Similarly, do the same for the other number.
  • Apply math.acosh() function to the given list element and print it.
  • The Exit of Program.

Below is the implementation:

# Import math module using the import keyword.
import math
# Give the list as user input using list(),map(),input(),and split() functions.
# Store it in a variable.
gvn_lst = list(map(float, input(
    'Enter some random List Elements separated by spaces = ').split()))
# Give the first number as user input using the float(input()) function
# and store it in a variable.
gvn_numb1 = float(input("Enter some random number = "))
# Apply math.acosh() function to the given first number to get inverse
# hyperbolic cosine of a given number
# Store it in another variable.
fnl_rslt = math.acosh(gvn_numb1)
print("The result after applying acosh() function on above given first number",
      gvn_numb1, " = ", fnl_rslt)
# similarly do the same for the other number.
gvn_numb2 = float(input("Enter some random number = "))
print("The result after applying acosh() function on above given second number",
      gvn_numb2, " = ", math.acosh(gvn_numb2))
# Apply math.acosh() function to the given list element and print it.
print(
    "The result after applying acosh() function on given list element gvnlst[2] = ", math.acosh(gvn_lst[2]))

Output:

Enter some random List Elements separated by spaces = 10 20 30 50 
Enter some random number = 14.5
The result after applying acosh() function on above given first number 14.5 = 3.366104642925109
Enter some random number = 25
The result after applying acosh() function on above given second number 25.0 = 3.9116227652145885
The result after applying acosh() function on given list element gvnlst[2] = 4.0940666686320855

Know all about Mathematical Functions in Python by going through our Python Mathematical Methods Examples well explained step by step.