In the previous article, we have discussed Python Program for cosh() Function
sinh() Function in Python:
The sinh() function in Python computes the Trigonometric Hyperbolic Sine for the given expression.
Syntax:
math.sinh(x)
Parameters:
x: This is Required. It is a number for which the hyperbolic sine must be calculated. If the value is not a number, a TypeError is returned.
Return Value:
Returns a float value representing a number’s hyperbolic sine.
- The sinh() function returns the Sine value if the number argument is positive or negative.
- The sinh function returns TypeError if the number argument is not a number.
Examples:
Example1:
Input:
Given first number = 0.3 Given second number = 1
Output:
The result after applying sinh() function on above given first number 0.3 = 0.3045202934471426 The result after applying sinh() function on above given second number 1 = 1.1752011936438014
Example2:
Input:
Given first number = 3 Given second number = 5.5
Output:
The result after applying sinh() function on above given first number 3 = 10.017874927409903 The result after applying sinh() function on above given second number 5.5 = 122.34392274639096
Program for cosh() 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.sinh() function to the given first number to get the hyperbolic sine value of a given number.
- Store it in another variable.
- Print the above result.
- Similarly, do the same for the other number.
- Apply math.sinh() 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, -3, 1, 0.8] # Give the first number as static input and store it in another variable. gvn_numb1 = 0.3 # Apply math.sinh() function to the given first number to get the hyperbolic # sine value of a given number. # Store it in another variable. fnl_rslt = math.sinh(gvn_numb1) # Print the above result print("The result after applying sinh() function on above given first number", gvn_numb1, " = ", fnl_rslt) # similarly do the same for the other number. gvn_numb2 = 1 print("The result after applying sinh() function on above given second number", gvn_numb2, " = ", math.sinh(gvn_numb2)) # Apply math.sinh() function to the given list element and print it. print( "The result after applying sinh() function on given list element gvnlst[1] = ", math.sinh(gvn_lst[1]))
Output:
The result after applying sinh() function on above given first number 0.3 = 0.3045202934471426 The result after applying sinh() function on above given second number 1 = 1.1752011936438014 The result after applying sinh() function on given list element gvnlst[1] = -10.017874927409903
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.sinh() function to the given first number to get the hyperbolic sine value of a given number.
- Store it in another variable.
- Print the above result.
- Similarly, do the same for the other number.
- Apply math.sinh() 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.sinh() function to the given first number to get the hyperbolic # sine value of a given number. # Store it in another variable. fnl_rslt = math.sinh(gvn_numb1) # Print the above result print("The result after applying sinh() 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 sinh() function on above given second number", gvn_numb2, " = ", math.sinh(gvn_numb2)) # Apply math.sinh() function to the given list element and print it. print( "The result after applying sinh() function on given list element gvnlst[2] = ", math.sinh(gvn_lst[2]))
Output:
Enter some random List Elements separated by spaces = 1 1.5 2.5 3 Enter some random number = 3 The result after applying sinh() function on above given first number 3.0 = 10.017874927409903 Enter some random number = 5.5 The result after applying sinh() function on above given second number 5.5 = 122.34392274639096 The result after applying sinh() function on given list element gvnlst[2] = 6.0502044810397875
Know all about Mathematical Functions in Python by going through our Python Mathematical Methods Examples well explained step by step.