In the previous article, we have discussed Python Program for asinh() Function
atanh() Function in Python:
The inverse hyperbolic tangent of a number is returned by the math.atanh() method.
Note: It should be noted that the parameter passed in math.atanh() must be between -0.99 and 0.99.
Syntax:
math.atanh(x)
Parameters:
x: This is required. It is a number between -0.99 and 0.99 that is positive or negative. If x is not a number, a TypeError is returned.
Return Value:
Returns a float value representing a number’s inverse hyperbolic tangent.
- The atanh function returns the Hyperbolic Arc Tangent value if the number argument is both positive and negative.
- The atanh function returns ValueError if it is not between -1 (exclude) and 1 (exclude).
- If it is not a number, the atanh function throws a TypeError.
Examples:
Example1:
Input:
Given first number = 0.6 Given second number = -0.8
Output:
The result after applying atanh() function on above given first number 0.6 = 0.6931471805599453 The result after applying atanh() function on above given second number -0.8 = -1.0986122886681098
Example2:
Input:
Given first number = 0.54 Given second number = -0.9
Output:
The result after applying atanh() function on above given first number 0.54 = 0.6041556029622671 The result after applying atanh() function on above given second number -0.9 = -1.4722194895832204
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.atanh() function to the given first number to get the inverse hyperbolic tangent of a given number
- Store it in another variable.
- Print the above result.
- Similarly, do the same for the other number.
- Apply math.atanh() 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 = [0.25, 0.35, 1, 4] # Give the first number as static input and store it in another variable. gvn_numb1 = 0.6 # Apply math.atanh() function to the given first number to get the inverse # hyperbolic tangent of a given number # Store it in another variable. fnl_rslt = math.atanh(gvn_numb1) # Print the above result. print("The result after applying atanh() function on above given first number", gvn_numb1, " = ", fnl_rslt) # similarly do the same for the other number. gvn_numb2 = -0.8 print("The result after applying atanh() function on above given second number", gvn_numb2, " = ", math.atanh(gvn_numb2)) # Apply math.atanh() function to the given list element and print it. print( "The result after applying atanh() function on given list element gvnlst[1] = ", math.atanh(gvn_lst[1]))
Output:
The result after applying atanh() function on above given first number 0.6 = 0.6931471805599453 The result after applying atanh() function on above given second number -0.8 = -1.0986122886681098 The result after applying atanh() function on given list element gvnlst[1] = 0.36544375427139614
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.atanh() function to the given first number to get the inverse hyperbolic tangent of a given number
- Store it in another variable.
- Print the above result.
- Similarly, do the same for the other number.
- Apply math.atanh() 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.atanh() function to the given first number to get the inverse # hyperbolic tangent of a given number # Store it in another variable. fnl_rslt = math.atanh(gvn_numb1) # Print the above result. print("The result after applying atanh() 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 atanh() function on above given second number", gvn_numb2, " = ", math.atanh(gvn_numb2)) # Apply math.atanh() function to the given list element and print it. print( "The result after applying atanh() function on given list element gvnlst[2] = ", math.atanh(gvn_lst[2]))
Output:
Enter some random List Elements separated by spaces = 0.1 0.2 -0.3 4.4 Enter some random number = 0.54 The result after applying atanh() function on above given first number 0.54 = 0.6041556029622671 Enter some random number = -0.9 The result after applying atanh() function on above given second number -0.9 = -1.4722194895832204 The result after applying atanh() function on given list element gvnlst[2] = -0.30951960420311175
Know all about Mathematical Functions in Python by going through our Python Mathematical Methods Examples well explained step by step.