- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

# Haskell Program to find the hyperbolic tangent of given radian value

This tutorial will help us in finding hyperbolic tangent of the given radian value. The hyperbolic functions are used to calculate the angles and the distances. The hyperbolic tangent function gives us the hyperbolic tangent value of the radian angle. The angle value must be a radian value. If the angle is any degree value then, it must be converted into radian value first.

## Syntax

tanh(angle)

Here, tanh() is a built-in function and angle is passed as parameter to compute the hyperbolic tangent of the entered angle, where angle must be a radian value.

## Method 1: Finding hyperbolic tangent using in-built tanh() function

In this method,we will call the tanh() function and angle to be find the hyperbolic tangent of, is passed as parameter to the function.

### Algorithm

**Step 1**− Program execution will be started from main function. The main() function has whole control of the program.**Step 2**− A variable named, “angle” is being initialized. Initially, it will have the garbage value. Then, a constant value is being assigned to it.**Step 3**− The constant value that will be the radian angle value, is assigned to the variable “angle” by using the assignment operator.**Step 4**− The inbuilt hyperbolic tangent function, tanh() is called. It’s definition is already available in the standard library.**Step 5**− “Angle” variable that contains the radian value is passed as parameter to the tanh() function.**Step 6**− The result is assigned to the “result” variable after tanh() function computes the final resultant value and final output is displayed by printing the result value.

### Example

In this example, we are going to see that how we can calculate hyperbolic tangent of any radian angle. This can be done by using in-built tanh() function.

main = do let angle = 1 putStrLn "The radian angle whose hyperbolic tangent is to be computed is: " print (angle) let result=tanh(angle) putStrLn "The resultant hyperbolic tangent is: " print (result)

### Output

The radian angle whose hyperbolic tangent is to be computed is: 1.0 The resultant hyperbolic tangent is: 0.7615941559557649

## Method 2: Using in-built tanh() function for degree values by converting them into radian

In this method, the radian value obtained after computation is used.The tanh() function is called and angle to be find the hyperbolic tangent of (in radian), is passed as parameter to the function. Then, final result is printed.

### Algorithm

**Step 1**− Program execution will be started from main function. The main() function has whole control of the program.**Step 2**− A variable named “degree”, is being initialized. And a constant degree value is assigned to it (I.e., 90, 60,45,etc.)**Step 3**− A variable named “angle”, is initialized to convert degree into radian value. This variable will contain the radian value after conversion.**Step 4**− Radian value is obtained by using formula degree*pi/180. For example, 90 degree is converted into radian using this formula and radian value obtained is 1.57095.**Step 5**− Radian value computed is assigned to the variable “angle”. Now, the variable “angle” contains the radian value, that is further passed as parameter.**Step 6**− The inbuilt hyperbolic tangent function, tanh() is called. It’s definition is already available in the standard library.**Step 7**− “angle” variable that contains the radian value is passed as parameter to the tanh() function.**Step 8**− The result is assigned to the “result” variable after tanh() function computes the final resultant value and final output is displayed by printing the result value.

### Example

In this example, we are going to see that how we can calculate hyperbolic tangent of any degree angle.

main = do let degree= 90 let angle=degree * 3.14159 / 180 putStrLn "The radian angle whose hyperbolic tangent is to be computed is: " print (angle) let result=tanh(angle) putStrLn "The resultant hyperbolic tangent is: " print (result)

### Output

The radian angle whose hyperbolic tangent is to be computed is: 1.570795 The resultant hyperbolic tangent is: 0.9171521249300707

## Conclusion

The hyperbolic tangent value in radians for the given angle in Haskell can be calculated by using the tanh() function. The value passed as parameter to this function must be in radian. And for degree values, it can be converted into radian. And this radian value is then passed to the tanh() function resulting, Example is executed and result is printed successfully.

The data type of the resultant value obtained depends on the data type of the desired result value on the computation of the value entered, whether it could be of integer, float or double.